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,5 +1,7 @@
import * as db from '../../db/numbers.js';
// #region Helpers
function requireSelectedCompany(req) {
const companyId = req.user.selectedCompanyId;
if (companyId == null) {
@@ -17,6 +19,8 @@ function numberErrorStatus(error) {
return 500;
}
// #endregion
/**
* Registers number-sequence routes for the authenticated user's selected company.
* @param {import('express').Application} app
@@ -70,6 +74,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region GET /number
app.get(`${basePath}/number`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -86,6 +92,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /number/{id}:
@@ -161,6 +169,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region PATCH /number/:id
app.patch(`${basePath}/number/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -193,4 +203,6 @@ export function register(app, basePath = '') {
res.status(status).json({ error: error.message });
}
});
// #endregion
}