Simple todo list application built with Nest framework, With fully CRUD operation features, Auth and logging system feature implemented as well!
# Installation:
$ yarn
OR
$ yarn install
# Development mode:
$ npm run start
---
# Watch mode:
$ npm run start:dev
---
# Production mode:
$ npm run start:prod
NOTE You can view all scripts via run
# All Potential Scripts:
$ ntl
ntl is a npm pkg, you need to instal lit globally :)
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
root
├── config
│ ├── default.yml
│ ├── development.yml
│ └── production.yml
├── Dockerfile
├── nest-cli.json
├── package.json
├── -path
├── README.md
├── src
│ ├── common
│ │ ├── auth-strategies
│ │ │ └── jwt-auth.strategy.ts
│ │ ├── constants
│ │ │ └── psql
│ │ │ └── error-codes.constants.
│ │ ├── decorators
│ │ │ └── getUser.decorator.ts
│ │ ├── dtos
│ │ │ ├── todo
│ │ │ │ ├── create-todo.dto.ts
│ │ │ │ └── filter-todo.dto.ts
│ │ │ └── user
│ │ │ ├── user-signin.dto.ts
│ │ │ └── user-signup.dto.ts
│ │ ├── entities
│ │ │ ├── todo
│ │ │ │ └── todo.entity.ts
│ │ │ └── user
│ │ │ └── user.entity.ts
│ │ ├── enums
│ │ │ └── todo-status.enum.ts
│ │ ├── interfaces
│ │ │ └── auth
│ │ │ └── jwt-payload.interface.
│ │ └── pipes
│ │ └── todo
│ │ └── todo-status.pipe.ts
│ ├── configs
│ │ └── typeORM.config.ts
│ ├── controllers
│ │ ├── auth
│ │ │ └── auth.controller.ts
│ │ └── todo
│ │ └── todo.controller.ts
│ ├── main.ts
│ ├── modules
│ │ ├── app
│ │ │ └── app.module.ts
│ │ ├── auth
│ │ │ └── auth.module.ts
│ │ └── todo
│ │ └── todo.module.ts
│ ├── repositories
│ │ ├── todo
│ │ │ └── todo.repository.ts
│ │ └── user
│ │ └── user.repository.ts
│ └── services
│ ├── auth
│ │ └── auth.service.ts
│ └── todo
│ └── todo.service.ts
├── test
│ ├── app.e2e-spec.ts
│ └── jest-e2e.json
├── tsconfig.build.json
├── tsconfig.json
└── yarn.lock
- Method:
GET
- End point:
http://localhost:3000/api/todos
- STATUS
200
You can retrieve todos with `status, description, title` search criteria.
-
End point:
http://localhost:3000/api/todos?status=${status}&search=${word}
-
Allowed statuses:
[OPEN, IN_PROGRESS,CLOSED]
-
[Word] matches both title or description of todo.
- End point:
http://localhost:3000/api/todos/${id}
- Method
POST
- End point:
http://localhost:3000/api/todos
- Request body:
{
"title": "Your todo's title",
"description": "put some description here"
}
- Response:
{
"title": "Your todo's title",
"description": "put some description here",
"userId": 1,
"id": 1,
"status": "OPEN"
}
userId: logged user's id
status: default status
- STATUS
201
- Method
PATCH
- End point:
http://localhost:3000/api/todos/${id}
- Request body:
{
"status": "IN_PROGRESS"
}
- Response:
{
"title": "Your todo's title",
"description": "put some description here",
"userId": 1,
"id": 1,
"status": "IN_PROGRESS"
}
- STATUS
200
-
Method
DELETE
-
End point:
http://localhost:3000/api/todos/${id}
-
Response: No response returns back
-
STATUS
200
- Method
POST
- End point:
http://localhost:3000/api/signup
- Request body:
{
"firstName": "John",
"lastName": "Doe",
"email": "john00@gmail.com",
"password": "Aa0012345"
}
firstName: must be more than 3 chars
email: must be an e-mail
password: must be more than or equal 8 chars and has at least one uppercase char.
-
Response: No response returns back
-
STATUS
201
- Method
POST
- End point:
http://localhost:3000/api/signin
- Request body:
{
"email": "john00@gmail.com",
"password": "Aa0012345"
}
- Response:
Login process reduces an
accessToken
, User can use it later to credit his/her self.
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFub3RoZXJAZ21haWwuY29tIiwibmFtZSI6ImFub3RoZXIgYW5vdGhlciIsImlhdCI6MTYyNjQ3OTc5OCwiZXhwIjoxNjI2NDgzMzk4fQ.b5qiHsXfI9klw6mLIv9GKOEEUe8zK6WABXbFS-NAC4E"
}
- STATUS
200
So every future potential request should has accessToken in request header as a Bearer token.
Header authorization:
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFub3RoZXJAZ21haWwuY29tIiwibmFtZSI6ImFub3RoZXIgYW5vdGhlciIsImlhdCI6MTYyNjQ3OTc5OCwiZXhwIjoxNjI2NDgzMzk4fQ.b5qiHsXfI9klw6mLIv9GKOEEUe8zK6WABXbFS-NAC4E"
Fell free to fork/star todonest !!