Skip to content

Get Code

Method

REST method is adopted.

HTTP Method

GET: Get single code information

Naming Convention

To unify the naming of query parameters and nodes and improve readability, snake_case is used for URIs and JSON nodes in requests.

Request and Response

Headers

Meta information is set in HTTP headers, not in the response body.

Request Headers

  • Authorization
  • Content-Type
  • Accept
  • Accept-language

Response Headers

  • Content-Type

Get Single Code Information

URI

GET /v1/organizations/{organization_id}/projects/{project_id}/code/{code_id}

Path Parameters

Name Type Required Description
organization_id number Required Backend PostgreSQL organization ID
project_id number Required Backend PostgreSQL project ID
code_id string Required Code UUID

Response

The response is JSON.

{
  "id": "0192a3b4-c5d6-4e8f-9a0b-1c2d3e4f5a6b",
  "projectId": 42,
  "name": "Button",
  "s3Key": "code/0192a3b4-c5d6-4e8f-9a0b-1c2d3e4f5a6b.png",
  "sourceCode": "const Button = () => { ... }",
  "cssCode": ".button { ... }",
  "status": 1,
  "createdAt": 1234567890000,
  "updatedAt": 1234567890000,
  "deletedAt": null,
  "createdBy": "user-id",
  "updatedBy": "user-id",
  "deletedBy": null
}

Response Fields

Name Type Description
id string Code UUID
projectId number Backend PostgreSQL project ID
name string Code name
s3Key string S3 key for preview image
sourceCode string Source code
cssCode string | null CSS code
status number Processing status (0 processing, 1 completed, 2 failed)
createdAt number Creation timestamp (epoch milliseconds)
updatedAt number Update timestamp (epoch milliseconds)

Authentication

Authentication is performed using JSON Web Tokens (JWT) issued by Amazon Cognito.

Error Handling

The status codes for error handling are as follows.

Description Status Code Status Name
Missing credentials 401 Unauthorized
Insufficient permissions 403 Forbidden
Code, project, or organization not found 404 Not Found
Internal server error 500 Internal Server Error

Processing Flow

  1. Extract organization ID, project ID, and code ID from path parameters
  2. Verify the user has access to the project
  3. Verify the code belongs to the specified project
  4. Return code information

Detailed Flowchart

flowchart TD
    Start([GET Request]) --> Route[Route Handler]
    Route --> Auth[Auth & Parameter Extraction]
    Auth --> Service[Service Layer]

    Service --> AccessCheck[Access Check]
    AccessCheck --> HasAccess{Read permission?}
    HasAccess -->|No| Err404[404 Not Found]
    HasAccess -->|Yes| QueryDB

    QueryDB[Repository Layer] --> FindOne[Fetch Record<br/>WHERE id = ?<br/>AND projectId = ?<br/>AND deletedAt IS NULL]

    FindOne --> Exists{Exists?}
    Exists -->|No| Err404
    Exists -->|Yes| Format[Format Response<br/>Dateโ†’timestamp conversion]

    Format --> Response[200 OK]