-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from fawizzy/create_organization
feat: API Endpoint to Create Organisation
- Loading branch information
Showing
18 changed files
with
7,709 additions
and
206 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,125 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
import { OrganisationService } from "../services/createOrg.services"; | ||
// import { NextFunction, Request, Response } from "express"; | ||
// import { OrganisationService } from "../services/organization.service"; | ||
|
||
/** | ||
* @swagger | ||
* /organisation: | ||
* post: | ||
* summary: Create a new organisation | ||
* description: This endpoint allows a user to create a new organisation | ||
* tags: | ||
* - Organisation | ||
* operationId: createOrganisation | ||
* requestBody: | ||
* description: Organisation payload | ||
* required: true | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* name: | ||
* type: string | ||
* example: My Organisation | ||
* description: | ||
* type: string | ||
* example: This is a sample organisation. | ||
* required: | ||
* - name | ||
* responses: | ||
* '201': | ||
* description: Organisation created successfully | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* status: | ||
* type: string | ||
* example: success | ||
* message: | ||
* type: string | ||
* example: Organisation created successfully | ||
* data: | ||
* type: object | ||
* properties: | ||
* id: | ||
* type: string | ||
* example: "1" | ||
* name: | ||
* type: string | ||
* example: My Organisation | ||
* description: | ||
* type: string | ||
* example: This is a sample organisation. | ||
* createdAt: | ||
* type: string | ||
* format: date-time | ||
* updatedAt: | ||
* type: string | ||
* format: date-time | ||
* status_code: | ||
* type: integer | ||
* example: 201 | ||
* '400': | ||
* description: Bad Request | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* status: | ||
* type: string | ||
* example: error | ||
* message: | ||
* type: string | ||
* example: Invalid input | ||
* status_code: | ||
* type: integer | ||
* example: 400 | ||
* '500': | ||
* description: Internal Server Error | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* status: | ||
* type: string | ||
* example: error | ||
* message: | ||
* type: string | ||
* example: Internal server error | ||
* status_code: | ||
* type: integer | ||
* example: 500 | ||
*/ | ||
// /** | ||
// * @swagger | ||
// * /organisation: | ||
// * post: | ||
// * summary: Create a new organisation | ||
// * description: This endpoint allows a user to create a new organisation | ||
// * tags: | ||
// * - Organisation | ||
// * operationId: createOrganisation | ||
// * requestBody: | ||
// * description: Organisation payload | ||
// * required: true | ||
// * content: | ||
// * application/json: | ||
// * schema: | ||
// * type: object | ||
// * properties: | ||
// * name: | ||
// * type: string | ||
// * example: My Organisation | ||
// * description: | ||
// * type: string | ||
// * example: This is a sample organisation. | ||
// * required: | ||
// * - name | ||
// * responses: | ||
// * '201': | ||
// * description: Organisation created successfully | ||
// * content: | ||
// * application/json: | ||
// * schema: | ||
// * type: object | ||
// * properties: | ||
// * status: | ||
// * type: string | ||
// * example: success | ||
// * message: | ||
// * type: string | ||
// * example: Organisation created successfully | ||
// * data: | ||
// * type: object | ||
// * properties: | ||
// * id: | ||
// * type: string | ||
// * example: "1" | ||
// * name: | ||
// * type: string | ||
// * example: My Organisation | ||
// * description: | ||
// * type: string | ||
// * example: This is a sample organisation. | ||
// * createdAt: | ||
// * type: string | ||
// * format: date-time | ||
// * updatedAt: | ||
// * type: string | ||
// * format: date-time | ||
// * status_code: | ||
// * type: integer | ||
// * example: 201 | ||
// * '400': | ||
// * description: Bad Request | ||
// * content: | ||
// * application/json: | ||
// * schema: | ||
// * type: object | ||
// * properties: | ||
// * status: | ||
// * type: string | ||
// * example: error | ||
// * message: | ||
// * type: string | ||
// * example: Invalid input | ||
// * status_code: | ||
// * type: integer | ||
// * example: 400 | ||
// * '500': | ||
// * description: Internal Server Error | ||
// * content: | ||
// * application/json: | ||
// * schema: | ||
// * type: object | ||
// * properties: | ||
// * status: | ||
// * type: string | ||
// * example: error | ||
// * message: | ||
// * type: string | ||
// * example: Internal server error | ||
// * status_code: | ||
// * type: integer | ||
// * example: 500 | ||
// */ | ||
|
||
export const createOrganisation = async ( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction, | ||
) => { | ||
try { | ||
const payload = req.body; | ||
const user = req.user; | ||
const userId = user.id; | ||
// export const createOrganisation = async ( | ||
// req: Request, | ||
// res: Response, | ||
// next: NextFunction, | ||
// ) => { | ||
// try { | ||
// const payload = req.body; | ||
// const user = req.user; | ||
// const userId = user.id; | ||
|
||
const organisationService = new OrganisationService(); | ||
const newOrganisation = await organisationService.createOrganisation( | ||
payload, | ||
userId, | ||
); | ||
// const organisationService = new OrganisationService(); | ||
// const newOrganisation = await organisationService.createOrganisation( | ||
// payload, | ||
// userId, | ||
// ); | ||
|
||
const respObj = { | ||
status: "success", | ||
message: "organisation created successfully", | ||
data: newOrganisation, | ||
status_code: 201, | ||
}; | ||
// const respObj = { | ||
// status: "success", | ||
// message: "organisation created successfully", | ||
// data: newOrganisation, | ||
// status_code: 201, | ||
// }; | ||
|
||
return res.status(201).json(respObj); | ||
} catch (error) { | ||
return next(error); | ||
} | ||
}; | ||
// return res.status(201).json(respObj); | ||
// } catch (error) { | ||
// return next(error); | ||
// } | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.