Ensure that you have actual versions of tools.
My ones are listed below:
$ node --version
v20.11.1
$docker --version
Docker version 26.0.0, build 2ae903e
$ uname -a
Linux 5.13.0-40-generic #45~20.04.1-Ubuntu
- Clone this repository:
git clone https://github.com/user-of-github/nodejs2024Q1-service.git .
- Switch to actual branch (for task 3 it is
dev-3
, see actual branch in PR. Or after course completion it should be justmaster
):
git checkout dev-3
// or other actual branch with most recent changes - Ensure that ports are free (:5432, :4000) (see them in
.env
)- Note: On Linux you can use command
sudo lsof -i:5432
andsudo lsof -i:4000
to check, if ports are free
- Note: On Linux you can use command
- Run
npm install
- Ensure that there is
app_logs/logs.log
file andapp_logs/errors.log
file (towards project root) (check relevant paths of lof-files in.env
file). While running program you will be able to see online content of log-files, even if app is in docker, because directory is mounted - Uncomment whole
docker-compose
, in.env
make sure, thatDATABASE_URL
for DOCKER is used (see comments inenv
).
Rundocker compose up
orsudo docker compose up
- Run your postgres instance locally from params in
.env
or you just can:- Comment
app
service indocker-compose
(so only DB will be run in container) - in
.env
make sure, thatDATABASE_URL
for LOCAL is used (see comments inenv
)
- Comment
- Run
npm run start
ornpm run start:dev
. - Before running, you can check, that 4000 and 5432 ports are free by using command (in Linux):
sudo lsof -i:5432
,sudo lsof -i:4000
. And kill processes if they occupy these ports (sudo kill <PROCESS_ID>
)
- // in separate terminal :)
- If you haven't done before,
npm install
- For now (3rd part of this project-task,
dev-3
)AuthModule
is already implemented, so usual tests will fail. You need to run tests:npm run test:auth
npm run test:refresh
- DOCKER CONTAINER WITH APP SHOULD BE ALREADY RUNNING :)
- After testing and using, don't forget to run
sudo docker compose down
(even if you already pressedctrl+c
orctrl+z
in terminal)
Error response from daemon: driver failed programming external connectivity on endpoint db ... Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use
,
then ensure that port is free. You need to stop all running containers, free up port.
You can check, which process uses this port by using: sudo lsof -i:5432
. With sudo !! Because without it on my personal machine command showed nothing. And then kill this process
https://hub.docker.com/repository/docker/684684684/rs-nodejs-2024q1-service
- Every entity is processed within its module
- Database has a separate module
- Types
- Linting
- Launch data stored in
.env
- Auth via
passport.js
andJWT
-tokens (for now entities are not binded to users, as it was not in task statement and there are no tests for it; But actually it is not a problem now to make reference of favourites to user) - Custom logging to file and logs-rotation; Logger Module; Middleware
-
Users
(/user
route)GET /user
- get all usersGET /user/:id
- get single user by idPOST /user
- create user (following DTO should be used)PUT /user/:id
- update user's passwordDELETE /user/:id
- delete user
-
Tracks
(/track
route)GET /track
- get all tracksGET /track/:id
- get single track by idPOST /track
- create new trackPUT /track/:id
- update track infoDELETE /track/:id
- delete track
-
Artists
(/artist
route)GET /artist
- get all artistsGET /artist/:id
- get single artist by idPOST /artist
- create new artistPUT /artist/:id
- update artist infoDELETE /artist/:id
- delete album
-
Albums
(/album
route)GET /album
- get all albumsGET /album/:id
- get single album by idPOST /album
- create new albumPUT /album/:id
- update album infoDELETE /album/:id
- delete album
-
Favorites
GET /favs
- get all favoritesPOST /favs/track/:id
- add track to the favoritesDELETE /favs/track/:id
- delete track from favoritesPOST /favs/album/:id
- add album to the favoritesDELETE /favs/album/:id
- delete album from favoritesPOST /favs/artist/:id
- add artist to the favoritesDELETE /favs/artist/:id
- delete artist from favorites
-
Auth
POST /auth/signup
- register with body{login, password}
POST /auth/login
- login with body{login, password}
POST /auth/refresh
- refresh tokens with body{refreshToken}