A Node RESTful API that manages a blog's users, posts, categories & comments.
Technologies Used: Node.js - Nest.js - TypeScript - PostgresSQL - TypeORM.
- Connect to the Database, Perform CRUD Operations & Create Relationships using TypeORM.
- Create Environment Variables using Config Module.
- Validate Data using Validation Pipes & DTOs.
- Serialize Returned Data using Interceptors & DTOs.
- Authenticate users with JWT & Cookies using Passport JWT Strategy.
- Hash Passwords with bcrypt.
- Authorize Routes with Guards.
To run this project, you will need to create a .env file in the root directory of the project
JWT_SECRET
JWT_EXPIRATION_TIME
POSTGRES_USER
POSTGRES_PASSWORD
POSTGRES_DB
ADMIN_EMAIL
ADMIN_PASSWORD
Clone the project
git clone https://github.com/Ahmed-Yassen/blog.git
Go to the project directory
cd blog
Install dependencies
npm install
Start the server
npm run start
POST /api/auth/sign-up/
Parameter | Type | Description |
---|---|---|
email |
string |
Required. |
password |
string |
Required. should be atleast 8 characters. |
firstName |
string |
Required. |
lastName |
string |
Required. |
POST /api/auth/sign-in
Parameter | Type | Description |
---|---|---|
email |
string |
Required. |
password |
string |
Required. |
POST /api/auth/sign-out
Parameter | Type | Description |
---|
GET /api/users/profile
POST /api/users/change-password
Parameter | Type | Description |
---|---|---|
currentPassword |
string |
Required. |
newPassword |
string |
Required. |
DELETE /api/users/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. user id |
POST /api/categories
Parameter | Type | Description |
---|---|---|
name |
string |
Required. |
GET /api/categories
PATCH /api/categories/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. |
name |
string |
Required. |
DELETE /api/categories/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. |
POST /api/posts
Parameter | Type | Description |
---|---|---|
title |
string |
Required. |
content |
string |
Required. |
categories |
array[{id:number}] |
Required. an array that holds objects that contain the category id of each category of the post |
PATCH /api/posts/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. |
content |
string |
Optional. |
title |
string |
Optional. |
categories |
array[{id:number}] |
Optional. |
- Can remove only my posts when role is user
- Can remove any post when role is admin
DELETE /api/patients/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. |
GET /api/posts/find/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. id of the post to find |
GET /api/posts/my-posts
GET /api/posts/user/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. id of a user to find their posts |
GET /api/posts/category/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. id of the category. |
GET /api/posts/newest
POST /api/comments
Parameter | Type | Description |
---|---|---|
content |
string |
Required. |
postId |
number |
Required. |
PATCH /api/comments/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. |
content |
string |
Required. |
DELETE /api/comments/:id
Parameter | Type | Description |
---|---|---|
id |
number |
Required. |
If you have any feedback, please reach out to me at ahmed.ibrahim.yassen@gmail.com