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/quote.js';
// #region Helpers
function requireSelectedCompany(req) {
const companyId = req.user.selectedCompanyId;
if (companyId == null) {
@@ -22,6 +24,8 @@ function quoteErrorStatus(error) {
return 500;
}
// #endregion
/**
* Registers quote routes for the authenticated user's selected company.
* @param {import('express').Application} app
@@ -155,6 +159,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region GET /quote
app.get(`${basePath}/quote`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -171,6 +177,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region POST /quote
app.post(`${basePath}/quote`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -198,6 +208,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /quote/{id}:
@@ -362,6 +374,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region GET /quote/:id
app.get(`${basePath}/quote/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -383,6 +397,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region PATCH /quote/:id
app.patch(`${basePath}/quote/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -425,6 +443,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region DELETE /quote/:id
app.delete(`${basePath}/quote/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -445,4 +467,6 @@ export function register(app, basePath = '') {
res.status(status).json({ error: error.message });
}
});
// #endregion
}