Skip to content

SudoSOS Back-end API / catalogue/products / ProductController

Class: ProductController ​

The BaseController class is responsible for:

  • Storing route definitions.
  • Generating router objects based on the policy.

Extends ​

Constructors ​

Constructor ​

ts
new ProductController(options): ProductController;

Creates a new product controller instance.

Parameters ​

ParameterTypeDescription
optionsBaseControllerOptionsThe options passed to the base controller.

Returns ​

ProductController

Overrides ​

BaseController.constructor

Properties ​

PropertyModifierTypeDescriptionInherited from
roleManagerprotectedRoleManagerA reference to the role manager passed in the base controller options.BaseController.roleManager
specificationpublicSwaggerSpecificationA reference to the swagger specification passed in the base controller options.BaseController.specification

Methods ​

createProduct() ​

ts
createProduct(req, res): Promise<void>;

POST /products

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - The created product entity

Operation Id ​

createProduct

Tags ​

products - Operations of product controller

Security ​

JWT


deleteProduct() ​

ts
deleteProduct(req, res): Promise<void>;

DELETE /products/

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

204 - Success

Operation Id ​

deleteProduct

Tags ​

products - Operations of products controller

Security ​

JWT


getAllProducts() ​

ts
getAllProducts(req, res): Promise<void>;

GET /products

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - All existing products

Operation Id ​

getAllProducts

Tags ​

products - Operations of product controller

Security ​

JWT


getPolicy() ​

ts
getPolicy(): Policy;

Gets the policy defined by child classes. This policy includes all routes that the controller accepts, the authorization middleware, and the final handler function for every route.

Returns ​

Policy

The policy of this controller.

Overrides ​

BaseController.getPolicy


getRouter() ​

ts
getRouter(): Router;

Returns ​

Router

the router used by this controller.

Inherited from ​

BaseController.getRouter


getSingleProduct() ​

ts
getSingleProduct(req, res): Promise<void>;

GET /products/

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - The requested product entity

Operation Id ​

getSingleProduct

Tags ​

products - Operations of products controller

Security ​

JWT


updateProduct() ​

ts
updateProduct(req, res): Promise<void>;

PATCH /products/

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - The created product entity

Operation Id ​

updateProduct

Tags ​

products - Operations of product controller

Security ​

JWT


updateProductImage() ​

ts
updateProductImage(req, res): Promise<void>;

POST /products/{id}/image

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

204 - Success

Operation Id ​

updateProductImage

Tags ​

products - Operations of products controller

Consumes ​

multipart/form-data

Security ​

JWT


getRelation() ​

ts
static getRelation(req): Promise<string>;

Function to determine which credentials are needed to get product 'all' if user is not connected to product 'own' if user is connected to product

Parameters ​

ParameterTypeDescription
reqRequestWithTokenRequest with product id as param

Returns ​

Promise<string>

whether product is connected to user token


postRelation() ​

ts
static postRelation(req): string;

Function to determine which credentials are needed to post product 'all' if user is not connected to product 'organ' if user is not connected to product via organ 'own' if user is connected to product

Parameters ​

ParameterTypeDescription
reqRequestWithTokenRequest with CreateProductRequest as body

Returns ​

string

whether product is connected to user token