Development of the back-end gateway service for the VirusSeq Portal-ui
This file is meant as a quick introduction, WIP
This app has been tested using NodeJS v^18, yet should work with earlier versions.
This service depends on a Postgres instance of its own, as well as those owned by Singularity and Song. Make sure to provide the right environment variables for it to reach those correctly.
Setting up the project, and prepare things to make changes
# 1. clone the repository
git clone [email protected]:virusseq/portal-gateway.git
# 2. install the dependencies
npm ci
Now you should be able to start the server from the project's root folder:
# run the server (on port 8080)
npm run dev
# or better yet
npm run dev:nodemon
# which also restarts if linked packages are updated (e.g. Arranger)
# NOTE: if using NodeJS v17+, you may have to do one of the following:
NODE_OPTIONS=--openssl-legacy-provider npm run dev
# or do this, before running the server
export NODE_OPTIONS=--openssl-legacy-provider
The development server will start on port 4000
by default.
There is API documentation provided by Swagger, available at /swagger.
Leveraging Ley, this API is able to apply migrations every time it is deployed to one of our k8s environments. The changes are implemented in the sequential files contained in the migrations
directory, and you may create new ones by running the following command:
npm run migrate new <short_migration_description>.ts
Each of these files should contain an up
function that effects the changes, and a down
function that rolls them back entirely.
// Example migration file
import { Sql } from 'postgres';
export const up = async (client: Sql) => {
await client`create table example (...)`;
};
export const down = async (client: Sql) => {
await client`drop table example`;
};