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/propertyname.js';
import { emit } from '../sse.js';
// #region Helpers
function requireSelectedCompany(req) {
const companyId = req.user?.selectedCompanyId;
if (companyId == null) {
@@ -22,6 +24,8 @@ function propertyErrorStatus(error) {
return 500;
}
// #endregion
/**
* Registers propertyname routes.
* @param {import('express').Application} app
@@ -93,6 +97,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region GET /propertyname
app.get(`${basePath}/propertyname`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -107,6 +113,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region POST /propertyname
app.post(`${basePath}/propertyname`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -122,6 +132,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /propertyname/order:
@@ -154,6 +166,8 @@ export function register(app, basePath = '') {
* 400:
* description: Bad request
*/
// #region PUT /propertyname/order
app.put(`${basePath}/propertyname/order`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -169,6 +183,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /propertyname/{id}:
@@ -265,6 +281,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region PATCH /propertyname/:id
app.patch(`${basePath}/propertyname/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -283,6 +301,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region DELETE /propertyname/:id
app.delete(`${basePath}/propertyname/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -303,4 +325,6 @@ export function register(app, basePath = '') {
res.status(status).json({ error: message });
}
});
// #endregion
}