Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4cf499a
chore: update .gitignore
Quiddlee Mar 11, 2024
f6fee49
chore: add prisma package
Quiddlee Mar 11, 2024
f0d3b2c
chore: add docker compose with postgresSQL
Quiddlee Mar 11, 2024
0601137
feat: add prisma
Quiddlee Mar 11, 2024
a6ba7b6
chore: add necessary packages
Quiddlee Mar 13, 2024
5dac476
chore: add postgresSQL environment variables
Quiddlee Mar 13, 2024
2cd0d45
chore: configure docker
Quiddlee Mar 13, 2024
5aacb89
chore: configure docker to run in watch mode
Quiddlee Mar 13, 2024
967bfb7
chore: reduce docker server's image size
Quiddlee Mar 13, 2024
eeae76a
chore: add npm script to run docker vulnerabilities scan
Quiddlee Mar 14, 2024
690c45c
chore: add editorconfig
Quiddlee Mar 14, 2024
b21e91b
chore: reduce docker image size
Quiddlee Mar 14, 2024
000bd10
chore: change nest clie to be dev dependency
Quiddlee Mar 14, 2024
0f6f3c2
chore: add prisma schema
Quiddlee Mar 15, 2024
dfb00f4
chore: add docker start script
Quiddlee Mar 15, 2024
59336b8
chore: remove old migrations
Quiddlee Mar 15, 2024
3974b7e
chore: update docker to perform prisma migrations
Quiddlee Mar 15, 2024
1939bb6
chore: update migrations
Quiddlee Mar 15, 2024
a1afd9a
feat: change user entity to work with prisma
Quiddlee Mar 15, 2024
dc80702
feat: change track entity to work with prisma
Quiddlee Mar 15, 2024
bb7b5d2
feat: change artist entity to work with prisma
Quiddlee Mar 15, 2024
0603a81
feat: change album entity to work with prisma
Quiddlee Mar 15, 2024
a129823
chore: update Dockerfile
Quiddlee Mar 17, 2024
70c1e59
fix: album service prisma queries
Quiddlee Mar 17, 2024
775d396
fix: artist service prisma queries
Quiddlee Mar 17, 2024
0940d9b
fix: favorite service prisma queries
Quiddlee Mar 17, 2024
157b56e
feat: add exclude user fields util
Quiddlee Mar 17, 2024
3e215ab
feat: add format user date util
Quiddlee Mar 17, 2024
672dfa8
chore: change npm script
Quiddlee Mar 17, 2024
8a0b136
refactor: update prisma schema
Quiddlee Mar 17, 2024
84efdc9
fix: track service prisma queries
Quiddlee Mar 17, 2024
372f323
fix: user service prisma queries
Quiddlee Mar 17, 2024
4bf6b31
chore: delete sql migrations
Quiddlee Mar 17, 2024
00c7f8a
refactor: remove user update method
Quiddlee Mar 17, 2024
883d478
refactor: remove in-memory db
Quiddlee Mar 18, 2024
b4ce900
refactor: change favorites to use prisma
Quiddlee Mar 18, 2024
4ce149d
refactor: make exclude util more generic
Quiddlee Mar 20, 2024
4f48e83
refactor: save favs table if in constant
Quiddlee Mar 20, 2024
ad58f18
fix: favorite entity prisma queries
Quiddlee Mar 20, 2024
a66431a
chore: update prisma dependencies
Quiddlee Mar 20, 2024
f3a3a54
chore: change prisma to "push" instead of "migrate"
Quiddlee Mar 21, 2024
25215de
chore: add logs volumes
Quiddlee Mar 21, 2024
8faf16d
chore: change docker to use prisma migrate
Quiddlee Mar 23, 2024
8385d93
docs: update readme
Quiddlee Mar 23, 2024
680fa48
chore: change to reset migrations
Quiddlee Mar 25, 2024
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
39 changes: 39 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
**/.classpath
**/.dockerignore
**/.git
**/.env.example
**/.gitignore
**/.project
**/.editorconfig
**/.eslintrc.js
**/.prettierrc
**/jest.config.json
**/nest-cli.json
**/tsconfig.build.json
**/environment.d.ts
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
**/doc
**/public
**/test
LICENSE
README.md
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ JWT_SECRET_KEY=secret123123
JWT_SECRET_REFRESH_KEY=secret123123
TOKEN_EXPIRE_TIME=1h
TOKEN_REFRESH_EXPIRE_TIME=24h

POSTGRES_USER=myuser
POSTGRES_PASSWORD=mypassword
POSTGRES_DB=home-library
POSTGRES_PORT=5432
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/${POSTGRES_DB}?schema=public"
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ lerna-debug.log*
!.vscode/launch.json
!.vscode/extensions.json

# .env
# compiled app
dist

.env

dev.db
dev.db-journal
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ARG NODE_VERSION=20

FROM node:${NODE_VERSION}-alpine as build-stage

WORKDIR /app

COPY package.json ./

RUN npm i --only=prod && npm i @nestjs/cli

COPY . .

RUN npx prisma generate

FROM node:${NODE_VERSION}-alpine as runtime-stage

WORKDIR /app

COPY --from=build-stage /app/src ./src
COPY --from=build-stage /app/types ./types
COPY --from=build-stage /app/.env ./
COPY --from=build-stage /app/tsconfig.json ./
COPY --from=build-stage /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=build-stage /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=build-stage /app/prisma ./prisma

COPY package.json ./

RUN npm i && npm i @nestjs/cli \
&& npm cache clean --force \
&& rm -rf \
./node_modules/.cache \
./node_modules/.npm \
./node_modules/.yarn \
./node_modules/.pnpm

EXPOSE ${PORT}

CMD [ "npm", "run", "start:migrate:dev" ]
58 changes: 40 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ To run the project locally, you would have to download zip file with the reposit
🤔 What things do you need to do in order to run our project locally?

* ⚡ Use node 20 LTS
* ✌️ Installed [.git](https://git-scm.com/) on your computer.
* ✌️ Installed [.git](https://git-scm.com/) on your computer.
* 📝 Code Editor of your choice.
* 🐳 Docker.

## 🔮 Installation And Preparation
## 🔮 Installation And Preparation

First make sure you have all the things listed in the previous section. Then clone our repository to your computer: 👌

Expand Down Expand Up @@ -41,11 +42,17 @@ JWT_SECRET_KEY=secret123123
JWT_SECRET_REFRESH_KEY=secret123123
TOKEN_EXPIRE_TIME=1h
TOKEN_REFRESH_EXPIRE_TIME=24h

POSTGRES_USER=myuser
POSTGRES_PASSWORD=mypassword
POSTGRES_DB=home-library
POSTGRES_PORT=5432
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/${POSTGRES_DB}?schema=public"
```

🤩 Finally run a development server:
```
npm run start:dev
docker compose up
```
Aaaaand you're done! 🎉🥳

Expand Down Expand Up @@ -100,7 +107,7 @@ Type check the App with `TypeScript`:
npm run type-check
```

## 🧪 Testing
## 🧪 Testing

After application running open new terminal and enter:

Expand Down Expand Up @@ -128,32 +135,47 @@ To run only specific test suite with authorization
npm run test:auth -- <path to suite>
```

## 🐳 Docker
Run application
```
docker compose up
```
Run application in watch mode
```
docker compose watch
```
Scan docker images for vulnerabilities
```
npm run docker:scan
```

# ⚙️ Technology Stack

## 🦈 Developing
* 🦅 **Nest.js** - The Backend Framework
* 🦅 **Nest.js** - The Backend Framework
* 💖 **TypeScript** - The Language
* 🦄 **Prisma** - The ORM
* 🔒 **bcrypt** - The Password Hasher
* 🎫 **jsonwebtoken** - The JWT Token Generator
* 📖 **Nest.js/Swagger** - The OpenAPI Documentation
* 🦄 **Prisma** - The ORM
* 🔒 **bcrypt** - The Password Hasher
* 🎫 **jsonwebtoken** - The JWT Token Generator
* 📖 **Nest.js/Swagger** - The OpenAPI Documentation
* 🐳 **Docker** - The Containerization tool

## 🧹 Code Quality
* 🧪 **Jest** - The Test Runner
* 🫂 **Supertest** - The Testing Framework
* 🔔 **ESLint** — Air-bnb base - The Linter
* 👏 **Prettier** - The Code Formatter
* 😎 **EditorConfig** - The Code Style Enforcer
* 🧪 **Jest** - The Test Runner
* 🫂 **Supertest** - The Testing Framework
* 🔔 **ESLint** — Air-bnb base - The Linter
* 👏 **Prettier** - The Code Formatter
* 😎 **EditorConfig** - The Code Style Enforcer

## 📚 External Libraries
* ✌️ **dotenv** - The Environment Variables Library
* 🌐 **cross-env** - The Environment Variables Loader
## 📚 External Libraries
* ✌️ **dotenv** - The Environment Variables Library
* 🌐 **cross-env** - The Environment Variables Loader


# 📍 Working with the API
🙏 Following the link below, you can find ```Postman``` collection that will make your life easier while working with the API! [postman collection](https://www.postman.com/bold-spaceship-739379/workspace/node-js-service/overview)

![img.png](./public/img.png)
![img.png](public/img.png)

## 🌊 API endpoints
The API has the following endpoints:
Expand Down
58 changes: 0 additions & 58 deletions db/albumDB.ts

This file was deleted.

49 changes: 0 additions & 49 deletions db/artistDB.ts

This file was deleted.

17 changes: 0 additions & 17 deletions db/db.ts

This file was deleted.

37 changes: 0 additions & 37 deletions db/favorite/favoriteAlbumDB.ts

This file was deleted.

Loading