Skip to content

forestbiotech-lab/PHENO-old

Repository files navigation

Plant breeding API

This is an implementation of BrAPI using nodeJS. It is being developed by the Portuguese Node within the context of ELIXIR-EXCELERATE.

Overview

This implementation is done in a NodeJS which provides the node package manager (npm) to manages all it's dependencies and for data persistence mySQL a relational database is used. The major technologies used are listed below.

implementation which is a JavaScript run-time environment.

  • is used as the web Framework to routes the calls.
  • a promise-base ORM is used to connect to the database defined in the config.js.
  • Pug is used as a
A relational database

Getting things running

The following sections detail all the necessary steps to get this project running on your server.

How to install

To install this project you must have nodeJS and npm installed on your system. Once you have nodejs/node and npm available on your system, simply clone this repro and get all the necessary packages:

	$ git clone https://github.com/forestbiotech-lab/BrAPI.git #Clone repository
	$ cd BrAPI #Enter directory
    $ npm install #Install all the necessary node packages

Setup database

This will guide you through installing the mySQL server. Once you have your mySQL server up and running you can load the data model with or without the test dataset.

	#Details for ubuntu
	$ sudo apt-get update
	$sudo apt-get install mysql-server
	$ sudo mysql_secure_installation
	#Setup a new user and permissions
	#...

	$ mysql -p -u [user] -D [database] < [pathToProject]/SQL/BrAPI_dan.sql #this will  install the empty database

	#or

	$ mysql -p -u [user] -D [database] < [pathToProject]/SQL/LATEST_dump.sql #this will install the latest db dump	
 
Database credentials

Configure config_brapi.js or whatever file is setup in components/[schema]/sqldb/index.js

	module.exports = {
	  sql: {
	  	host: '[hostIfNotLocal]',
	    database: '[theDBtoUse]',
	    username: '[yourUsernaem]',
	    password: '[yourPassword]',
	    dialect: 'mysql', // PostgreSQL, MySQL, MariaDB, SQLite and MSSQL See more: http://docs.sequelizejs.com/en/latest/
	    logging: console.log,
	    timezone: '+05:30',
	    limit: 1000  //Limit of result to get if findAll is used
	  },
	  mongo: {
	    uri: ''
	  },
	  seedDB:false,
	  seedMongoDB:false,
	  seedDBForce:true,
	  db:'sql' // mongo,sql if you want to use any SQL change dialect above in sql config
	}

Note: Create a user with limited privileges, enable query only to necessary tables and local access only.

How to run

Once all dependencies by nodejs have been installed you can start the server in developer mode by running, :

    $ DEBUG=brapi:* npm start 

It should spin up a web server available on localhost: http://127.0.0.1:3000/

You can define alternate address and port with the vars:

  • port
  • address
    $ address=192.168.1.100 port=3333 DEBUG=brapi:* npm start 
Production vs Development

If you what to run the Web Server with external access, consider using the production webserver. It will spin up a secure Web Server instead. Change the vars email and domains in:

  • PathToBrAPI/bin/www

then run with the mode variable set to PRODUCTION:

    $ mode=PRODUCTION DEBUG=brapi:* npm start 

Database

Default data model being used is fig. 2.

Figure 2 - Data model used for this BrAPI implementation.

Refer to SQL directory to get creation scripts.

Specs to be implemented

Currently this implementation is focused on getting the ELIXIR-Excelerate mandatory calls up and working. But will soon implement all the calls in the specification.

Pagination (TODO)

This section has not been updated

If the response is a single record that doesn't require pagination, then the value for the "pagination" key is the javascript reserved word 'NULL'. When the results are paginated, the pagination object contains the keys "pageSize", "currentPage", "totalCount", "totalPages". The first page will be page 0 (zero).