This is the backend for the Blog App. It is a Node.js application that uses the Prisma ORM to interact with the database.
- Clone the repository
git clone https://github.com/yourusername/blog-app-backend.git
cd blog-app-backend
- Install dependencies
npm install
- generate Prisma client
npx prisma generate
- create a
.env
file and add the following variables:
DATABASE_URL="your-database-url"
SECRET_KEY="your-secret-key"
- Start the application
npm run dev
- Open the browser and navigate to
http://localhost:8787
The API documentation is available in the docs
folder.
Method | Endpoint | Description | Auth Required |
---|---|---|---|
POST | /api/v1/user/register |
Register new user | No |
POST | /api/v1/user/login |
Login user | No |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET | /api/v1/user/profile |
Get user profile | Yes |
PUT | /api/v1/user/profile |
Update profile | Yes |
PUT | /api/v1/user/password |
Change password | Yes |
DELETE | /api/v1/user/account |
Delete account | Yes |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET | /api/v1/blog/posts |
List all posts | No |
GET | /api/v1/blog/posts/:id |
Get single post | Yes |
GET | /api/v1/blog/posts/search |
Search posts | Yes |
GET | /api/v1/blog/posts/author/:authorId |
Get author's posts | Yes |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
POST | /api/v1/writers/posts |
Create post | Yes |
PUT | /api/v1/writers/posts/:id |
Update post | Yes |
DELETE | /api/v1/writers/posts/:id |
Delete post | Yes |
PATCH | /api/v1/writers/posts/:id/publish |
Toggle publish status | Yes |
GET | /api/v1/writers/drafts |
Get draft posts | Yes |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
POST | /api/v1/blog/posts/:id/comments |
Add comment | Yes |
DELETE | /api/v1/blog/comments/:id |
Delete own comment | Yes |
DELETE | /api/v1/writers/posts/:postId/comments/:commentId |
Delete any comment (writer only) | Yes |
PATCH | /api/v1/writers/posts/:id/comments-status |
Toggle comments | Yes |
here is the live link of website : https://backend.pushpitkamboj.workers.dev/