A Blog backend built using express server in NodeJS and mongoDB atlas is used to store the data and hosted on Heroku.
- get a list of all the blogs
- create a blog
- upload images to cloudinary or to local storage
- store data to mongoDB using atlas
- get blogs using Blog Id
- delete blog using blog Id
- update blog using Blog Id
- used cloud storage cloudinary to upload and store the file
- used multer to accept multipart data
- dataURI to convert the buffer into readable stream support by clodinary
- authentication is done by the auth server and communication is done using axios api calls
- hosted on heroku platform
- clone the repository
git clone https://github.com/ialtafshaikh/blog-backend.git
- add a
.env
file inside the root folder
DEBUG=false //set false to use atlas and true to use local mongodb
PORT=3000
STORAGE_TYPE=cloud // upload to cloudinary or set local to upload images to local server
LOCAL_DB_URL=mongodb://127.0.0.1:27017/localblogapp
DATABASE_URL=atlas url
STORAGE=local storage path
CLOUDINARY_CLOUD_NAME=your cloudinary cloud name
CLOUDINARY_API_KEY=your cloudinary api key
CLOUDINARY_API_SECRET=your cloudinary api secret
/blogs : (method:get) - to get all blogs
/blogs : (method:post) - to post blog
/blogs?auther=value&select=title - query this endpoint to get all the blogs based on query and select filter
/blogs/id : (method:get) - to get a single blog using blogID
/blogs/id : (method:put) - to update post ``titile`` and ``content`` of a single blog using blogID
/blogs/id : (method:delete) - to delete blog using blogID
/signup : (method:post) - create user accout
/login : (method:post) - get jwt token and authenticate yourself using the creds (email,password)
/auth : to restrict the user from accessing the resources on route /blogs so send token in authorization header as bearer token
To Host the Project I had used Heroku Platform. To learn more refer this gist
- mongoose quick start
- mongoDB documentation reference
- multer for file uploads
- uniquid to generate unique ids
- npm express
- multer and cloudinary blog
- dataUri package
- upload image to cloudinary in nodejs official doc
- axios to make api calls
- CORS module to talk between cross-origin resources
- Altaf Shaikh - work by - ialtafshaikh
This project is licensed under the MIT License - see the LICENSE.md file for details