NG Word API
Endpoints for managing the prohibited words used to screen generated text. The article/blog generation and rewrite Lambdas load every row at start-up and build an Aho-Corasick automaton to scan their output.
POST /v1/ng_words
Overview
Registers a new NG word.
Request and Response
Headers
Request Headers
Content-Type: application/json
Response Headers
Content-Type: application/json
URI
Request Body
| Field | Type | Required | Notes |
|---|---|---|---|
| name | string | โฏ |
Response
201 Created
Error Handling
| Description | Status Code | Status Name |
|---|---|---|
| Invalid request body | 422 | Unprocessable Entity |
| Internal server error | 500 | Internal Server Error |
Processing Flow
- Receive the request
- Validate the request body
- Create and save the NG word
- Return the created NG word
flowchart TD
Start([POST /v1/ng_words]) --> Validate[Request validation]
Validate -->|invalid| E422[422 Unprocessable Entity]
Validate -->|valid| Save[Save to DB]
Save --> Success[201 Created]
GET /v1/ng_words
Overview
Retrieves a list of NG words.
Request and Response
URI
Query Parameters
| Parameter | Type | Required | Notes |
|---|---|---|---|
| page | number | Page number to retrieve. Default: 1 |
|
| size | number | Items per page. Default: 10 |
|
| order | enum | asc / desc (by updated_at). Default: desc |
Request Body
None
Response
200 OK
{
"list": [
{
"id": "string",
"name": "string",
"created_at": 1234567890000,
"updated_at": 1234567890000
}
],
"current_page": 1,
"total_count": 10
}
Error Handling
| Description | Status Code | Status Name |
|---|---|---|
| Internal server error | 500 | Internal Server Error |
Processing Flow
- Receive the request
- Fetch the NG word list
- Return the list
flowchart TD
Start([GET /v1/ng_words]) --> Fetch[Fetch NG word list from DB]
Fetch --> Success[200 OK]
GET /v1/ng_words/{ng_word_id}
Overview
Retrieves the specified NG word.
Request and Response
URI
| Path Parameter | Type | Notes |
|---|---|---|
| ng_word_id | string | _id |
Request Body
None
Response
200 OK
Error Handling
| Description | Status Code | Status Name |
|---|---|---|
| NG word not found | 404 | Not Found |
| Internal server error | 500 | Internal Server Error |
Processing Flow
- Receive the request
- Search for the NG word by
ng_word_id - Return the NG word
flowchart TD
Start([GET /v1/ng_words/ng_word_id]) --> Fetch[Search in DB]
Fetch -->|not found| E404[404 Not Found]
Fetch -->|found| Success[200 OK]
PUT /v1/ng_words/{ng_word_id}
Overview
Updates the specified NG word.
Request and Response
Headers
Request Headers
Content-Type: application/json
Response Headers
Content-Type: application/json
URI
| Path Parameter | Type | Notes |
|---|---|---|
| ng_word_id | string | _id |
Request Body
| Field | Type | Required | Notes |
|---|---|---|---|
| name | string | โฏ |
Response
200 OK
Error Handling
| Description | Status Code | Status Name |
|---|---|---|
| Invalid request body | 422 | Unprocessable Entity |
| NG word not found | 404 | Not Found |
| Internal server error | 500 | Internal Server Error |
Processing Flow
- Receive the request
- Validate the request body
- Verify the NG word exists
- Update and save the NG word
- Return the updated NG word
flowchart TD
Start([PUT /v1/ng_words/ng_word_id]) --> Validate[Request validation]
Validate -->|invalid| E422[422 Unprocessable Entity]
Validate -->|valid| Fetch[Search in DB]
Fetch -->|not found| E404[404 Not Found]
Fetch -->|found| Save[Save to DB]
Save --> Success[200 OK]
DELETE /v1/ng_words/{ng_word_id}
Overview
Soft-deletes the specified NG word.
Request and Response
URI
| Path Parameter | Type | Notes |
|---|---|---|
| ng_word_id | string | _id |
Request Body
None
Response
204 No Content
Error Handling
| Description | Status Code | Status Name |
|---|---|---|
| NG word not found | 404 | Not Found |
| Internal server error | 500 | Internal Server Error |
Processing Flow
- Receive the request
- Verify the NG word exists
- Set
deleted_atto the current time and save (soft delete) - Return 204
flowchart TD
Start([DELETE /v1/ng_words/ng_word_id]) --> Fetch[Search in DB]
Fetch -->|not found| E404[404 Not Found]
Fetch -->|found| Delete[Set deleted_at]
Delete --> Success[204 No Content]