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

@@ -2,6 +2,8 @@ import multer from 'multer';
import * as db from '../../db/delivery.js';
import { writeErrorLog } from '../../util/errorLog.js';
// #region Helpers
// Shared memory storage for delivery attachments (max 50 MB)
const multerUpload = multer({
storage: multer.memoryStorage(),
@@ -184,6 +186,8 @@ function deliveryErrorStatus(error) {
return 500;
}
// #endregion
/**
* Registers delivery (goods receipt) routes for the authenticated user's selected company.
* @param {import('express').Application} app
@@ -344,6 +348,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region GET /delivery
app.get(`${basePath}/delivery`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -361,6 +367,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region POST /delivery
app.post(`${basePath}/delivery`, uploadDeliveryFiles, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -412,6 +422,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /delivery/{id}:
@@ -613,6 +625,8 @@ export function register(app, basePath = '') {
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region GET /delivery/:id
app.get(`${basePath}/delivery/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -635,6 +649,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region PATCH /delivery/:id
app.patch(`${basePath}/delivery/:id`, uploadDeliveryFiles, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -695,6 +713,10 @@ export function register(app, basePath = '') {
}
});
// #endregion
// #region DELETE /delivery/:id
app.delete(`${basePath}/delivery/:id`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
@@ -723,6 +745,8 @@ export function register(app, basePath = '') {
}
});
// #endregion
/**
* @openapi
* /delivery/{id}/file/{fileId}:
@@ -867,6 +891,15 @@ export function register(app, basePath = '') {
}
};
// #region GET /delivery/:id/file/:fileId
app.get(`${basePath}/delivery/:id/file/:fileId`, handleGetDeliveryFile);
// #endregion
// #region GET /delivery/:id/files/:fileId
app.get(`${basePath}/delivery/:id/files/:fileId`, handleGetDeliveryFile);
// #endregion
}