u
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user