Sign inSign up

mediacomem/modos-backend

By mediacomem

•Updated over 5 years ago

Image
0

426

mediacomem/modos-backend repository overview

⁠MoDoS Backend

The MoDoS backend is mainly a REST API which is intended to be used by various front-end (mobile, web, etc...).

⁠Getting started with Docker

Make sure to install the following requirements:

Then perform the following steps:

# Create .env and adapt it to your environment if necessary. The default settings should
# work out of the box.
cp .env.sample .env

# Run the application.
docker-compose up --build

The API should be available at http://localhost:3000/api⁠.

⁠Getting started with Node.js

Make sure to install the following requirements:

You will also need to create a database with a schema named modos in your PostgreSQL cluster:

CREATE DATABASE modos;
\connect modos
CREATE SCHEMA modos;

Then perform the following steps:

# Install dependencies.
npm ci

# Create .env and adapt it to your environment, notably the $MODOS_DATABASE_URL variable.
cp .env.sample .env

# Build the application.
npm run build

# Migrate the database to the latest version (the database you configured in
# .env must already exist).
npm run migrate

# Run the application.
npm run dev

The API should be available at http://localhost:3000/api⁠.

Once your server is running, you can access:

⁠Configuration

The default configuration is suited for a development environment. However, if you want to tweak some values (or switch to a production environment), you can modify .env according to your needs.

Look at src/config/config.ts for more information on available configuration options.

⁠Scripts

ExampleDescription
npm run buildCompile the application to the dist directory.
npm run devRun the application in development mode (it will recompile and restart everytime the source code changes).
npm run startRun the compiled application (requires npm run build to have been run first).
⁠Database management
ExampleDescription
npm run migration:create -- -n UpdateSomeTableCreate a new blank database migration.
npm run migration:generate -- -n UpdateSomeTableAutomatically generate a new database migration based on schema changes.
npm run migrateRun all pending database migrations (requires npm run build to have been run first).
npm run rollbackRoll back the last executed database migration (requires npm run build to have been run first).

Note that the npm run migrate and npm run rollback scripts will work in production, while the other migration management scripts can only be used in development.

⁠More

See the scripts defined in package.json⁠.

After the migrations have taken place, you need to refresh a view using this SQL query:

REFRESH MATERIALIZED VIEW "modos"."network_convex_hull_v";

Tag summary

Content type

Image

Digest

Size

49.2 MB

Last updated

over 5 years ago

docker pull mediacomem/modos-backend