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
- Getting started with Node.js
- A few links to browse
- Configuration
- Scripts
Make sure to install the following requirements:
- Docker 19+
- Docker Compose 1.27+
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.
Make sure to install the following requirements:
- Node.js 12
- PostgreSQL 12 with:
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:
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.
Example | Description |
---|---|
npm run build |
Compile the application to the dist directory. |
npm run dev |
Run the application in development mode (it will recompile and restart everytime the source code changes). |
npm run start |
Run the compiled application (requires npm run build to have been run first). |
Example | Description |
---|---|
npm run migration:create -- -n UpdateSomeTable |
Create a new blank database migration. |
npm run migration:generate -- -n UpdateSomeTable |
Automatically generate a new database migration based on schema changes. |
npm run migrate |
Run all pending database migrations (requires npm run build to have been run first). |
npm run rollback |
Roll back the last executed database migration (requires npm run build to have been run first). |
Note that the
npm run migrate
andnpm run rollback
scripts will work in production, while the other migration management scripts can only be used in development.
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";