Closed FredChuksDev closed 1 month ago
Develop a backend API for creating organisations, including authentication and authorization checks, input validation, and error handling.
Authentication Middleware
401 Unauthorized
Create Organisation Endpoint
HTTP POST
/api/v1/organisations
201 Created
Field Validation
422 Unprocessable Entity
{ "name": "String", "description": "String", "email": "string", "industry": "string", "type": "string", "country": "string", "address": "string", "state": "string", }
{ "status": "success", "message": "organisation created successfully", "data": { "id": "String", "name": "String", "description": "String", "owner_id": "string", "slug" : "string", "email": "string", "industry": "string", "type": "string", "country": "string", "address": "string", "state": "string", "created_at": "2024-01-01T12:00:00Z", "updated_at": "2024-06-01T12:00:00Z" }, "status_code": 201 }
{ "status": "Bad Request", "message": "Client error", "statusCode": 400 }
{ "errors": [ { "field": "String", "message": "String" } ] }
{ "status": "Unauthorized", "message": "User not authenticated", "statusCode": 401 }
Table organisations { id uuid [primary key] slug varchar(255) [unique] owner_id uuid [foreign key to users(id)] name varchar(255) email varchar(255) industry varchar(255) type varchar(255) country varchar(255) address varchar(255) state varchar(255) description text created_at timestamp updated_at timestamp } Table organisations_user { user_id uuid [foreign key to users(id)] organisation_id uuid [foreign key to organisations(id)] role varchar(255) created_at timestamp updated_at timestamp } Ref: users.id < organisations_user.user_id Ref: organisations.id < organisations_user.organisation_id
Provide a backend service that allows admins to create new organizations, ensuring proper authentication, authorization, and validation.
The API endpoint allows admins to create new organisations with appropriate validation and authentication.
HTTP POST /api/v1/organisations
This issue is linked to the approved issue here
Description
Develop a backend API for creating organisations, including authentication and authorization checks, input validation, and error handling.
Acceptance Criteria
Authentication Middleware
401 Unauthorized
status code.Create Organisation Endpoint
HTTP POST
requests at/api/v1/organisations
.201 Created
status code if the user request is valid.Field Validation
422 Unprocessable Entity
status code with detailed error messages.Request Body
Successful Response
Unsuccessful Response
Validation Error Response
Unauthenticated Error Response
Database Design
Purpose
Provide a backend service that allows admins to create new organizations, ensuring proper authentication, authorization, and validation.
Requirements
Expected Outcome
The API endpoint allows admins to create new organisations with appropriate validation and authentication.
Task
HTTP POST /api/v1/organisations
to create new organisations.Testing