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 ​
new ProductController(options): ProductController;Creates a new product controller instance.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
options | BaseControllerOptions | The options passed to the base controller. |
Returns ​
ProductController
Overrides ​
Properties ​
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
roleManager | protected | RoleManager | A reference to the role manager passed in the base controller options. | BaseController.roleManager |
specification | public | SwaggerSpecification | A reference to the swagger specification passed in the base controller options. | BaseController.specification |
Methods ​
createProduct() ​
createProduct(req, res): Promise<void>;POST /products
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The created product entity
Operation Id ​
createProduct
Tags ​
products - Operations of product controller
Security ​
JWT
deleteProduct() ​
deleteProduct(req, res): Promise<void>;DELETE /products/
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
204 - Success
Operation Id ​
deleteProduct
Tags ​
products - Operations of products controller
Security ​
JWT
getAllProducts() ​
getAllProducts(req, res): Promise<void>;GET /products
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - All existing products
Operation Id ​
getAllProducts
Tags ​
products - Operations of product controller
Security ​
JWT
getPolicy() ​
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 ​
The policy of this controller.
Overrides ​
getRouter() ​
getRouter(): Router;Returns ​
Router
the router used by this controller.
Inherited from ​
getSingleProduct() ​
getSingleProduct(req, res): Promise<void>;GET /products/
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The requested product entity
Operation Id ​
getSingleProduct
Tags ​
products - Operations of products controller
Security ​
JWT
updateProduct() ​
updateProduct(req, res): Promise<void>;PATCH /products/
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The created product entity
Operation Id ​
updateProduct
Tags ​
products - Operations of product controller
Security ​
JWT
updateProductImage() ​
updateProductImage(req, res): Promise<void>;POST /products/{id}/image
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
204 - Success
Operation Id ​
updateProductImage
Tags ​
products - Operations of products controller
Consumes ​
multipart/form-data
Security ​
JWT
getRelation() ​
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 ​
| Parameter | Type | Description |
|---|---|---|
req | RequestWithToken | Request with product id as param |
Returns ​
Promise<string>
whether product is connected to user token
postRelation() ​
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 ​
| Parameter | Type | Description |
|---|---|---|
req | RequestWithToken | Request with CreateProductRequest as body |
Returns ​
string
whether product is connected to user token