Project: Rememo
Group ID: #13
Alessio Gandelli - alessiogandelli
Mattia Salvador - MattiaSalvador201506
Nicola Toscan - nicolatoscan
Taras Rashkevych - TarasRashkevych99
This project consists of an express rest API server written in Typescript.
A web application that uses this API is being developed at https://github.com/nicolatoscan/rememo-webapp
A live demo is available at https://rememo.nicolatoscan.dev
You can find there a README and wiki on how it's being developed.
A live demo of the APIs is available at https://rememo-api.herokuapp.com/
API documentation available at https://rememoapi.docs.apiary.io/
Make sure you have installed Node.js.
This project was developed with Node v15 and tested on Ubuntu and Windows.
Clone the repository on your machine.
git clone https://github.com/nicolatoscan/rememo-api.git
Inside the rememo-api
folder install the necessary dependencies and transpile the typescript .
npm install
Create a file called .env
using the .env.example
template file.
You can create a similar file called .env.test
that will be used during tests.
IMPORTANT! The content of the DEFAULT_DB in the .env.test
will be wiped every time the tests are run.
Here's an example of a .env
or .env.test
file.
.env
PORT=3000
DEFAULT_DB=rememo
MONGODB_CONNECTION_STRING=<insert-your-connection-string>
TOKEN_SECRET=<a-token-secret>
CRYPTO_SECRET=<crypto-secret>
.env.test
PORT=4000
DEFAULT_DB=rememo-test
MONGODB_CONNECTION_STRING=<insert-your-connection-string>
TOKEN_SECRET=<a-token-secret>
CRYPTO_SECRET=<crypto-secret>
Initialize your database:
npm run init-database
Run the application:
npm run start
From the repository a docker image is automatically created using Dockerfile
.
The project can be run in a docker container using the same .env
described before with:
docker run -p 3000:3000 --env-file ./.env nicolatoscan/rememo-api
IMPORTANT! The test will wipe the database, check you are using the .env.test
variables.
Tests for the code are made using the Mocha test framework and can be run with:
npm test
Tests are divided into two macro categories.
Mocha tests functions will test services and models.
Postman tests are run inside a mocha test with Newman using an exported JSON containing the request and the environment variables.
The process will spawn a child running the express server on the port 4000 or the one specified in the .env.test
file.
The postman tests will make an http call to the endpoint specified in test/postman/Rememo.postman_environment.json
so, if you change the port from 4000, you will need to change the endpoint hardcoded in the postman environment variables JSON.
The application come with several npm scripts:
npm run serve
- Transpile and run the application in one commandnpm run start
- Start cluster of applications with pm2npm run watch
- Transpile, run the application and hot-reloead on changesnpm run transpile
- Transpile the typescript file to javascriptnpm run postinstall
- Transpile the project after anpm install
npm run commit
- Commit with commitizennpm run commit:sign
- Signed commit with commitizennpm run init-database
- Clean and initialize the databasenpm test:start
- Run all the testsnpm test
- Transpile the application and run all the tests