Service for storing and sharing notes.
- Node.js (>= 12.7.0)
- PostgreSQL (>= 12)
- PM2 (>= 4.4.0)
- Install dependencies:
npm install
- Build project:
npm run build
- Copy env file:
cp .env.example .env
- Change env variables in env file.
- Run migrations:
npm run migration:run
- Run project:
npm run start:prod
npm run build
- build project.
npm run start
- Start project.
npm run start:prod
- Start project in production mode (don't forget to specify that in .env)
npm run migration:run
- run migrations.
npm run migration:generate
- generate migration by entities.
-n
name of migration. For e.g.npm run migration:generate -- -n Initial
- Other arguments see on TypeORM website.
For all requests which need authorization, use that header:
Authorization: <API-TOKEN>
Replace <API-TOKEN>
with token received by requesting POST /api/auth
All routes has prefix /api
Route | Request | Response | Description |
---|---|---|---|
POST /user | CreateUserRequest | CreateUserRequest | Register user. |
Route | Request | Response | Description |
---|---|---|---|
POST /auth | GetTokenRequest | GetTokenResponse | Get token for authenticated requests. |
POST /auth/reset | none | none | Reset all tokens. Need authorization. |
Route | Request | Response | Description |
---|---|---|---|
GET /note | IndexNoteRequest | IndexNoteResponse | Get list of notes. Need authorization. |
GET /note/:id | GetNoteRequest | NoteResponse | Get note. |
GET /note/:id/preview | GetNoteRequest | Content of note. See here | Get preview of note. |
POST /note | CreateNoteRequest | NoteResponse | Create note. Need authorization. |
PATCH /note/:id | UpdateNoteRequest | NoteResponse | Update note. Need authorization. |
DELETE /note/:id | GetNoteRequest | none | Delete note. Need authorization. |
Accept-Type: application/json
URL parameters: none.
Query parameters: none.
Body:
Name | Type | Description |
---|---|---|
login | string | User's login. |
password | string | User's password. Min length: 6. |
Content-Type: application/json
Name | Type | Description |
---|---|---|
id | int | User's id. |
login | string | User's login. |
createdAt | date | User's registration date. |
Accept-Type: application/json
URL parameters: none.
Query parameters: none.
Body:
Name | Type | Description |
---|---|---|
login | string | User's login. |
password | string | User's password. |
Content-Type: application/json
Name | Type | Description |
---|---|---|
token | string | API token. |
expiresAt | date | Token expiration date. |
URL parameters: none.
Query parameters:
Name | Type | Description |
---|---|---|
page | int | Page number. |
limit | int | Count of items per page. |
Body: none.
Content-Type: application/json
Name | Type | Description |
---|---|---|
count | int | Count of all items . |
items | Note[] | Array of notes. See here |
URL parameters:
Name | Type | Description |
---|---|---|
id | int | Identifier of note. |
Query parameters: none.
Body: none.
Content-Type: application/json
Name | Type | Description |
---|---|---|
id | int | Identifier of note. |
content | string | Content of note. |
isShared | boolean | Note with shared access or not. |
createdAt | date | Date the note was created. |
updatedAt | date | Date the note was updated. |
Accept-Type: application/json
URL parameters: none.
Query parameters: none.
Body:
Name | Type | Description |
---|---|---|
content | string | Content of note. |
isShared | boolean | Note with shared access or not. |
Accept-Type: application/json
URL parameters: none.
Query parameters: none.
Body:
Name | Type | Description |
---|---|---|
content | string? | Content of note. |
isShared | boolean? | Note with shared access or not. |