This is an exercise with solution of an API server build on Postgres and NodeJS. The purpose of this exercise is to show how to implement a simple server to help authenticate user using username and password and provide JWTs as authorization method.
- Clone repo to your local machine
git clone https://github.com/VicaSpace/athen-books.git
- Install needed packages
- Using npm:
npm install
- Using yarn:
yarn
- Set up .env file for enviroment variables
- Make a copy of .env.example and named it .env
- Modify username, password and database name for postgres server:
DATABASE_URL="postgresql://postgres_user:[email protected]:5432/postgres_database?schema=public"
- Run server
- Using npm:
npm run dev
- Using yarn:
yarn dev
- Swagger
- Solution:
git checkout solution
Tests are already created. Run tests to test you APIs behavior.
- Run tests
- Using npm:
npm run test
- Using yarn:
yarn test
- Run tests with coverage
- Using npm:
npm run test:coverage
- Using yarn:
yarn test:coverage
Vu Thi Thien Anh [email protected]