This repository contains a basic REST API with a simple jwt login endpoint and middleware to check authentication but implemented using concepts of TDD
- Nodejs
- Express
- PostgreSQL
- SQLite (for tests)
- Docker
- SequelizeORM
- Jest
To manage the dependencies, this project uses preferably yarn, but you can feel free to use npm instead. If you want to use yarn but don't have it yet, check out the installation guide from official documentation
With yarn installed open your favorite shell in the root folder of this project and then run:
yarn
Or if you choose to use npm, run:
npm i
Running the application in development mode allows it to take advantage of nodemon to restart the server for every change, to start the server in development mode, simply run:
yarn dev
Or if you choose to use npm, run:
npm run dev
To test the application, the environment is changed in such a way that the DB becomes SQLite instead of PostgreSQL to not affect the possible production database.
All the migrations are executed before the tests and undone after the tests (see pretest
and posttest
scripts respectively in the package.json
file for more info)
Also, the database is truncated before every test in order to avoid any bias on tests
yarn test
Or if you choose to use npm, run:
npm run test
- Change the implementation to Typescript
- Create a deployment guide
🚀@rocketseat-content for sharing the content that allowed me to practice and learn about TDD, check out the video (in portuguese) or the repo