Docs Configuration Installation Running the app Types
- in the root folder create a
.envfile and add the followind variables:
.env
DB_NAME=... #your postgres database name
DB_PASSWORD=... #your postgres password
DB_USERNAME=... #your postgres username
DB_PORT=... #your postgres port
DB_HOST=localhost #this is default value, you can change it if you run don't run app on localhost
CORS_ORIGIN=... #your frontend URL/URLS
MAIL_HOST=... #your mail smtp host
MAIL_PORT=465 #your mail smtp port
MAIL_USER=... #your mail (example: [email protected])
MAIL_PASSWORD=... #your mail password
MAIL_SECURE=true
JWT_SECRET=... #your jwt secret key
JWT_ACCESS_EXPIRES-IN=... #time whem access token expires in (default: 900s)
JWT_REFRESH_EXPIRES-IN=... #time when refresh token expires in (default: 7d)- to run the app you need to install all dependencies:
bash
yarn installbash
- to run app in
devmode:
yarn start:devbash
- to run app in
prodmode:
yarn start:prodbash
- to
buildthe app:
yarn build-
POST/auth/register- register a new user
- Request Body
name: stringemail: stringpassword: string
- Response
status: numbermessage: string
-
POST/auth/login- login a user
- Request Body
login: stringpassword: string
- Response
status: numbermessage: stringaccess_token: string
-
POST/user/change-avatar- changes user avatar
- Request Headers
Authorization:Bearerstring
- Request Body
avatar: string
- Response
status: numbermessage: string
-
PATCH/user/change-name- changes user name
- Request Headers
Authorization:Bearerstring
- Request Body
id: numbername: string
- Response
status: numbermessage: string
-
GET/user/get-tasks- get all user tasks
- Request Headers
Authorization:Bearerstring
- Response
status: numbermessage: stringtasks: Task[]
-
GET/user/get-avatar- get user avatar file by user id
- Query
id: number
- Response
status: numberavatar: Buffer
-
GET/user/get-user- get public user DTO by user id
- Query
id: number
- Response
status: numbermessage: stringuser: PublicUserDto
GET/user/get-user- get public user DTO by token
- Request Headers
Authorization:Bearerstring
- Response
status: numbermessage: stringuser: PublicUserDto
-
GET/user/get-avatar- get user avatar url by token
- Query
id: numbertime: Date
- Response
status: numbermessage: stringavatar: string
-
PATCH/user/change-password- changes user password
- Request Headers
Authorization:Bearerstring
- Query
id: number
- Request Body
password: stringconfirmPassword: string
- Response
status: numbermessage: stringtoken:Basicstring
-
PATCH/tasks/change-header- changes task header
- Request Headers
Authorization:Bearerstring
- Request Body
id: numberheader: string
- Response
status: numbermessage: string
-
DELETE/tasks/delete-task- delete task
- Request Headers
Authorization:Bearerstring
- Query
id: number // task id
- Response
status: numbermessage: string
-
GETtasks/get-tasks-by-substring- get tasks by substring
- Request Headers
Authorization:Bearerstring
- Query
substring: string
- Response
status: numbermessage: stringtasks: Task[]
GETtasks/get-tasks-by-type- get tasks by type
- Request Headers
Authorization:Bearerstring
- Query
type: TodoType
- Response
status: numbermessage: stringtasks: Task[]
GETtasks/get-today-tasks- get today tasks
- Request Headers
Authorization:Bearerstring
- Query
createdAt: string
- Response
status: numbermessage: stringtasks: Task[]
GETtasks/get-tasks-by-header- get tasks by header
- Request Headers
Authorization:Bearerstring
- Query
header: string
- Response
status: numbermessage: stringtasks: Task[]
GETtasks/get-tasks-by-month- get tasks by month
- Request Headers
Authorization:Bearerstring
- Query
month: string
- Response
status: numbermessage: stringtasks: Task[]
GETtasks/get-tasks-by-week- get tasks by week
- Request Headers
Authorization:Bearerstring
- Query
week: string
- Response
status: numbermessage: stringtasks: Task[]
GETtasks/get-tasks-length- get tasks length
- Request Headers
Authorization:Bearerstring
- Response
status: numbermessage: stringtasks: Record<TodoType, number>
interface Task {
header: string;
isChecked: boolean;
createdAt: string;
from: string;
till: string;
important: boolean;
creator: string; // user name
id: number;
type: TodoType;
tasks: Array<{ isChecked: boolean, content: string }>; // subtasks
}interface User {
name: string;
email: string;
password: string;
avatar: Buffer;
isHaveAvatar: boolean;
tasks: Task[];
}interface CreateTodoDto {
isChecked: boolean;
createdAt: string;
from: string;
header: string;
important: boolean;
tasks: Array<{ isChecked: boolean, content: string }>;
till: string;
type: TodoType;
}type TodoType =
| 'school'
| 'work'
| 'shop'
| 'read'
| 'work out';interface PublicUserDto {
isHaveAvatar: boolean;
name: string;
email: string;
avatar: string; // `${process.env.API_URL}/user/get-avatar?id=${user.id}&time=${new Date()}`
}