Skip to content

alexandrelamberty/hortus-api

Repository files navigation

Build & Tests Docker Codacy Badge codecov DockerHub

Hortus API

Gardening planner API part of the Hortus project.

This application expose an API with NestJS that connect to a MongoDB and Redis databases. It use authentication/encryption with JWT and BCRYPT.

The API implement the Hortus API Specification

Technologies, languages, frameworks

Requirements

Usage

This application is part of a Docker stack. see: Hortus project to run the complete stack.

Development

This API run as a Docker service and rely on a MongoDB database and a Redis cache service.

Run required services

See Hortus

Environment variables

Create a file named .env and insert the following properties

ENV=dev
PORT=3333
PAIRING_KEY=9fca54477c8ad4e70dc5e1084f884aad
JWT_SECRET=d7a481461577ba4c3c4c6946cca7204b
JWT_EXPIRE=90
BCRYPT_HASH=7f91317e30a02bc7b87205e95b842df2
DATABASE_URI=mongodb://hortus:hortus@localhost:27017/hortus
STATIC_DIR=/upload
UPLOAD_PATH=/upload
CACHE_HOST=localhost
CACHE_PORT=6379
CACHE_TTL=300
SESSION_HOST=localhost
SESSION_PORT=6380
SESSION_TTL=300

This config will work out of the box in most case. Verify that the ports specified in the configuration are not in use.

Running with NPM

Run the application

npm run start:development

Tests

To implement

npm run tests

Build and run with Docker

Build the image, see: Dockerfile.

docker build . -t alexandrelamberty/hortus-api:{tag}

Run the image, specify the ports mapping, environment variables file and network to join.

FIXME: link source folder

docker run -p 3333:3333 --network=hortus_default --env-file .env --name hortus-api -d alexandrelamberty/hortus-api:{tag}