mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-09-14 10:52:34 +00:00
Convert backend to ESM
- About 5 years overdue - Remove eslint, use bomejs instead
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
const express = require('express');
|
||||
const validator = require('../lib/validator');
|
||||
const jwtdecode = require('../lib/express/jwt-decode');
|
||||
const apiValidator = require('../lib/validator/api');
|
||||
const internalSetting = require('../internal/setting');
|
||||
const schema = require('../schema');
|
||||
import express from "express";
|
||||
import internalSetting from "../internal/setting.js";
|
||||
import jwtdecode from "../lib/express/jwt-decode.js";
|
||||
import apiValidator from "../lib/validator/api.js";
|
||||
import validator from "../lib/validator/index.js";
|
||||
import { getValidationSchema } from "../schema/index.js";
|
||||
|
||||
let router = express.Router({
|
||||
const router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
strict: true,
|
||||
mergeParams: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* /api/settings
|
||||
*/
|
||||
router
|
||||
.route('/')
|
||||
.route("/")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -27,10 +27,10 @@ router
|
||||
* Retrieve all settings
|
||||
*/
|
||||
.get((_, res, next) => {
|
||||
internalSetting.getAll(res.locals.access)
|
||||
internalSetting
|
||||
.getAll(res.locals.access)
|
||||
.then((rows) => {
|
||||
res.status(200)
|
||||
.send(rows);
|
||||
res.status(200).send(rows);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -41,7 +41,7 @@ router
|
||||
* /api/settings/something
|
||||
*/
|
||||
router
|
||||
.route('/:setting_id')
|
||||
.route("/:setting_id")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -53,26 +53,28 @@ router
|
||||
* Retrieve a specific setting
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['setting_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
setting_id: {
|
||||
type: 'string',
|
||||
minLength: 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
setting_id: req.params.setting_id
|
||||
})
|
||||
validator(
|
||||
{
|
||||
required: ["setting_id"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
setting_id: {
|
||||
type: "string",
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
setting_id: req.params.setting_id,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalSetting.get(res.locals.access, {
|
||||
id: data.setting_id
|
||||
id: data.setting_id,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -83,16 +85,15 @@ router
|
||||
* Update and existing setting
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/settings/{settingID}', 'put'), req.body)
|
||||
apiValidator(getValidationSchema("/settings/{settingID}", "put"), req.body)
|
||||
.then((payload) => {
|
||||
payload.id = req.params.setting_id;
|
||||
return internalSetting.update(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
export default router;
|
||||
|
Reference in New Issue
Block a user