The HRG Feed Manager Service (hrg-feed-manager) manages onboarding HRG Feed users, their posts and comments into a Mongo backend. To clone this project...
$ git clone https://github.com/ram95krishh/hrg-feed-manager.git
- Scripts to onboard Users and inject Posts and Comments,
- APIs to retrieve User(s) and Post(s) with Comments & to update User Image,
- Protected with a simple JWT Authentication mechanism.
Both the scripts to onboard users and the service are present in the same project. Note: Before running the scripts, please have the server spun up using the following instructions
$ cd hrg-feed-manager
- Create a .env file and include the environmental variables
$ touch .env
- Install the dependencies and start the server.
$ npm install
$ npm start
Verify the server status by hitting this health-check endpoint. 127.0.0.1:7600/health
The scripts can be found in the /scripts folder of the project.
$ cd scripts
$ sh onboard_users.sh
- Inject posts and comments from https://jsonplaceholder.typicode.com/posts & https://jsonplaceholder.typicode.com/comments using...
$ sh inject_posts.sh
To get Auth Token to access all other endpoints
localhost:7600/users/login - POST
Payload:
{
"username": [username],
"password": [reverse-of-email]
}
Returns : Jwt Token as String
And to logout, use token obtained in login as Bearer token in Headers and call
localhost:7600/users/logout - GET
localhost:7600/users/logout-all - GET // to invalidate all tokens
*Note - For all preceding endpoint the token needs to be used as a Bearer Token in all the api call headers
localhost:7600/users/my-info - GET
localhost:7600/posts - GET
localhost:7600/users/get-all - GET
Returns:
200 - All Users for Admins,
401 - For unauthorized users & Viewers
localhost:7600/posts/get-all - GET
Returns:
200 - All Posts for Admins,
401 - For unauthorized users & Viewers
This project uses a number of open source projects/libraries, some of which are listed here:
- Express - fast node.js network app framework
- mongoose - a MongoDB object modeling tool designed to work in an asynchronous environment!
- bcrypt - to encrypt passwords before storing them
- joi - to validate environment and other variables
- JWTs - to generate & verify auth tokens (JWTs) after successful Authentication.
- Multer-S3 - Streaming multer storage engine for AWS S3.
- RamdaJs - A practical functional library for JavaScript programmers.
- Write Unit Tests
- Set up deployment and scripts
- Add Swagger endpoints returning swagger JSONs for API Reference
- Add Documentation for code using JSDoc