This is a simple TODO list API built with Fastify. It allows basic CRUD operations on a TODO List and Tasks + subscribe User to other's List.
Rewriten TODO list Api v1.0 with new features
:
- Fastify instead of Express
- Encapsulated functionality with fastify-plugins
- Less code
- More readable and modular code
And keeping the old features
:
- TODO List API
- RESTfull API
- JWT authentication
- CRUD operations
- Prisma ORM
- PostgreSQL
- Swagger documentation
- TypeScript
Table of Contents
/*
[src]
├──[plugins] - incapsulated functionality of app and optinos
├──[routes]
│ ├──[auth]
│ │ │── │handler.ts│ - handlers for login and register
│ │ │── │index.ts│ - register routes with options
│ │ │── │options.ts│ - put together handlers and schema
│ │ └── │chema.ts│ - validation and serialization
│ ├──[list]
│ │ │── │handler.ts│ - CRUD + /subscribe handlers
│ │ │── │index.ts│ - register routes with options
│ │ │── │options.ts│ - put together handlers and schema
│ │ └── │chema.ts│ - validation and serialization
│ └──[task]
│ │── │handler.ts│ - CRUD handlers
│ │── │index.ts│ - register routes with options
│ │── │options.ts│ - put together handlers and schema
│ └── │chema.ts│ - validation and serialization
│
│──│server.ts│ - set options, register plugins, routes
└──│app.ts│ - import and start server
--------------------------------------------------------
[test]
└──│index.ts│ - start all tests
*/
- Download repo
git clone https://github.com/Mykhailo-Sichkaruk/TODO-list-api
- Change directory to downloaded repo
cd TODO-list-api
- Install dependencies:
npm install
- Setup Postgres
- Open
.env
file in project root - Set your password and login for postgress in
DATABASE_URL
topostgres://_YOUR_POSTRGES_LOGIN_:_YOUR_POSTGRES_PASSWORD_@localhost:5432/mydb?schema=public
(Without '_' symbols) - It shold be like this:
DATABASE_URL="postgres://postgres:todo@localhost:5432/mydb?schema=public"
- Open
- Run server:
npm start
- Follow instrunction in terminal
- Click Register
- Click Try it out
- Clisk Execute
- Copy token fron response`s header or body
- Scroll up and click Autorize
- Paste token and clisck Autorize
Great You added token to header!
Read detailed about API in Swagger/Open API docs
- Sign up with login and password (POST /auth/register)
- Sign in with login and password (POST /auth/login)
- List has
- title (string)
- subscribers (array Users)
- author (string)
- tasks (array of strings)
- Create list (POST /list)
- Get list (GET /list/)
- Get all lists (GET /list)
- Update list (PUT /list)
- Delete list (DELETE /list)
- Task has
- id
- title
- body
- status (
ACTIVE
orIN_PROGRES
orDONE
orCLOSED
) - listId
- deadline
- authorId
- Create task (POST /task)
- Get task (GET /task/)
- Get all tasks (GET /task)
- Update task (PUT /task)
- Delete task (DELETE /task)
- Subscribe user to list (POST /list/subscribe)
- Database:
Postgres
- ORM:
Prisma
- Language:
TypeScript
- Execution environment:
Node.js
- Framework:
Fastify
- Documentation:
Swagger/Open API