The Blog Project is a backend system for a blogging platform with Admin and User roles. Admins manage users and blogs, while Users can perform CRUD operations on their own blogs. Features include secure authentication, role-based access control, and a public API with search, sort, and filter functionalities. Built with TypeScript, Node.js, Express.js, and MongoDB, the project ensures security and efficiency.
https://techblog-server.vercel.app/
https://techblog-server.vercel.app/
- TypeScript: Strong typing and enhanced developer experience.
- Node.js: Runtime environment for JavaScript-based backend.
- Express.js: Framework for building RESTful APIs.
- MongoDB & Mongoose: NoSQL database with an ORM for schema validation and CRUD operations.
To run this project, you will need to add the following environment variables to your .env file
DATABASE_URL= <Your database URL>
PORT= <Port number>
NODE_ENV = development
BCRYPT_SALT_ROUNDS=
JWT_ACCESS_TOKEN=
REFRESH_TOKEN=
JWT_ACCESS_EXPIRES =
REFRESH_ACCESS_EXPIRES =
email: admin@gmail.com
password: admin1234
Install my-project with npm
- Node
- Git
- npm
node --version
git --versionClone the project
git clone https://github.com/rana-arju/techBlog.gitGo to the project directory
cd techBlogInstall dependencies
npm installStart the server
npm run dev POST /api/auth/registerRequest Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "securepassword"
}
POST /api/auth/login/api/blogs?search=technology&sortBy=createdAt&sortOrder=desc&filter=60b8f42f9c2a3c9b7cbd4f18
GET /api/blogs POST /api/blogsRequest Body:
{
"title": "My First Blog",
"content": "This is the content of my blog."
}
DELETE /api/blogs/:id PATCH /api/blogs/:idRequest Body:
{
"title": "Updated Blog Title",
"content": "Updated content."
}
PATCH /api/admin/users/:userId/block DELETE /api/admin/blogs/:idβββ README.md
βββ tsconfig.json
βββ .env
βββ package-lock.json
βββ package.json
βββ src
β βββ App.ts
β βββ server.ts
β βββ app
β βββ config
β β βββ index.ts
| βββ builder
β β βββ QueryBuilder.ts
| βββ errors
β β βββ error all files
| βββ middleware
β β βββ auth, globalErrorHandler,notFound and validationRequest file
β βββ modules
β βββ Admin
| | βββ admin.controller.ts
| | βββ admin.service.ts
| | βββ admin.route.ts
β βββ Auth
| βββ auth.controller.ts
| βββ auth.schema.ts
| βββ auth.interface.ts
| βββ auth.service.ts
| βββ auth.utils.ts
| βββ auth.validation.ts
| βββ auth.route.ts
β βββ Blog
| βββ blog.controller.ts
| βββ blog.schema.ts
| βββ blog.interface.ts
| βββ blog.service.ts
| βββ blog.validation.ts
| βββ blog.route.ts
β βββ routes
β βββ index.ts
β βββ utils
β βββ catchAsync.ts and sendResponse.ts
β
βββ vercel.json
βββ eslint.config.mjs
βββ .gitignore
βββ .prettierigmore
βββ .prettierrc
| Used Package List |
|---|
| express js |
| mongoose |
| typescript |
| JWT |
| jsonWebToken |
| bcrypt |
| Zod |
| cors |
| dotenv |
| prettier |
| eslint__js |
