docker-compose.yml
file is used to bundle the environment.- Run the project by running the following commands.
docker-compose up -d
- The server app will run at 'localhost:3000'.
- The Mongo server will be up on 27017 port.
- Navigate to the app by visiting http://localhost:3000/api/v1/ in your browser.
- There you'll see the Hi message.
- Now start playing with the app as you wish.
- Please make sure you've mongodb installed locally and is listening on port 27017
- Please make sure you've node installed
- run
npm install
. This will install all the dependencies - run
npm run build && npm run start:prod
. This will create a dist folder and run the server on port 3000. - Navigate to the app by visiting http://localhost:3000/api/v1/ in your browser.
- There you'll see the Hi message.
- Now start playing with the app as you wish.
-
The Authentication is built on JWT, Passport.
-
JWT is the modern standard of the modern web, it also helps to bundle user information and pass it between client and server.
-
The server is based on NestJS, and the implementation of JWT is to build on top of Passport. Passport also gives many strategy for authentication.
-
The APIs are supporting Versioning. So we can release new versions after adding new features.
-
You'll find all the api's in the Postman Collection
-
/api/v1/auth/login
request isPOST
. Pass the body as{ "credentials": { "username": "admin", // username can be anything. "password": "password", // password can be anything. "role": "admin" // role other then admin will consider as the non-admin and will not be able to make CRUD operation on Post Resource. } }
-
/api/v1/posts/
request isGET
. Get request to fetch all the posts. -
/api/v1/posts/
request isPOST
. Post request to create a new Post. Pass the content in the body of the request as{ "content": "this is a first post" }
-
/api/v1/posts/:id
request isPUT
. PUT call to update the existing post.:id
parameter is the _id UUID of the post. -
/api/v1/posts/:id
request isDELETE
. DELETE call to delete the existing post.:id
parameter is the _id UUID of the post.
- The Post schema is simple and have
createdBy
andcontent
field. - The Database name is
workflow
, and the collection isPosts
- Here again, I'm leveraging the NestJS framework. The mongoose ODM provides the wrapper functions hence I don't need to run the script to create a new collection or new DB itself.