Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3f0607d
refactor: added folder build to gitigmor and fix passwordHash in putM…
RamanMukhin Jun 29, 2021
08e575c
feat: added userControler and db
RamanMukhin Jun 30, 2021
8368e7a
feat: added boardsControler
RamanMukhin Jul 1, 2021
685f658
feat: added tasksControler
RamanMukhin Jul 1, 2021
c36f0b0
feat: fix endpoins
RamanMukhin Jul 1, 2021
22b65fd
refactor: fix db config
RamanMukhin Jul 1, 2021
23880d4
feat: added migrations
RamanMukhin Jul 2, 2021
b2aac61
feat: added admin to db
RamanMukhin Jul 2, 2021
9255b28
feat: added request validation
RamanMukhin Jul 2, 2021
b0e27ff
feat: finished request validation
RamanMukhin Jul 2, 2021
009d952
feat: fix request validation
RamanMukhin Jul 2, 2021
a181919
feat: added loginController
RamanMukhin Jul 3, 2021
132ddf5
feat: fix login
RamanMukhin Jul 3, 2021
55f92ba
feat: added jwtAuth
RamanMukhin Jul 4, 2021
195d2c2
feat: fix jwtAuth
RamanMukhin Jul 4, 2021
a823e02
feat: added tests
RamanMukhin Jul 4, 2021
2a12008
feat: added logging
RamanMukhin Jul 5, 2021
9ba1589
feat: added exceptionFilter
RamanMukhin Jul 5, 2021
7bd85ed
feat: fix exceptionFilter
RamanMukhin Jul 5, 2021
dc56908
feat: added docker and fix test dependencies
RamanMukhin Jul 5, 2021
8ed7a7a
feat: added fastify
RamanMukhin Jul 6, 2021
cccea21
feat: fix esLint
RamanMukhin Jul 6, 2021
9317f73
feat: added stressests
RamanMukhin Jul 8, 2021
d6c8482
feat: changed project root folder
RamanMukhin Jul 8, 2021
f838ad7
feat: added compare tables
RamanMukhin Jul 8, 2021
a5dbd0c
feat: fix readme
RamanMukhin Jul 8, 2021
6b32561
refactor: fix readme
RamanMukhin Jul 8, 2021
1bc1b4a
refactor: fix readme - checkout on branch
RamanMukhin Jul 8, 2021
f505cd6
refactor: fix url in logger
RamanMukhin Jul 9, 2021
8192c8e
refactor: fix exception meddleware
RamanMukhin Jul 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
docs
dist
9 changes: 7 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Set your application information here
NODE_ENV=development
PORT=4000
AUTH_MODE=false

# Set your JWT information here
JWT_SECRET_KEY=secret-key
EXPIRATION_TIME=3600

# Set your database connection information here
TYPE=postgres
POSTGRES_HOST=host.docker.internal
Expand All @@ -11,4 +14,6 @@ POSTGRES_DB=BASA
POSTGRES_PASSWORD=QWER
POSTGRES_PORT=5432
POSTGRES_TRY=5
MONGO_CONNECTION_STRING=your-mongo-db-connection-string

# Set true or false, if you want to use FASTIFY platform
USE_FASTIFY=false
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { off } = require("process");

module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
createDefaultProgram: false,
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
"plugin:import/typescript",
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['./.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
"@typescript-eslint/ban-types": 'off'
},
};
44 changes: 0 additions & 44 deletions .eslintrc.json

This file was deleted.

40 changes: 34 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
node_modules/
docs/
logs.txt
errorLogs.txt
uncaughtExceptionLogs.txt
unhandledRejectionLogs.txt
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
7 changes: 3 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
"singleQuote": true,
"trailingComma": "all"
}
120 changes: 97 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# RS School REST service

## Prerequisites

- Git - [Download & Install Git](https://git-scm.com/downloads).
- Node.js - [Download & Install Node.js](https://nodejs.org/en/download/) and the npm package manager.
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>

## Downloading

```
git clone {repository URL}
git clone https://github.com/RamanMukhin/Express-REST-service.git
```

## go to the Express-REST-service folder

```
cd ./Express-REST-service
```

## chekout on the branch task_9

```
git checkout task_9
```

## Installing NPM modules
Expand All @@ -19,21 +30,47 @@ npm install

## Running application

```
npm start
If you want to run the application locally, you must first have a postgress database running.
Next, you need to specify the parameters for connecting to the database in the .env file.
After completing these points, you can start launching the application.

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

After starting the app on port (4000 as default) you can open
in your browser OpenAPI documentation by typing http://localhost:4000/doc/.
For more information about OpenAPI/Swagger please visit https://swagger.io/.
However, it is better to immediately launch the application in Docker.
How to do it - read below.

## Running application in DOCKER
1. Run in terminal ##docker compose up## if you want to see logs in terminal, else run ##docker compose up -d##
1. If you want to see logs run in terminal, run
```
docker compose up
```
else run
```
docker compose up -d
```
2. Now it works!
3. To stop the application after comand ##docker compose up## enter in terminal ##Ctrl+c##
4. To stop the application after comand ##docker compose up -d## enter in terminal ##docer compose down##
3. To stop the application after comand **docker compose up** enter in terminal
```
Ctrl+C
```
4. To stop the application after comand **docker compose up -d** enter in terminal
```
docer compose down
```
5. Now it stops!
6. If you want to fix or add something in code - do it, and then run ##docker compose build##.
6. If you want to fix or add something in code - do it, and then run
```
docker compose build
```
7. If you want to run the application again - see the paragraph above (1).

## Testing
Expand Down Expand Up @@ -64,18 +101,55 @@ To run only specific test suite with authorization (users, boards or tasks)
npm run test:auth <suite name>
```

## Development
## Tables comparing performance of Nestjs express vs Nestjs fastify

If you're using VSCode, you can get a better developer experience from integration with [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extensions.
Full test results can be found in the corresponding files in the **stressTestResults** folder.
# Express
**Summary**

### Auto-fix and format
| | |
| :- | :- |
|Test duration |190 sec|
|Scenarios created |1366 |
|Scenarios completed |1366 |

```
npm run lint
```
**Scenario counts**

| | |
| :- | :- |
|Get all users |263 (19.253%)|
|Create a new user and then delete him |292 (21.376%)|
|Create a new user and then get him by id |291 (21.303%)|
|Create a new user |249 (18.228%)|
|Create a new user and then update him |271 (19.839%)|

**Overall Latency Distribution**

|Min |max |median |P95 |P99 |
| :- | :- | :- | :- | :- |
|4 msec |3144 msec |250 msec |1167 msec |1837 msec|

# Fastify
**Summary**

| | |
| :- | :- |
|Test duration |190 sec |
|Scenarios created |1355 |
|Scenarios completed |1355 |

**Scenario counts**

### Debugging in VSCode
| | |
| :- | :- |
|Get all users |275 (20.295%)|
|Create a new user and then delete him |273 (20.148%)|
|Create a new user and then get him by id |280 (20.664%)|
|Create a new user |268 (19.779%)|
|Create a new user and then update him |259 (19.114%)|

Press <kbd>F5</kbd> to debug.
**Overall Latency Distribution**

For more information, visit: https://code.visualstudio.com/docs/editor/debugging
|Min |max |median |P95 |P99 |
| :- | :- | :- | :- | :- |
|3 msec |1448 msec |122 msec |421 msec |695 msec |
38 changes: 0 additions & 38 deletions build/app.js

This file was deleted.

22 changes: 0 additions & 22 deletions build/auth/auth.router.js

This file was deleted.

3 changes: 0 additions & 3 deletions build/auth/auth.service.js

This file was deleted.

1 change: 0 additions & 1 deletion build/auth/payload.model.js

This file was deleted.

8 changes: 0 additions & 8 deletions build/auth/sendAuthStatus.js

This file was deleted.

Loading