This commit is contained in:
seb
2026-10-10 02:08:10 +02:00
parent d4e2b05cb0
commit 7f8661be3e
43 changed files with 3312 additions and 2339 deletions

View File

@@ -1,6 +1,8 @@
import * as db from '../../db/categoryproperty.js';
import { emit } from '../sse.js';
// #region Helpers
function requireSelectedCompany(req) {
const companyId = req.user?.selectedCompanyId;
if (companyId == null) {
@@ -33,6 +35,8 @@ function categoryPropertyErrorStatus(error) {
return 500;
}
// #endregion
/**
* Registers categoryproperty routes under `/category/:id/property`.
* @param {import('express').Application} app
@@ -113,6 +117,8 @@ export function register(app, basePath = '') {
* items:
* $ref: '#/components/schemas/CategoryProperty'
*/
// #region GET /category/:id/property
app.get(`${basePath}/category/:id/property`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -132,6 +138,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region PUT /category/:id/property
app.put(`${basePath}/category/:id/property`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -157,6 +167,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /category/{id}/property/{propertyId}:
@@ -185,6 +197,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/SuccessResponse'
*/
// #region DELETE /category/:id/property/:propertyId
app.delete(`${basePath}/category/:id/property/:propertyId`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -205,4 +219,6 @@ export function register(app, basePath = '') {
res.status(categoryPropertyErrorStatus(error)).json({ error: error.message });
}
});
// #endregion
}