Skip to content

Commit

Permalink
chore: merge dev branch to feature/api-user-docs branch
Browse files Browse the repository at this point in the history
  • Loading branch information
masterchief-Dave committed Jul 25, 2024
2 parents 6704f25 + 491b595 commit 4b557de
Show file tree
Hide file tree
Showing 94 changed files with 14,146 additions and 1,458 deletions.
45 changes: 29 additions & 16 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
PORT=8000
AUTH_SECRET=
DB_USER=
DB_PORT=
DB_HOST=
DB_PASSWORD=
DB_NAME=
NODE_ENV=development
SMTP_USER=
SMTP_PASSWORD=
SMTP_HOST=
SMTP_SERVICE=
TWILIO_ACCOUNT_SID=
PORT=8000,
"api-prefix": "api/v1",
DB_USER=,
DB_HOST=,
DB_PASSWORD=,
DB_PORT=,
DB_NAME=,
TOKEN_SECRET=
SMTP_USER=,
SMTP_PASSWORD=,
SMTP_HOST=,
SMTP_SERVICE=,
SMTP_PORT=,
REDIS_PASSWORD=,
REDIS_HOST=,
REDIS_PORT=,
NODE_ENV=,
TWILIO_SID=
TWILIO_AUTH_TOKEN=
#Redis Configuration
REDIS_HOST=
REDIS_PORT=
TWILIO_PHONE_NUMBER=
GOOGLE_CLIENT_ID=:
GOOGLE_CLIENT_SECRET=
GOOGLE_AUTH_CALLBACK_URL=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
GOOGLE_AUTH_CALLBACK_URL=
FLW_PUBLIC_KEY=
FLW_SECRET_KEY=
FLW_ENCRYPTION_KEY=
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ build/
tmp/
temp/
.env
env
src/entity
src/ormconfig.ts
yarn.lock
build
issueformat.md
requests.rest
Expand Down
7 changes: 3 additions & 4 deletions contributors.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

[Nainah23](https://github.com/Nainah23)
Erasmus Tayviah (StarmannRassy)

- [Nainah23](https://github.com/Nainah23)
- Erasmus Tayviah (StarmannRassy)
- [Adekolu Samuel Samixx](https://github.com/samixYasuke)
180 changes: 180 additions & 0 deletions docs/blog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Blog API Documentation

This project provides an API for managing blog posts, including creating, editing, deleting, and retrieving blog posts. The API is documented using Swagger.

## Getting Started

### Prerequisites

Make sure you have the following installed on your machine:

- Node.js (>=14.x)
- Yarn (>=1.x)

### Installation

1. Clone the repository:

```bash
git clone repo
cd repo
```

2. Install dependencies:
```bash
yarn install
```

### Running the Server

To start the server, run:

```bash
yarn start
```

## API Endpoints

### Authentication

Ensure that users are authenticated before accessing the endpoints that modify or delete resources.

#### Login

- **URL**: `/api/v1/auth/login`
- **Method**: `POST`
- **Request Body**:
```json
{
"username": "[email protected]",
"password": "password123"
}
```
- **Responses**:
- `200 OK`: Successfully authenticated
- `401 Unauthorized`: Invalid credentials

#### Register

- **URL**: `/api/v1/auth/register`
- **Method**: `POST`
- **Request Body**:
```json
{
"username": "[email protected]",
"password": "password123",
"name": "John Doe"
}
```
- **Responses**:
- `201 Created`: Successfully registered
- `400 Bad Request`: Invalid input

### Create a Blog Post

- **URL**: `/api/v1/blog/create`
- **Method**: `POST`
- **Authentication**: Required
- **Request Body**:
```json
{
"title": "Sample Blog Post",
"content": "This is a sample blog post.",
"author": "John Doe",
"Imageurl": "http://example.com/image.jpg",
"categories": ["Tech", "Programming"],
"tags": ["Node.js", "Express"],
"likes": [],
"comments": []
}
```
- **Responses**:
- `201 Created`: Blog post created successfully
- `400 Bad Request`: Invalid request body
- `401 Unauthorized`: Authentication required
- `500 Internal Server Error`: Server error

### Get All Blog Posts with Pagination

- **URL**: `/api/v1/blog`
- **Method**: `GET`
- **Query Parameters**:
- `page`: Page number (default: 1)
- `limit`: Number of posts per page (default: 10)
- `offset`: Number of posts to skip (default: 0)
- **Responses**:
- `200 OK`: List of blog posts
- `500 Internal Server Error`: Server error

### Get a Single Blog Post by ID

- **URL**: `/api/v1/blog/:id`
- **Method**: `GET`
- **Parameters**:
- `id`: Blog post ID
- **Responses**:
- `200 OK`: Blog post details
- `404 Not Found`: Blog post not found
- `500 Internal Server Error`: Server error

### Edit a Blog Post by ID

- **URL**: `/api/v1/blog/:id`
- **Method**: `PUT`
- **Authentication**: Required
- **Parameters**:
- `id`: Blog post ID
- **Request Body**:
```json
{
"title": "Updated Blog Post",
"content": "This is an updated blog post.",
"author": "John Doe",
"Imageurl": "http://example.com/new-image.jpg",
"categories": ["Tech", "Programming"],
"tags": ["Node.js", "Express"]
}
```
- **Responses**:
- `200 OK`: Blog post updated successfully
- `400 Bad Request`: Invalid request body
- `401 Unauthorized`: Authentication required
- `404 Not Found`: Blog post not found
- `500 Internal Server Error`: Server error

### Delete a Blog Post by ID

- **URL**: `/api/v1/blog/:id`
- **Method**: `DELETE`
- **Authentication**: Required
- **Parameters**:
- `id`: Blog post ID
- **Responses**:
- `204 No Content`: Blog post deleted successfully
- `401 Unauthorized`: Authentication required
- `404 Not Found`: Blog post not found
- `500 Internal Server Error`: Server error

## Project Structure

```
├── src
│ ├── models
│ │ └── blog.ts
│ ├── routes
│ │ └── blog.ts
│ ├── blogSwaggerConfig.ts
│ └── server.ts
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

```
```
Loading

0 comments on commit 4b557de

Please sign in to comment.