Skip to content

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

POST /v1/ng_words

Request Body

{
  "name": "string"
}
Field Type Required Notes
name string โ—ฏ

Response

201 Created

{
  "id": "string",
  "name": "string",
  "created_at": 1234567890000,
  "updated_at": 1234567890000
}

Error Handling

Description Status Code Status Name
Invalid request body 422 Unprocessable Entity
Internal server error 500 Internal Server Error

Processing Flow

  1. Receive the request
  2. Validate the request body
  3. Create and save the NG word
  4. 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

GET /v1/ng_words

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

  1. Receive the request
  2. Fetch the NG word list
  3. 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

GET /v1/ng_words/{ng_word_id}
Path Parameter Type Notes
ng_word_id string _id

Request Body

None

Response

200 OK

{
  "id": "string",
  "name": "string",
  "created_at": 1234567890000,
  "updated_at": 1234567890000
}

Error Handling

Description Status Code Status Name
NG word not found 404 Not Found
Internal server error 500 Internal Server Error

Processing Flow

  1. Receive the request
  2. Search for the NG word by ng_word_id
  3. 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

PUT /v1/ng_words/{ng_word_id}
Path Parameter Type Notes
ng_word_id string _id

Request Body

{
  "name": "string"
}
Field Type Required Notes
name string โ—ฏ

Response

200 OK

{
  "id": "string",
  "name": "string",
  "created_at": 1234567890000,
  "updated_at": 1234567890000
}

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

  1. Receive the request
  2. Validate the request body
  3. Verify the NG word exists
  4. Update and save the NG word
  5. 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

DELETE /v1/ng_words/{ng_word_id}
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

  1. Receive the request
  2. Verify the NG word exists
  3. Set deleted_at to the current time and save (soft delete)
  4. 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]