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:5432andsudo lsof -i:4000to check, if ports are free
- Note: On Linux you can use command
- Run
npm install - Ensure that there is
app_logs/logs.logfile andapp_logs/errors.logfile (towards project root) (check relevant paths of lof-files in.envfile). 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.envmake sure, thatDATABASE_URLfor DOCKER is used (see comments inenv).
Rundocker compose uporsudo docker compose up
- Run your postgres instance locally from params in
.envor you just can:- Comment
appservice indocker-compose(so only DB will be run in container) - in
.envmake sure, thatDATABASE_URLfor LOCAL is used (see comments inenv)
- Comment
- Run
npm run startornpm 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)AuthModuleis already implemented, so usual tests will fail. You need to run tests:npm run test:authnpm 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+corctrl+zin 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.jsandJWT-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(/userroute)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(/trackroute)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(/artistroute)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(/albumroute)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
-
FavoritesGET /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
-
AuthPOST /auth/signup- register with body{login, password}POST /auth/login- login with body{login, password}POST /auth/refresh- refresh tokens with body{refreshToken}



