https://github.com/radinansari/nodejs-blog-api
Blog REST API With NodeJS
https://github.com/radinansari/nodejs-blog-api
access access-token api architecture cookies express-js jwt mongodb moongose nodejs nodejs-api refresh-token restful
Last synced: 7 months ago
JSON representation
Blog REST API With NodeJS
- Host: GitHub
- URL: https://github.com/radinansari/nodejs-blog-api
- Owner: RadinAnsari
- Created: 2023-08-18T12:30:53.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-18T22:59:23.000Z (about 2 years ago)
- Last Synced: 2024-04-28T03:21:52.604Z (over 1 year ago)
- Topics: access, access-token, api, architecture, cookies, express-js, jwt, mongodb, moongose, nodejs, nodejs-api, refresh-token, restful
- Language: JavaScript
- Homepage:
- Size: 4.11 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nodejs-blog-api
The Blog REST API With Node.jsI built this repo for fun and to learn how to make a rest api and server
The different things you can do with this server:
- Controllers - deals with database read/write operations and logic.
- Models - define schemas of objects in collections the database.
- Routes - defines the API routing for controller functions.
- Middlewares - helper files, utils and methods. Basically anything that isn't done by a controller.
Installing & config
Start the server with nodemon: npm start
. Currently the default port for the server is 5000
and this can be set in the .env
. This is to prevent clashes when running the server and clients in dev locally.for database i use mongodb
and you can download and install it also you can download and install MongoDB Compass. Compass is a free interactive tool for querying, optimizing, and analyzing your MongoDB data. Get key insights, drag and drop to build pipelines, and more.
To killing the Port You can use :
sudo fuser -n tcp -k 5000
Dependencies
- bcryptjs: 2.4.3
- dotenv : ^16.3.1
- express: ^4.18.2
- express-validator: ^7.0.1
- jsonwebtoken: ^9.0.
- mongoose: ^7.4.2
- nodemon: 3.0.1
Note
Using .env file to store secret variables in software applications is a good common practice in software development. These variables can be database credentials, urls, ip addresses or hosts, secret keys for third party integrations etc.Since this file contains secret variables, we don't push it to git/github so remember to include .env file in your .gitignore file under your project root directory.
Implemented endpoints:
/User
Path
Method
Description
/api/v1/users/
GET
Get all users
/api/v1/users/login
POST
User Login
/api/v1/users/signup
POST
User Signup
/Post
Path
Method
Description
//api/v1/posts/
POST
Add New Post
/api/v1/posts/:pid
DELETE
Delete Post by Post Id
/Comments
Path
Method
Description
/api/v1/comments/getAllComments
Method
Description
/api/v1/comments/:pid
GET
Get All Comments
/api/v1/comments/:cid
DELETE
Delete Comments by Comment Id
!!! Project still in progress !!!