panta-pasen-api

1.2.0 • Public • Published

pp-api

Monolithic Node Express Rest API

The full list of endpoints can be found on the generate API Doc

The functionality is divided by data entity on routes, controllers and models for example:

Scan routes will handle the scan routes incoming express connections checking the authorization, validating the request parameters get information from the Authorization token if need it then calling the controller.

Scan Controller will handle the business logic and maybe defer to other pp-nm-modules that have encapsulated functionality using Mongoose and Sequelize Models to connect to the database.

The mongoose and sql models to connect to the database pp-nm-database-models to hold here.

This API connect to three different sources of data

PostgreSQL to handle account and transactions related data

MongoDB to handle operational data like code, scans and tokens

Redis to add element to a queue handled by pp-queue

The connection is handled in database config and most off values come from .env files

Getting Started

This is instruction will help you get up running with the project on your local machine

Prerequisites

You should install:

Node 10 to run the application

You can install separately or run docker in current repositories:

Use docker

Docker for run locally.

 docker-compose up -d 

Install manually

MongoDB It is 4.0.12 version

PostgreSQL We are running on 9.6

Redis we are using redis for bull (queue jobs)

Then you should init data: Use this repositories with dump and init scripts:
pp-data.

Before running a .env file needs to be present you can use .env.example as starting point

The authorization mechanism of the app will filter the request per domain, so need to update the roles table with the host where the API is going to be running, something like will do if you run the app on localhost port 4000: it will run automatically in pp-data.

Setup connection for pgAdmin in a docker:

host: host.docker.internal
db: pp_rc_current
user: pp_rc_user
password: bowerPass

For mac in docker use :

If you just want to reach a service on the host from within a docker container on Mac OS X you cannot use localhost or 127.0.0.1 . Instead you have to use

host.docker.internal

Running

To run the application you will need you to clone the repository and install the dependencies with:

make node_modules

Then you can start the app with

make run

for starting the API with a watcher for changes

Tests

The test for the API live on test folder and mostly run per API endpoint being more like integration test connecting to the database and sending request to a test API superserver

The framework are mocha, chai, sinon, nock and you can run them with

make test

Be careful that the test will pick up the .env configuration and interact with the MongoDB database set in there

Documentation

If you want to see the API endpoints documentation locally run

make doc

And then open the docs/index.html page

Some processes are documented here

Code styles

We enforce the code style rules with eslint and the base rules set on @pantapasen/eslint-config

Git Workflow

We follow a simple git workflow with feature and bugfix branches and the JIRA code on branch and commits

For example:

git checkout -b feature/BOW-75-fix-login-bug
git commit -m "BOW-75 Fix the bug on user login."

where 75 - sprint number

Deployment

We use jenkins manual deploy:Jenkins Full instruction you can find here: Link

Migration

Full instruction you can find here: Link

We use insomnia for test our endpoints: https://insomnia.rest/

and use this plugin to sync file for insomnia https://insomnia.rest/plugins/insomnia-plugin-repo-sync-2 and setup folder for sync to dev_tools

Readme

Keywords

none

Package Sidebar

Install

npm i panta-pasen-api

Weekly Downloads

0

Version

1.2.0

License

ISC

Unpacked Size

3.26 MB

Total Files

422

Last publish

Collaborators

  • pantapasensweden