a task management tool with NestJS
nestjs-tasker is an example Nest.js back-end API that can manage tasks.
This repository serves as a learning repository to chronicle my progress from the Udemy course: NestJS Zero to Hero by Ariel Weinberger.
Original code was written by Ariel Weinberger, minor modifications by me (Sophia Brandt).
Prerequisites:
- Node.js (>=10.13.0)
- Docker
- Docker Compose
You'll need Docker and docker-compose for the Postgres database. The database runs in a Docker container.
$ git clone [email protected]:sophiabrandt/nestjs-tasker.git && cd nestjs-tasker
$ docker-compose build
$ pnpm install # or `npm install`
If you want to use your locally installed Postgres instance, you have to configure the database in the config
folder.
- Start application
$ docker-compose up -d
$ pnpm run start:dev # or npm run start:dev
Basic Open API is available under http://localhost:3000/api
.
- Register user
Register a new user under http://localhost:3000/auth/signup
:
$ curl -d '{"username":"janedoe","password":"JaneDoe$333"}' -H "Content-Type: application/json" -X POST http://localhost:3000/auth/signup
- Sign in and retrieve auth token on the route
http://localhost:3000/auth/signin
:
$ TOKEN=$(curl -d '{"username":"janedoe","password":"JaneDoe$333"}' -H "Content-Type: application/json" -X POST http://localhost:3000/auth/signin | jq -r '.accessToken')
We use jq to parse the json response and set the auth token as a bash variable in the command line.
- Use the
tasks
route
Example:
$ curl -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://localhost:3000/tasks
Now you can do CRUD operations on http://localhost:3000/tasks
when you send the bearer token.
$ pnpm run test # or npm run test
Copyright © 2019 Ariel Weinberger, Sophia Brandt
Original repository