FrontSpot Hub: Ptushki, backend
These instructions will running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- To run application locally you need docker installed.
- node 14.x.
- postgreSQL 11.x
docker compose up -d
When run locally (without docker) make sure that you added postgres instance creds in .env
file. To know which variables to use you have to look in ./config/default.js
. In simplest case your .env
should be look like:
So, now you ready to start from:
npm i
- and then
npm start
to build and start server in prod mode ornpm run start:dev
to run server in dev mode with rebuilding on changes.
At any time you can start filling db with fixtures, this script works independently from server:
npm run fixtures
Be attentive: it drops db and schemes.
It will creates examples of all entities and users. All users come with password 1234
. For convenience there are also some users with emails which match their roles:
Main app routes are
users/
auth/
observations/
rings/
Although it would be best to start the diggin by going to the OpenAPI documentation located at swagger/
Project is committing to ESLint coding styles with formatting via Prettier. Also Prettier is configured for other types of files: .json
, .md
, .yaml
To lint .ts
files run:
npm run lint
or
npm run lint:fix
if you want to simultaneously fix them. But you shouldn't pay much attention for this. As most part of work is doing in time of commit. All staged changes are linted and / or only prettified and added to stage again to commit then, of course if there aren't unfixable errors.
Also project has tests which can be run with command
npm test
With adding modifications :coverage
or :watch
should be run corresponding commands. Don't forget about run
after npm
.
Currently, there are only functional tests. Which fully cover authentication and authorization flow.
These tests require additional db instance, as they drop db every time. You can declare this db in environment variables using the same variables as for main db instance but with prefix _TEST_
like this: PG_TEST_URL
and so on.
Unfortunately, now unit tests isn't implemented.
Add additional notes about how to deploy this on a live system
By default, any time you commit will be started linting and fixing which includes eslint
& prettier
rules.
There also exists template for Pull Requests. Please fill it as much as possible.
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the ISC License - see the LICENSE.md file for details