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
- Host: GitHub
- URL: https://github.com/sohnryang/simple-forum-api
- Owner: sohnryang
- Created: 2022-01-24T05:36:09.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-07T12:52:15.000Z (over 3 years ago)
- Last Synced: 2025-01-18T09:33:03.931Z (5 months ago)
- Language: TypeScript
- Size: 752 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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//
```