mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-09-14 19:02:35 +00:00
Convert backend to ESM
- About 5 years overdue - Remove eslint, use bomejs instead
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../lib/validator');
|
||||
const jwtdecode = require('../../lib/express/jwt-decode');
|
||||
const apiValidator = require('../../lib/validator/api');
|
||||
const internalAccessList = require('../../internal/access-list');
|
||||
const schema = require('../../schema');
|
||||
import express from "express";
|
||||
import internalAccessList from "../../internal/access-list.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/nginx/access-lists
|
||||
*/
|
||||
router
|
||||
.route('/')
|
||||
.options((req, res) => {
|
||||
.route("/")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
@@ -27,26 +27,28 @@ router
|
||||
* Retrieve all access-lists
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
query: {
|
||||
$ref: "common#/properties/query",
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'common#/properties/query'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null),
|
||||
query: (typeof req.query.query === 'string' ? req.query.query : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
query: typeof req.query.query === "string" ? req.query.query : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalAccessList.getAll(res.locals.access, data.expand, data.query);
|
||||
})
|
||||
.then((rows) => {
|
||||
res.status(200)
|
||||
.send(rows);
|
||||
res.status(200).send(rows);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -57,13 +59,12 @@ router
|
||||
* Create a new access-list
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/access-lists', 'post'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/access-lists", "post"), req.body)
|
||||
.then((payload) => {
|
||||
return internalAccessList.create(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(201)
|
||||
.send(result);
|
||||
res.status(201).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -74,7 +75,7 @@ router
|
||||
* /api/nginx/access-lists/123
|
||||
*/
|
||||
router
|
||||
.route('/:list_id')
|
||||
.route("/:list_id")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -86,30 +87,32 @@ router
|
||||
* Retrieve a specific access-list
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['list_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
list_id: {
|
||||
$ref: 'common#/properties/id'
|
||||
validator(
|
||||
{
|
||||
required: ["list_id"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
list_id: {
|
||||
$ref: "common#/properties/id",
|
||||
},
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
list_id: req.params.list_id,
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
list_id: req.params.list_id,
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalAccessList.get(res.locals.access, {
|
||||
id: parseInt(data.list_id, 10),
|
||||
expand: data.expand
|
||||
id: Number.parseInt(data.list_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -120,14 +123,13 @@ router
|
||||
* Update and existing access-list
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/access-lists/{listID}', 'put'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/access-lists/{listID}", "put"), req.body)
|
||||
.then((payload) => {
|
||||
payload.id = parseInt(req.params.list_id, 10);
|
||||
payload.id = Number.parseInt(req.params.list_id, 10);
|
||||
return internalAccessList.update(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -138,12 +140,12 @@ router
|
||||
* Delete and existing access-list
|
||||
*/
|
||||
.delete((req, res, next) => {
|
||||
internalAccessList.delete(res.locals.access, {id: parseInt(req.params.list_id, 10)})
|
||||
internalAccessList
|
||||
.delete(res.locals.access, { id: Number.parseInt(req.params.list_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
export default router;
|
||||
|
@@ -1,22 +1,22 @@
|
||||
const express = require('express');
|
||||
const error = require('../../lib/error');
|
||||
const validator = require('../../lib/validator');
|
||||
const jwtdecode = require('../../lib/express/jwt-decode');
|
||||
const apiValidator = require('../../lib/validator/api');
|
||||
const internalCertificate = require('../../internal/certificate');
|
||||
const schema = require('../../schema');
|
||||
import express from "express";
|
||||
import internalCertificate from "../../internal/certificate.js";
|
||||
import errs from "../../lib/error.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";
|
||||
|
||||
const router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
strict: true,
|
||||
mergeParams: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* /api/nginx/certificates
|
||||
*/
|
||||
router
|
||||
.route('/')
|
||||
.route("/")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -28,26 +28,28 @@ router
|
||||
* Retrieve all certificates
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
query: {
|
||||
$ref: "common#/properties/query",
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'common#/properties/query'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null),
|
||||
query: (typeof req.query.query === 'string' ? req.query.query : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
query: typeof req.query.query === "string" ? req.query.query : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalCertificate.getAll(res.locals.access, data.expand, data.query);
|
||||
})
|
||||
.then((rows) => {
|
||||
res.status(200)
|
||||
.send(rows);
|
||||
res.status(200).send(rows);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -58,14 +60,13 @@ router
|
||||
* Create a new certificate
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/certificates', 'post'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/certificates", "post"), req.body)
|
||||
.then((payload) => {
|
||||
req.setTimeout(900000); // 15 minutes timeout
|
||||
return internalCertificate.create(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(201)
|
||||
.send(result);
|
||||
res.status(201).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -76,7 +77,7 @@ router
|
||||
* /api/nginx/certificates/test-http
|
||||
*/
|
||||
router
|
||||
.route('/test-http')
|
||||
.route("/test-http")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -89,14 +90,14 @@ router
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
if (req.query.domains === undefined) {
|
||||
next(new error.ValidationError('Domains are required as query parameters'));
|
||||
next(new errs.ValidationError("Domains are required as query parameters"));
|
||||
return;
|
||||
}
|
||||
|
||||
internalCertificate.testHttpsChallenge(res.locals.access, JSON.parse(req.query.domains))
|
||||
internalCertificate
|
||||
.testHttpsChallenge(res.locals.access, JSON.parse(req.query.domains))
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -107,7 +108,7 @@ router
|
||||
* /api/nginx/certificates/123
|
||||
*/
|
||||
router
|
||||
.route('/:certificate_id')
|
||||
.route("/:certificate_id")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -119,30 +120,32 @@ router
|
||||
* Retrieve a specific certificate
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['certificate_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
certificate_id: {
|
||||
$ref: 'common#/properties/id'
|
||||
validator(
|
||||
{
|
||||
required: ["certificate_id"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
certificate_id: {
|
||||
$ref: "common#/properties/id",
|
||||
},
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
certificate_id: req.params.certificate_id,
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
certificate_id: req.params.certificate_id,
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalCertificate.get(res.locals.access, {
|
||||
id: parseInt(data.certificate_id, 10),
|
||||
expand: data.expand
|
||||
id: Number.parseInt(data.certificate_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -153,10 +156,10 @@ router
|
||||
* Update and existing certificate
|
||||
*/
|
||||
.delete((req, res, next) => {
|
||||
internalCertificate.delete(res.locals.access, {id: parseInt(req.params.certificate_id, 10)})
|
||||
internalCertificate
|
||||
.delete(res.locals.access, { id: Number.parseInt(req.params.certificate_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -167,7 +170,7 @@ router
|
||||
* /api/nginx/certificates/123/upload
|
||||
*/
|
||||
router
|
||||
.route('/:certificate_id/upload')
|
||||
.route("/:certificate_id/upload")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -180,16 +183,15 @@ router
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
if (!req.files) {
|
||||
res.status(400)
|
||||
.send({error: 'No files were uploaded'});
|
||||
res.status(400).send({ error: "No files were uploaded" });
|
||||
} else {
|
||||
internalCertificate.upload(res.locals.access, {
|
||||
id: parseInt(req.params.certificate_id, 10),
|
||||
files: req.files
|
||||
})
|
||||
internalCertificate
|
||||
.upload(res.locals.access, {
|
||||
id: Number.parseInt(req.params.certificate_id, 10),
|
||||
files: req.files,
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
}
|
||||
@@ -201,7 +203,7 @@ router
|
||||
* /api/nginx/certificates/123/renew
|
||||
*/
|
||||
router
|
||||
.route('/:certificate_id/renew')
|
||||
.route("/:certificate_id/renew")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -214,12 +216,12 @@ router
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
req.setTimeout(900000); // 15 minutes timeout
|
||||
internalCertificate.renew(res.locals.access, {
|
||||
id: parseInt(req.params.certificate_id, 10)
|
||||
})
|
||||
internalCertificate
|
||||
.renew(res.locals.access, {
|
||||
id: Number.parseInt(req.params.certificate_id, 10),
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -230,7 +232,7 @@ router
|
||||
* /api/nginx/certificates/123/download
|
||||
*/
|
||||
router
|
||||
.route('/:certificate_id/download')
|
||||
.route("/:certificate_id/download")
|
||||
.options((_req, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -242,12 +244,12 @@ router
|
||||
* Renew certificate
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
internalCertificate.download(res.locals.access, {
|
||||
id: parseInt(req.params.certificate_id, 10)
|
||||
})
|
||||
internalCertificate
|
||||
.download(res.locals.access, {
|
||||
id: Number.parseInt(req.params.certificate_id, 10),
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.download(result.fileName);
|
||||
res.status(200).download(result.fileName);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -258,7 +260,7 @@ router
|
||||
* /api/nginx/certificates/validate
|
||||
*/
|
||||
router
|
||||
.route('/validate')
|
||||
.route("/validate")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -271,18 +273,17 @@ router
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
if (!req.files) {
|
||||
res.status(400)
|
||||
.send({error: 'No files were uploaded'});
|
||||
res.status(400).send({ error: "No files were uploaded" });
|
||||
} else {
|
||||
internalCertificate.validate({
|
||||
files: req.files
|
||||
})
|
||||
internalCertificate
|
||||
.validate({
|
||||
files: req.files,
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
export default router;
|
||||
|
@@ -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 internalDeadHost = require('../../internal/dead-host');
|
||||
const schema = require('../../schema');
|
||||
import express from "express";
|
||||
import internalDeadHost from "../../internal/dead-host.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/nginx/dead-hosts
|
||||
*/
|
||||
router
|
||||
.route('/')
|
||||
.route("/")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -27,26 +27,28 @@ router
|
||||
* Retrieve all dead-hosts
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
query: {
|
||||
$ref: "common#/properties/query",
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'common#/properties/query'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null),
|
||||
query: (typeof req.query.query === 'string' ? req.query.query : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
query: typeof req.query.query === "string" ? req.query.query : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalDeadHost.getAll(res.locals.access, data.expand, data.query);
|
||||
})
|
||||
.then((rows) => {
|
||||
res.status(200)
|
||||
.send(rows);
|
||||
res.status(200).send(rows);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -57,13 +59,12 @@ router
|
||||
* Create a new dead-host
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/dead-hosts', 'post'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/dead-hosts", "post"), req.body)
|
||||
.then((payload) => {
|
||||
return internalDeadHost.create(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(201)
|
||||
.send(result);
|
||||
res.status(201).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -74,8 +75,8 @@ router
|
||||
* /api/nginx/dead-hosts/123
|
||||
*/
|
||||
router
|
||||
.route('/:host_id')
|
||||
.options((req, res) => {
|
||||
.route("/:host_id")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
@@ -86,30 +87,32 @@ router
|
||||
* Retrieve a specific dead-host
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'common#/properties/id'
|
||||
validator(
|
||||
{
|
||||
required: ["host_id"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: "common#/properties/id",
|
||||
},
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
host_id: req.params.host_id,
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
host_id: req.params.host_id,
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalDeadHost.get(res.locals.access, {
|
||||
id: parseInt(data.host_id, 10),
|
||||
expand: data.expand
|
||||
id: Number.parseInt(data.host_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -120,14 +123,13 @@ router
|
||||
* Update and existing dead-host
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/dead-hosts/{hostID}', 'put'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/dead-hosts/{hostID}", "put"), req.body)
|
||||
.then((payload) => {
|
||||
payload.id = parseInt(req.params.host_id, 10);
|
||||
payload.id = Number.parseInt(req.params.host_id, 10);
|
||||
return internalDeadHost.update(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -138,10 +140,10 @@ router
|
||||
* Update and existing dead-host
|
||||
*/
|
||||
.delete((req, res, next) => {
|
||||
internalDeadHost.delete(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalDeadHost
|
||||
.delete(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -152,7 +154,7 @@ router
|
||||
* /api/nginx/dead-hosts/123/enable
|
||||
*/
|
||||
router
|
||||
.route('/:host_id/enable')
|
||||
.route("/:host_id/enable")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -162,10 +164,10 @@ router
|
||||
* POST /api/nginx/dead-hosts/123/enable
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
internalDeadHost.enable(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalDeadHost
|
||||
.enable(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -176,7 +178,7 @@ router
|
||||
* /api/nginx/dead-hosts/123/disable
|
||||
*/
|
||||
router
|
||||
.route('/:host_id/disable')
|
||||
.route("/:host_id/disable")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -186,12 +188,12 @@ router
|
||||
* POST /api/nginx/dead-hosts/123/disable
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
internalDeadHost.disable(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalDeadHost
|
||||
.disable(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
export default router;
|
||||
|
@@ -1,22 +1,22 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../lib/validator');
|
||||
const jwtdecode = require('../../lib/express/jwt-decode');
|
||||
const apiValidator = require('../../lib/validator/api');
|
||||
const internalProxyHost = require('../../internal/proxy-host');
|
||||
const schema = require('../../schema');
|
||||
import express from "express";
|
||||
import internalProxyHost from "../../internal/proxy-host.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/nginx/proxy-hosts
|
||||
*/
|
||||
router
|
||||
.route('/')
|
||||
.options((req, res) => {
|
||||
.route("/")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
@@ -27,26 +27,28 @@ router
|
||||
* Retrieve all proxy-hosts
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
query: {
|
||||
$ref: "common#/properties/query",
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'common#/properties/query'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null),
|
||||
query: (typeof req.query.query === 'string' ? req.query.query : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
query: typeof req.query.query === "string" ? req.query.query : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalProxyHost.getAll(res.locals.access, data.expand, data.query);
|
||||
})
|
||||
.then((rows) => {
|
||||
res.status(200)
|
||||
.send(rows);
|
||||
res.status(200).send(rows);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -57,13 +59,12 @@ router
|
||||
* Create a new proxy-host
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/proxy-hosts', 'post'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/proxy-hosts", "post"), req.body)
|
||||
.then((payload) => {
|
||||
return internalProxyHost.create(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(201)
|
||||
.send(result);
|
||||
res.status(201).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -74,8 +75,8 @@ router
|
||||
* /api/nginx/proxy-hosts/123
|
||||
*/
|
||||
router
|
||||
.route('/:host_id')
|
||||
.options((req, res) => {
|
||||
.route("/:host_id")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
@@ -86,30 +87,32 @@ router
|
||||
* Retrieve a specific proxy-host
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'common#/properties/id'
|
||||
validator(
|
||||
{
|
||||
required: ["host_id"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: "common#/properties/id",
|
||||
},
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
host_id: req.params.host_id,
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
host_id: req.params.host_id,
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalProxyHost.get(res.locals.access, {
|
||||
id: parseInt(data.host_id, 10),
|
||||
expand: data.expand
|
||||
id: Number.parseInt(data.host_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -120,14 +123,13 @@ router
|
||||
* Update and existing proxy-host
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/proxy-hosts/{hostID}', 'put'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/proxy-hosts/{hostID}", "put"), req.body)
|
||||
.then((payload) => {
|
||||
payload.id = parseInt(req.params.host_id, 10);
|
||||
payload.id = Number.parseInt(req.params.host_id, 10);
|
||||
return internalProxyHost.update(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -138,10 +140,10 @@ router
|
||||
* Update and existing proxy-host
|
||||
*/
|
||||
.delete((req, res, next) => {
|
||||
internalProxyHost.delete(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalProxyHost
|
||||
.delete(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -152,7 +154,7 @@ router
|
||||
* /api/nginx/proxy-hosts/123/enable
|
||||
*/
|
||||
router
|
||||
.route('/:host_id/enable')
|
||||
.route("/:host_id/enable")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -162,10 +164,10 @@ router
|
||||
* POST /api/nginx/proxy-hosts/123/enable
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
internalProxyHost.enable(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalProxyHost
|
||||
.enable(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -176,7 +178,7 @@ router
|
||||
* /api/nginx/proxy-hosts/123/disable
|
||||
*/
|
||||
router
|
||||
.route('/:host_id/disable')
|
||||
.route("/:host_id/disable")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -186,12 +188,12 @@ router
|
||||
* POST /api/nginx/proxy-hosts/123/disable
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
internalProxyHost.disable(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalProxyHost
|
||||
.disable(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
export default router;
|
||||
|
@@ -1,22 +1,22 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../lib/validator');
|
||||
const jwtdecode = require('../../lib/express/jwt-decode');
|
||||
const apiValidator = require('../../lib/validator/api');
|
||||
const internalRedirectionHost = require('../../internal/redirection-host');
|
||||
const schema = require('../../schema');
|
||||
import express from "express";
|
||||
import internalRedirectionHost from "../../internal/redirection-host.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/nginx/redirection-hosts
|
||||
*/
|
||||
router
|
||||
.route('/')
|
||||
.options((req, res) => {
|
||||
.route("/")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
@@ -27,26 +27,28 @@ router
|
||||
* Retrieve all redirection-hosts
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
query: {
|
||||
$ref: "common#/properties/query",
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'common#/properties/query'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null),
|
||||
query: (typeof req.query.query === 'string' ? req.query.query : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
query: typeof req.query.query === "string" ? req.query.query : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalRedirectionHost.getAll(res.locals.access, data.expand, data.query);
|
||||
})
|
||||
.then((rows) => {
|
||||
res.status(200)
|
||||
.send(rows);
|
||||
res.status(200).send(rows);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -57,13 +59,12 @@ router
|
||||
* Create a new redirection-host
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/redirection-hosts', 'post'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/redirection-hosts", "post"), req.body)
|
||||
.then((payload) => {
|
||||
return internalRedirectionHost.create(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(201)
|
||||
.send(result);
|
||||
res.status(201).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -74,8 +75,8 @@ router
|
||||
* /api/nginx/redirection-hosts/123
|
||||
*/
|
||||
router
|
||||
.route('/:host_id')
|
||||
.options((req, res) => {
|
||||
.route("/:host_id")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
@@ -86,30 +87,32 @@ router
|
||||
* Retrieve a specific redirection-host
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'common#/properties/id'
|
||||
validator(
|
||||
{
|
||||
required: ["host_id"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: "common#/properties/id",
|
||||
},
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
host_id: req.params.host_id,
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
host_id: req.params.host_id,
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalRedirectionHost.get(res.locals.access, {
|
||||
id: parseInt(data.host_id, 10),
|
||||
expand: data.expand
|
||||
id: Number.parseInt(data.host_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -120,14 +123,13 @@ router
|
||||
* Update and existing redirection-host
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/redirection-hosts/{hostID}', 'put'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/redirection-hosts/{hostID}", "put"), req.body)
|
||||
.then((payload) => {
|
||||
payload.id = parseInt(req.params.host_id, 10);
|
||||
payload.id = Number.parseInt(req.params.host_id, 10);
|
||||
return internalRedirectionHost.update(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -138,10 +140,10 @@ router
|
||||
* Update and existing redirection-host
|
||||
*/
|
||||
.delete((req, res, next) => {
|
||||
internalRedirectionHost.delete(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalRedirectionHost
|
||||
.delete(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -152,8 +154,8 @@ router
|
||||
* /api/nginx/redirection-hosts/123/enable
|
||||
*/
|
||||
router
|
||||
.route('/:host_id/enable')
|
||||
.options((req, res) => {
|
||||
.route("/:host_id/enable")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
@@ -162,10 +164,10 @@ router
|
||||
* POST /api/nginx/redirection-hosts/123/enable
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
internalRedirectionHost.enable(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalRedirectionHost
|
||||
.enable(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -176,8 +178,8 @@ router
|
||||
* /api/nginx/redirection-hosts/123/disable
|
||||
*/
|
||||
router
|
||||
.route('/:host_id/disable')
|
||||
.options((req, res) => {
|
||||
.route("/:host_id/disable")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
@@ -186,12 +188,12 @@ router
|
||||
* POST /api/nginx/redirection-hosts/123/disable
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
internalRedirectionHost.disable(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalRedirectionHost
|
||||
.disable(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
export default router;
|
||||
|
@@ -1,22 +1,22 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../lib/validator');
|
||||
const jwtdecode = require('../../lib/express/jwt-decode');
|
||||
const apiValidator = require('../../lib/validator/api');
|
||||
const internalStream = require('../../internal/stream');
|
||||
const schema = require('../../schema');
|
||||
import express from "express";
|
||||
import internalStream from "../../internal/stream.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/nginx/streams
|
||||
*/
|
||||
router
|
||||
.route('/')
|
||||
.options((req, res) => {
|
||||
.route("/")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode()) // preferred so it doesn't apply to nonexistent routes
|
||||
@@ -27,26 +27,28 @@ router
|
||||
* Retrieve all streams
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
query: {
|
||||
$ref: "common#/properties/query",
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'common#/properties/query'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null),
|
||||
query: (typeof req.query.query === 'string' ? req.query.query : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
query: typeof req.query.query === "string" ? req.query.query : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalStream.getAll(res.locals.access, data.expand, data.query);
|
||||
})
|
||||
.then((rows) => {
|
||||
res.status(200)
|
||||
.send(rows);
|
||||
res.status(200).send(rows);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -57,13 +59,12 @@ router
|
||||
* Create a new stream
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/streams', 'post'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/streams", "post"), req.body)
|
||||
.then((payload) => {
|
||||
return internalStream.create(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(201)
|
||||
.send(result);
|
||||
res.status(201).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -74,8 +75,8 @@ router
|
||||
* /api/nginx/streams/123
|
||||
*/
|
||||
router
|
||||
.route('/:stream_id')
|
||||
.options((req, res) => {
|
||||
.route("/:stream_id")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode()) // preferred so it doesn't apply to nonexistent routes
|
||||
@@ -86,30 +87,32 @@ router
|
||||
* Retrieve a specific stream
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['stream_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
stream_id: {
|
||||
$ref: 'common#/properties/id'
|
||||
validator(
|
||||
{
|
||||
required: ["stream_id"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
stream_id: {
|
||||
$ref: "common#/properties/id",
|
||||
},
|
||||
expand: {
|
||||
$ref: "common#/properties/expand",
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'common#/properties/expand'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
stream_id: req.params.stream_id,
|
||||
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
|
||||
})
|
||||
},
|
||||
{
|
||||
stream_id: req.params.stream_id,
|
||||
expand: typeof req.query.expand === "string" ? req.query.expand.split(",") : null,
|
||||
},
|
||||
)
|
||||
.then((data) => {
|
||||
return internalStream.get(res.locals.access, {
|
||||
id: parseInt(data.stream_id, 10),
|
||||
expand: data.expand
|
||||
id: Number.parseInt(data.stream_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -120,14 +123,13 @@ router
|
||||
* Update and existing stream
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator(schema.getValidationSchema('/nginx/streams/{streamID}', 'put'), req.body)
|
||||
apiValidator(getValidationSchema("/nginx/streams/{streamID}", "put"), req.body)
|
||||
.then((payload) => {
|
||||
payload.id = parseInt(req.params.stream_id, 10);
|
||||
payload.id = Number.parseInt(req.params.stream_id, 10);
|
||||
return internalStream.update(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -138,10 +140,10 @@ router
|
||||
* Update and existing stream
|
||||
*/
|
||||
.delete((req, res, next) => {
|
||||
internalStream.delete(res.locals.access, {id: parseInt(req.params.stream_id, 10)})
|
||||
internalStream
|
||||
.delete(res.locals.access, { id: Number.parseInt(req.params.stream_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -152,7 +154,7 @@ router
|
||||
* /api/nginx/streams/123/enable
|
||||
*/
|
||||
router
|
||||
.route('/:host_id/enable')
|
||||
.route("/:host_id/enable")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -162,10 +164,10 @@ router
|
||||
* POST /api/nginx/streams/123/enable
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
internalStream.enable(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalStream
|
||||
.enable(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -176,7 +178,7 @@ router
|
||||
* /api/nginx/streams/123/disable
|
||||
*/
|
||||
router
|
||||
.route('/:host_id/disable')
|
||||
.route("/:host_id/disable")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
@@ -186,12 +188,12 @@ router
|
||||
* POST /api/nginx/streams/123/disable
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
internalStream.disable(res.locals.access, {id: parseInt(req.params.host_id, 10)})
|
||||
internalStream
|
||||
.disable(res.locals.access, { id: Number.parseInt(req.params.host_id, 10) })
|
||||
.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