Delete Project
Method
REST method is adopted.
HTTP Method
DELETE: Soft-delete a project
Naming Convention
To unify naming of query parameters and nodes and improve readability, snake_case is used for URIs and nodes in JSON during requests.
Request and Response
Headers
Meta information is set in HTTP headers rather than in the response body.
Request Headers
Authorization:Bearer <access_token>Content-Type:application/json
Response Headers
Content-Type:application/json
Delete Project
URI
Path parameter type is integer.
Response (200 OK)
Response is JSON. The project record is soft-deleted (deletedAt is populated).
{
"id": 1,
"organizationId": 1,
"name": "Project Alpha",
"createdAt": 1640995200000,
"updatedAt": 1640995200000,
"createdBy": "1111-aaaa-2222-bbbb",
"updatedBy": "1111-aaaa-2222-bbbb",
"deletedAt": 1640995200000,
"deletedBy": "1111-aaaa-2222-bbbb"
}
Authentication
Authentication is performed using JSON Web Tokens (JWT) issued by Amazon Cognito. A valid Bearer token is required in the Authorization header.
Exception Handling
Exception handling status codes are as follows.
| Description | Status Code | Status Name |
|---|---|---|
| Missing or invalid token | 401 | Unauthorized |
| Project not found | 404 | Not Found |
| Internal server error | 500 | Internal Server Error |
Process Flow
Sequence Diagram
sequenceDiagram
participant Client
participant Middleware as Protected Route Middleware
participant API as Hono Router
participant Service as Project Service
participant DB as PostgreSQL Database
Client->>Middleware: DELETE /api/v1/projects/{project_id}
Middleware->>Middleware: Verify JWT & session
alt Token Valid
Middleware-->>API: Auth info (sub)
API->>Service: remove(id, actorSub)
Service->>DB: findOneByIdOnly(id)
DB-->>Service: Existing project
alt Project Found
Service->>DB: softDelete(id, organizationId, actorSub)
DB-->>Service: Soft-deleted project
Service-->>API: Project with deletedAt
API-->>Client: 200 OK
else Project Not Found
Service-->>API: throw NotFoundError
API-->>Client: 404 Not Found
end
else Token Invalid
Middleware-->>Client: 401 Unauthorized
end
Routes Layer
API routing is performed here. The protectedRoute middleware validates the JWT token. The handler extracts the project_id path parameter and actor's Cognito sub, then delegates to the project service.
Source: apps/admin/src/routes/v1/project.ts
Services Layer
This section describes business logic. It verifies the project exists, then performs a soft-delete by setting deletedAt and recording the actor's Cognito sub as the deleter.
Source: apps/admin/src/services/project.ts
Repositories Layer
This section describes access to databases. It handles project lookup and soft-deletion.
Source: apps/admin/src/repositories/project.ts
Security
- Token validated by
protectedRoutemiddleware before handler execution - Actor's Cognito sub recorded as
deletedByfor audit trail - Soft-delete preserves data for potential recovery