u
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import * as db from '../../db/categoryattributevalue.js';
|
||||
import { emit } from '../sse.js';
|
||||
|
||||
// #region Helpers
|
||||
|
||||
function requireSelectedCompany(req) {
|
||||
const companyId = req.user?.selectedCompanyId;
|
||||
if (companyId == null) {
|
||||
@@ -33,6 +35,8 @@ function categoryAttributeValueErrorStatus(error) {
|
||||
return 500;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* Registers categoryattributevalue routes under `/category/:id/attributevalue`.
|
||||
* @param {import('express').Application} app
|
||||
@@ -103,6 +107,8 @@ export function register(app, basePath = '') {
|
||||
* items:
|
||||
* $ref: '#/components/schemas/CategoryAttributeValue'
|
||||
*/
|
||||
// #region GET /category/:id/attributevalue
|
||||
|
||||
app.get(`${basePath}/category/:id/attributevalue`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -122,6 +128,10 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region PUT /category/:id/attributevalue
|
||||
|
||||
app.put(`${basePath}/category/:id/attributevalue`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -143,4 +153,6 @@ export function register(app, basePath = '') {
|
||||
res.status(categoryAttributeValueErrorStatus(error)).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user