Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
380a3a9
feat: add modules and dtos
YuliaDemir May 29, 2025
a0b0401
feat: add update dtos
YuliaDemir May 29, 2025
a71f3ad
feat: add user endpoints
YuliaDemir May 31, 2025
b52afe3
refactor: delete unnecessary files
YuliaDemir May 31, 2025
1d89cdf
feat: implement track endpoint
YuliaDemir May 31, 2025
3ecccc3
fix: user put
YuliaDemir May 31, 2025
48e3ec6
feat: implement artist endpoint
YuliaDemir May 31, 2025
1a0526e
feat: implement album endpoint
YuliaDemir May 31, 2025
db568a4
fix: lint errors
YuliaDemir May 31, 2025
22954c0
feat: implement favorites endpoints
YuliaDemir Jun 1, 2025
fa0d498
fix: lint errors
YuliaDemir Jun 1, 2025
833c713
docs: api
YuliaDemir Jun 1, 2025
bb391c2
docs: add information to README
YuliaDemir Jun 1, 2025
58e1231
docs: add dockers files
YuliaDemir Jun 6, 2025
48c8fa5
feat: user module for ql
YuliaDemir Jun 8, 2025
2ce2b16
feat: track module for ql
YuliaDemir Jun 8, 2025
6f3fa24
feat: artist module for ql
YuliaDemir Jun 8, 2025
851d5c2
feat: album module for ql
YuliaDemir Jun 8, 2025
328086c
feat: favorite module
YuliaDemir Jun 8, 2025
7a0eb0e
fix: lint problems
YuliaDemir Jun 8, 2025
fda5f17
fix: a few problems
YuliaDemir Jun 9, 2025
bb8a4ee
fix: lint problems
YuliaDemir Jun 9, 2025
60488fb
feat: volume and container size
YuliaDemir Jun 9, 2025
f57eafa
feat: reduce container weight
YuliaDemir Jun 9, 2025
d624a03
fix: remove hardcode variables
YuliaDemir Jun 9, 2025
d9f6fe1
fix: lint improvement
YuliaDemir Jun 9, 2025
3626a0b
docs: add instructions to readme
YuliaDemir Jun 9, 2025
edd4ce9
feat: add error handler
YuliaDemir Jun 13, 2025
94e988d
feat: add authorisation
YuliaDemir Jun 13, 2025
ee216e4
fix: authorisation
YuliaDemir Jun 14, 2025
cfd489e
feat: add hash for password
YuliaDemir Jun 14, 2025
12739dc
fix: log write to the file
YuliaDemir Jun 14, 2025
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
npm-debug.log
Dockerfile*
docker-compose.yml
.git
.gitignore
18 changes: 18 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
PORT=4000

CRYPT_SALT=10
JWT_ACCESS_SECRET=123123
JWT_REFRESH_SECRET=123123
LOG_LEVEL=debug
TOKEN_EXPIRE_TIME=1h
TOKEN_REFRESH_EXPIRE_TIME=24h

DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=user123
DB_PASSWORD=111222
DB_NAME=appdb

POSTGRES_USER=user123
POSTGRES_PASSWORD=111222
POSTGRES_DB=appdb
10 changes: 8 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
PORT=4000

CRYPT_SALT=10
JWT_SECRET_KEY=secret123123
JWT_SECRET_REFRESH_KEY=secret123123
JWT_SECRET_KEY=123123
JWT_SECRET_REFRESH_KEY=123123
TOKEN_EXPIRE_TIME=1h
TOKEN_REFRESH_EXPIRE_TIME=24h

DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=user123
DB_PASSWORD=111222
DB_NAME=musicdb
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#stage1
FROM node:20-alpine AS builder

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

#stage2
FROM node:20-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install --production

COPY --from=builder /app/dist ./dist
COPY --from=builder /app/.env ./


EXPOSE 3000

CMD ["node", "dist/main.js"]
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,32 @@
- 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.

## Downloading
## INSTALATION

### 1. Downloading

```
git clone {repository URL}
git clone https://github.com/YuliaDemir/nodejs2025Q2-service.git
cd nodejs2025Q2-service
```

## Installing NPM modules
### 2. Moving to the development branch

```
npm install
git checkout dev2
```

## Running application
## RUNNING application

### 1. Launch your docker app

### 2. Assemble and launch the containers

```
npm start
docker-compose up --build
```

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/.

## Testing

Expand Down
90 changes: 9 additions & 81 deletions doc/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ info:
version: 1.0.0

servers:
- url: /api
- url: /4000

components:
schemas:
Expand Down Expand Up @@ -117,79 +117,7 @@ security:
- bearerAuth: []

paths:
/login:
post:
tags:
- Login
security: []
summary: Login
description: Logins a user and returns a JWT-token
requestBody:
required: true
content:
application/json:
schema:
type: object
title: example
properties:
login:
type: string
description: Username
password:
type: string
description: Password
required:
- user
- login
responses:
200:
description: Successful login.
content:
application/json:
schema:
type: object
properties:
token:
type: string
description: JWT Token
403:
description: Incorrect login or password
/signup:
post:
tags:
- Signup
security: [ ]
summary: Signup
description: Signup a user
requestBody:
required: true
content:
application/json:
schema:
type: object
title: example
properties:
login:
type: string
minLength: 3
maxLength: 255
description: Username
password:
type: string
format: password
pattern: ^[a-zA-Z0-9]{3,30}
description: Password
required:
- login
- password
responses:
204:
description: Successful signup
400:
description: Bad request
409:
description: Conflict. Login already exists
/users:
/user:
get:
tags:
- Users
Expand Down Expand Up @@ -239,7 +167,7 @@ paths:
description: Bad request. body does not contain required fields
401:
$ref: '#/components/responses/UnauthorizedError'
/users/{userId}:
/user/{userId}:
parameters:
- name: userId
in: path
Expand Down Expand Up @@ -334,7 +262,7 @@ paths:
$ref: '#/components/responses/UnauthorizedError'
404:
description: User not found
/tracks:
/track:
get:
tags:
- Track
Expand Down Expand Up @@ -388,7 +316,7 @@ paths:
description: Bad request. body does not contain required fields
401:
$ref: '#/components/responses/UnauthorizedError'
/tracks/{id}:
/track/{id}:
parameters:
- name: id
in: path
Expand Down Expand Up @@ -492,7 +420,7 @@ paths:
$ref: '#/components/responses/UnauthorizedError'
404:
description: Track was not found.
/albums:
/album:
get:
tags:
- Album
Expand Down Expand Up @@ -544,7 +472,7 @@ paths:
description: Bad request. body does not contain required fields
401:
$ref: '#/components/responses/UnauthorizedError'
/albums/{id}:
/album/{id}:
parameters:
- name: id
in: path
Expand Down Expand Up @@ -621,7 +549,7 @@ paths:
$ref: '#/components/responses/UnauthorizedError'
404:
description: Album was not found.
/artists:
/artist:
get:
tags:
- Artist
Expand Down Expand Up @@ -668,7 +596,7 @@ paths:
description: Bad request. body does not contain required fields
401:
$ref: '#/components/responses/UnauthorizedError'
/artists/{id}:
/artist/{id}:
parameters:
- name: id
in: path
Expand Down
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3.9'

networks:
app-network:
driver: bridge

services:
db:
build: ./postgres
container_name: postgres-db
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "${DB_PORT}:${DB_PORT}"
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- app-network

app:
build: .
restart: always
volumes:
- ./src:/app/src
- /app/node_modules
container_name: node-app
environment:
DB_HOST: db
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
DB_NAME: ${DB_NAME}
PORT: ${PORT}
ports:
- "${PORT}:${PORT}"
networks:
- app-network
volumes:
pgdata:
Loading