Skip to content

Latest commit

 

History

History
328 lines (239 loc) · 6.22 KB

File metadata and controls

328 lines (239 loc) · 6.22 KB

Description

Simple todo list application built with Nest framework, With fully CRUD operation features, Auth and logging system feature implemented as well!


Get Started

# Installation:

$ yarn
OR
$ yarn install

Running the app

# 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 :)


Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

File Structure

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

How to use

Available APIs (end-points)

CRUD operations

Retrieving todos

All todos

  • Method: GET
  • End point: http://localhost:3000/api/todos
  • STATUS 200

Get todos with filters

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.


Get todos via its :ID

  • End point: http://localhost:3000/api/todos/${id}


Create new todo

  • 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

Edit existed todo' status

  • 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

Delete existed todo

  • Method DELETE

  • End point: http://localhost:3000/api/todos/${id}

  • Response: No response returns back

  • STATUS 200



Authorization & Authentication (Logging)

Signup or register as a new user

  • 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

Sign or login as a existed user

  • 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

How to behave with the app

So every future potential request should has accessToken in request header as a Bearer token.

Header authorization:

  "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFub3RoZXJAZ21haWwuY29tIiwibmFtZSI6ImFub3RoZXIgYW5vdGhlciIsImlhdCI6MTYyNjQ3OTc5OCwiZXhwIjoxNjI2NDgzMzk4fQ.b5qiHsXfI9klw6mLIv9GKOEEUe8zK6WABXbFS-NAC4E"

Support

Fell free to fork/star todonest !!

Stay in touch

@salihcodev

License

MIT licensed.