The frontend of this project can be found here (Angular)
- Users/Authors can create their profiles (token-based authentication)
- Users/Authors can edit their profile
- Users/Authors can create blogs. They can set the country of their blog (i.e. philipines, unites states, united kingdom etc)
- Users/Authors can create blogs. They can set the category of their blog (i.e. business, entertainment, general etc)
- Blogs of a particular country can be viewed
- Blogs of a particular category can be viewed
Runtime environment
- Node.js
- Express.js
Database
- MongoDB
Image storage service
- Cloudinary
Testing framework
- Jest
Containerization tool
- Docker
- Navigate & open CLI into the directory where you want to put this project & Clone this project using this command.
git clone https://github.com/chesspamungkas/nalanews-backend
- Download repository
- Extract the zip file, navigate into it & copy the folder to your desired directory
- There is a file named
.env.example
on the root directory of the project - Create a new file by copying & pasting the file on the root directory & rename it to just
.env
- The
.env
file is already ignored, so your credentials inside it won't be committed - Change the values of the file. Make changes of comment to the
.env.example
file while adding new constants to the.env
file.
-
To build docker image
docker compose build --no-cache
-
To run the containers in detached mode (wait for a while for database connection)
docker compose up -d
-
To view running containers
docker container ps
-
To view API logs
docker logs nalanews-api
-
To run tests, first enter within the API container
- on windows CMD (not switching to bash)
docker exec -it nalanews-api /bin/sh
- on windows CMD (after switching to bash)
or
docker exec -it nalanews-api //bin//sh
winpty docker exec -it nalanews-api //bin//sh
- now run test command
npm test
- on windows CMD (not switching to bash)
-
To exit from API container, press Ctrl+D on terminal
-
To stop the containers
bash docker compose down
- Authentication required
- Authentication not required
- Register:
POST localhost:3000/user/register
- Login:
GET localhost:3000/user/login
- Edit user profile:
PUT localhost:3000/user/editProfile
- Refresh token:
POST localhost:3000/user/me/refreshToken
- Get loggedin user's info:
GET localhost:3000/user/myProfile
- Get author's info:
GET localhost:3000/user/authorProfile/:authorId
- Logout:
GET localhost:3000/user/logout
- Create a new country:
POST localhost:3000/country
- Edit a country:
POST localhost:3000/country/editCountry
- Delete a country:
DELETE localhost:3000/country/:countryId
- Get list of all countries:
GET localhost:3000/country
- Get list of all countries blog counts of user:
GET localhost:3000/category/countriesBlogs/:authorId
- Create a new category:
POST localhost:3000/category
- Edit a category:
POST localhost:3000/category/editCategory
- Get list of all categories:
GET localhost:3000/category
- Get list of all categorized blog counts of user:
GET localhost:3000/category/categorizedBlogs/:authorId
- Create a new blog:
POST localhost:3000/blog
- Edit a blog:
POST localhost:3000/blog/editBlog
- Delete a blog:
DELETE localhost:3000/blog/:blogId
- Get details of a blog:
GET localhost:3000/blog/:blogId
- Get list of all blogs with pagination of certain country:
GET localhost:3000/blog/:countryId?
- Get list of all blogs with pagination of certain category:
GET localhost:3000/blog/:categoryId?
- Get list of all blogs with pagination of certain country of a user/author:
GET localhost:3000/blog/:authorId?/:countryId?
- Get list of all blogs with pagination of certain category of a user/author:
GET localhost:3000/blog/:authorId?/:categoryId?