fccc-server

1.32.0 • Public • Published

FCCC Health Practice Software

What is this repository for?

This is the Backend API server for the FCCC software application, it hosts API endpoints, database functionality and other important related features that are needed for the FCCC software application.

Getting Started

Requirements

  • Node Version 12.18.3 : You can download Node from the official Node.js webpage.
  • MySQL Version 5.7 : It is important that your MySQL version matches that of the application in order to avoid some issues. You can get this particular version from the official MySQL webpage.
  • Redis Server ^5.0.4 : Make sure you have a redis server setup locally otherwise download & setup.

Node Environment

You need to create environmental variables to hold specific information that the application will need, you can do this by creating a .env file in the root project directory. There are also important keys in the .env.sample file, add these keys in your .env file and provide adequate values, they are necessary for the application to work.

Install Packages

Install the necessary packages for the application by running the following code in your terminal:

$ npm run install-local

Note : You must install peer dependencies manually, they are found under peerDependencies in the package.json file.

Database Configurations

Install knex CLI - Optional

Knex is an SQL query builder for Node.js and will be used for building MySQL queries in this application, so get that installed by running:

$ npm install knex -g
Migrating database

Create a database manually called betaquick_fccc. To migrate the database, run:

npm run migrate

or switch to the db directory and run:

knex migrate:latest --env development

You also need to seed the database with necessary data:

npm run seed

With that done, your created database should have been populated with necessary data needed by the application. Remember to add the necessary database information such as username, password, host and port into your .env file.

Run server

Start up the application server by running:

$ npm run dev

Setting up the Docker Image

Make sure you have Docker and Docker-compose installed locally, there are links below on how to setup docker locally depending on your operating system:

When that's done, make sure docker is up and running and then through your terminal navigate to the fccc-server project directory, Run the following commands to build and start the image: To build the image, in your terminal run:

$ docker-compose build

When the image is successfully built, you can start it up by running the following:

$ docker-compose up

Project Structure and Documentation

Project Structure

  • All database related configurations such as backups, seed, migration data, etc... are situated in the db folder.
  • All API endpoints can be located in app/config/routes.js.
  • Controllers and services are found in app/controllers and app/services directories respectively.
  • Database models are found in the app/models directory. This application uses an ORM Objection.js for modelling the DB, Objection.js is built upon the Knex query builder.

Documentation

The documentation for the API endpoints is generated using Postman and can be found at the following Postman URL. You need to import the collection into your Postman environment to be able to make changes to it. Whenever you add a new endpoint, make sure to update the collection and documentation with the new changes. Also when updating the collection, try to add example responses for each endpoint.

Test Coverage

The Mocha library and other packages are used for testing parts of the application, all tests can be found in the test directory. You can execute tests by running the command below:

$ npm run test-coverage

Contribution guidelines

  • 100% test coverage is important before pushing to the remote origin.
  • All PR submitted should include a 100% test coverage.
  • Do not comment out codes, delete them instead.
  • Maintain the projects style of code.

Who do I talk to?

  • Repo owner or admin
  • Other community or team contact

Troubleshooting

  1. On MySQL Versions other than 5.7, you may run into an error when trying to migrate or seed the database : ER_TRUNCATED_WRONG_VALUE: Incorrect date value...

    Try one or more of the following methods to fix the problem :

    • Upgrade/downgrade your MySQL version to 5.7

    • Paste the following code at the bottom of your MySQL config file my.cnf(my.ini for windows) : set @@sql_mode='no_engine_substitution';

    • In your MySQL shell, run the following code: select @@sql_mode; SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION'; SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION'; Note : Using this method you may need to run it everytime you restart your MySQL server.

  2. When you pull changes from the remote origin, it is possible that changes/additions have been made to the database tables and seed files, this may cause errors when running the application or when running tests. Such errors can be fixed by migrating your database and seeding it with latest data:

    $ npm run migrate
    $ npm run seed
  3. Follow this guide to install redis on Windows

Readme

Keywords

Package Sidebar

Install

npm i fccc-server

Weekly Downloads

0

Version

1.32.0

License

none

Unpacked Size

1.31 MB

Total Files

186

Last publish

Collaborators

  • radiumrasheed