u
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { randomInt } from 'node:crypto';
|
||||
import * as db from '../../db/posterminal.js';
|
||||
|
||||
// #region Helpers
|
||||
|
||||
function requireSelectedCompany(req) {
|
||||
const companyId = req.user.selectedCompanyId;
|
||||
if (companyId == null) {
|
||||
@@ -27,6 +29,8 @@ function posterminalErrorStatus(error) {
|
||||
return 500;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* Registers posterminal routes for the authenticated user's selected company.
|
||||
* @param {import('express').Application} app
|
||||
@@ -80,6 +84,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region GET /posterminal
|
||||
|
||||
app.get(`${basePath}/posterminal`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -96,6 +102,8 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /posterminal:
|
||||
@@ -161,6 +169,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region PUT /posterminal
|
||||
|
||||
app.put(`${basePath}/posterminal`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -196,6 +206,8 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /posterminal/{id}:
|
||||
@@ -269,6 +281,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region PATCH /posterminal/:id
|
||||
|
||||
app.patch(`${basePath}/posterminal/:id`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -312,6 +326,8 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /posterminal/{id}:
|
||||
@@ -356,6 +372,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region DELETE /posterminal/:id
|
||||
|
||||
app.delete(`${basePath}/posterminal/:id`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -377,6 +395,8 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /posterminal/{id}/category/{categoryId}:
|
||||
@@ -493,6 +513,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region PUT /posterminal/:id/category/:categoryId
|
||||
|
||||
app.put(`${basePath}/posterminal/:id/category/:categoryId`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -519,6 +541,10 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region DELETE /posterminal/:id/category/:categoryId
|
||||
|
||||
app.delete(`${basePath}/posterminal/:id/category/:categoryId`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -545,6 +571,8 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /posterminal/{id}/all:
|
||||
@@ -653,6 +681,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region PUT /posterminal/:id/all
|
||||
|
||||
app.put(`${basePath}/posterminal/:id/all`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -674,6 +704,10 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region DELETE /posterminal/:id/all
|
||||
|
||||
app.delete(`${basePath}/posterminal/:id/all`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -694,4 +728,6 @@ export function register(app, basePath = '') {
|
||||
res.status(status).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user