An open API service indexing awesome lists of open source software.

https://github.com/sohnryang/simple-forum-api

A simple forum API server built with Nest.js
https://github.com/sohnryang/simple-forum-api

Last synced: 3 months ago
JSON representation

A simple forum API server built with Nest.js

Awesome Lists containing this project

README

        

# Simple Forum API Server

A REST API for a simple forum website.

## Features

- Users
- User holds email, birthday and username.
- Posts
- Posts hold title, content, and hashtags.
- Search
- Posts can be searched using title, content, author username and hashtags.
- Authorization
- JWT-based authorization for some operations.

## API specs

### Users

#### Create user

```
POST /users
```

##### Request body

```json
{
"email": "...",
"birthday": "...",
"username": "...",
"password": "..."
}
```

#### Get a user's info

```
GET /users/
```

##### Response body

If successful, the response body contains email address, birthday, and username under field `email`, `birthday`, and `username` respectively.

#### Get JWT token

```
POST /users/auth
```

##### Request body

```json
{
"email": "...",
"password": "..."
}
```

##### Response body

If successful, the response contains the generated JWT under field `token`.

#### Update user info

```
PATCH /users/
```

##### Request body

```json
{
"email": "...",
"birthday": "...",
"username": "...",
"password": "..."
}
```

#### Delete user

```
DELETE /users/
```

### Posts

#### Create post

```
POST /posts
```

##### Request body

```json
{
"title": "...",
"content": "...",
"hashtags": ["...", "..."]
}
```

#### List posts

```
GET /posts
```

##### Response body

If successful, the response body contains an array of `PostEntity` instances.

TODO: add pagination

#### Get a post

```
GET /posts/
```

##### Response body

If successful, the response body contains an instance of `PostEntity` which corresponds to the given ID.

#### Update post

```
PATCH /posts/
```

##### Request body

```json
{
"title": "...",
"content": "...",
"hashtags": ["...", "..."]
}
```

#### Delete post

```
DELETE /posts/
```

#### Send search query

```
POST /posts/search
```

##### Request body

```json
{
"keyword": "...",
"hashtags": [...], // A list of hashtags
"author": "..."
}
```

##### Response body

If successful, the response body contains an array of `PostEntity` instances.

### Comments

#### Create comment for a post

```
POST /comments/
```

##### Request body

```json
{
"contents": "..."
}
```

#### Get comments for a post

```
GET /comments/
```

##### Response body

If successful, the response body contains an array of `CommentEntity` instances.

TODO: add pagination

#### Get a single comment

```
GET /comments//
```

##### Response body

If successful, the response body contains an instance of `CommentEntity` which corresponds to the given post ID and comment ID.

#### Delete comment

```
DELETE /comments//
```