mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-04 08:23:37 +00:00
update nginx/dep updates/fix eslint/change line endings
Signed-off-by: Zoey <zoey@z0ey.de>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const internalAccessList = require('../../../internal/access-list');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
|
||||
let router = express.Router({
|
||||
const router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
strict: true,
|
||||
mergeParams: true,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -26,26 +26,28 @@ router
|
||||
* Retrieve all access-lists
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/query',
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/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);
|
||||
})
|
||||
@@ -56,13 +58,12 @@ router
|
||||
* Create a new access-list
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/access-lists#/links/1/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/access-lists#/links/1/schema' }, 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);
|
||||
});
|
||||
@@ -85,30 +86,32 @@ router
|
||||
* Retrieve a specific access-list
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['list_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
list_id: {
|
||||
$ref: 'definitions#/definitions/id'
|
||||
validator(
|
||||
{
|
||||
required: ['list_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
list_id: {
|
||||
$ref: 'definitions#/definitions/id',
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/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: parseInt(data.list_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -119,14 +122,13 @@ router
|
||||
* Update and existing access-list
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/access-lists#/links/2/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/access-lists#/links/2/schema' }, req.body)
|
||||
.then((payload) => {
|
||||
payload.id = 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);
|
||||
})
|
||||
@@ -137,10 +139,10 @@ 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: parseInt(req.params.list_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
@@ -1,13 +1,13 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const internalCertificate = require('../../../internal/certificate');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
|
||||
let router = express.Router({
|
||||
const router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
strict: true,
|
||||
mergeParams: true,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -26,26 +26,28 @@ router
|
||||
* Retrieve all certificates
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/query',
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/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);
|
||||
})
|
||||
@@ -56,14 +58,13 @@ router
|
||||
* Create a new certificate
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/certificates#/links/1/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/certificates#/links/1/schema' }, 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);
|
||||
});
|
||||
@@ -80,16 +81,16 @@ router
|
||||
})
|
||||
.all(jwtdecode())
|
||||
|
||||
/**
|
||||
* GET /api/nginx/certificates/test-http
|
||||
*
|
||||
* Test HTTP challenge for domains
|
||||
*/
|
||||
/**
|
||||
* GET /api/nginx/certificates/test-http
|
||||
*
|
||||
* Test HTTP challenge for domains
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
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);
|
||||
});
|
||||
@@ -112,30 +113,32 @@ router
|
||||
* Retrieve a specific certificate
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['certificate_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
certificate_id: {
|
||||
$ref: 'definitions#/definitions/id'
|
||||
validator(
|
||||
{
|
||||
required: ['certificate_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
certificate_id: {
|
||||
$ref: 'definitions#/definitions/id',
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/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: parseInt(data.certificate_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -146,14 +149,13 @@ router
|
||||
* Update and existing certificate
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/certificates#/links/2/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/certificates#/links/2/schema' }, req.body)
|
||||
.then((payload) => {
|
||||
payload.id = parseInt(req.params.certificate_id, 10);
|
||||
return internalCertificate.update(res.locals.access, payload);
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -164,10 +166,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: parseInt(req.params.certificate_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -191,16 +193,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: parseInt(req.params.certificate_id, 10),
|
||||
files: req.files,
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
}
|
||||
@@ -225,12 +226,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: parseInt(req.params.certificate_id, 10),
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -253,12 +254,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: parseInt(req.params.certificate_id, 10),
|
||||
})
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.download(result.fileName);
|
||||
res.status(200).download(result.fileName);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -282,15 +283,14 @@ 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);
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const internalDeadHost = require('../../../internal/dead-host');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
|
||||
let router = express.Router({
|
||||
const router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
strict: true,
|
||||
mergeParams: true,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -26,26 +26,28 @@ router
|
||||
* Retrieve all dead-hosts
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/query',
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/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);
|
||||
})
|
||||
@@ -56,13 +58,12 @@ router
|
||||
* Create a new dead-host
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/dead-hosts#/links/1/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/dead-hosts#/links/1/schema' }, 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);
|
||||
});
|
||||
@@ -85,30 +86,32 @@ router
|
||||
* Retrieve a specific dead-host
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'definitions#/definitions/id'
|
||||
validator(
|
||||
{
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'definitions#/definitions/id',
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/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: parseInt(data.host_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -119,14 +122,13 @@ router
|
||||
* Update and existing dead-host
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/dead-hosts#/links/2/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/dead-hosts#/links/2/schema' }, req.body)
|
||||
.then((payload) => {
|
||||
payload.id = 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);
|
||||
})
|
||||
@@ -137,10 +139,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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -161,10 +163,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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -185,10 +187,10 @@ 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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
@@ -1,13 +1,13 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const internalProxyHost = require('../../../internal/proxy-host');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
|
||||
let router = express.Router({
|
||||
const router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
strict: true,
|
||||
mergeParams: true,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -26,26 +26,28 @@ router
|
||||
* Retrieve all proxy-hosts
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/query',
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/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);
|
||||
})
|
||||
@@ -56,13 +58,12 @@ router
|
||||
* Create a new proxy-host
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/proxy-hosts#/links/1/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/proxy-hosts#/links/1/schema' }, 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);
|
||||
});
|
||||
@@ -85,30 +86,32 @@ router
|
||||
* Retrieve a specific proxy-host
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'definitions#/definitions/id'
|
||||
validator(
|
||||
{
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'definitions#/definitions/id',
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/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: parseInt(data.host_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -119,14 +122,13 @@ router
|
||||
* Update and existing proxy-host
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/proxy-hosts#/links/2/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/proxy-hosts#/links/2/schema' }, req.body)
|
||||
.then((payload) => {
|
||||
payload.id = 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);
|
||||
})
|
||||
@@ -137,10 +139,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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -161,10 +163,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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -185,10 +187,10 @@ 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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
@@ -1,13 +1,13 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const internalRedirectionHost = require('../../../internal/redirection-host');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
|
||||
let router = express.Router({
|
||||
const router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
strict: true,
|
||||
mergeParams: true,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -26,26 +26,28 @@ router
|
||||
* Retrieve all redirection-hosts
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/query',
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/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);
|
||||
})
|
||||
@@ -56,13 +58,12 @@ router
|
||||
* Create a new redirection-host
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/redirection-hosts#/links/1/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/redirection-hosts#/links/1/schema' }, 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);
|
||||
});
|
||||
@@ -85,30 +86,32 @@ router
|
||||
* Retrieve a specific redirection-host
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'definitions#/definitions/id'
|
||||
validator(
|
||||
{
|
||||
required: ['host_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
host_id: {
|
||||
$ref: 'definitions#/definitions/id',
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/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: parseInt(data.host_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -119,14 +122,13 @@ router
|
||||
* Update and existing redirection-host
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/redirection-hosts#/links/2/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/redirection-hosts#/links/2/schema' }, req.body)
|
||||
.then((payload) => {
|
||||
payload.id = 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);
|
||||
})
|
||||
@@ -137,10 +139,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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -161,10 +163,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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -185,10 +187,10 @@ 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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
@@ -1,13 +1,13 @@
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const express = require('express');
|
||||
const validator = require('../../../lib/validator');
|
||||
const jwtdecode = require('../../../lib/express/jwt-decode');
|
||||
const internalStream = require('../../../internal/stream');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
const apiValidator = require('../../../lib/validator/api');
|
||||
|
||||
let router = express.Router({
|
||||
const router = express.Router({
|
||||
caseSensitive: true,
|
||||
strict: true,
|
||||
mergeParams: true
|
||||
strict: true,
|
||||
mergeParams: true,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -26,26 +26,28 @@ router
|
||||
* Retrieve all streams
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand'
|
||||
validator(
|
||||
{
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/query',
|
||||
},
|
||||
},
|
||||
query: {
|
||||
$ref: 'definitions#/definitions/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);
|
||||
})
|
||||
@@ -56,13 +58,12 @@ router
|
||||
* Create a new stream
|
||||
*/
|
||||
.post((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/streams#/links/1/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/streams#/links/1/schema' }, 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);
|
||||
});
|
||||
@@ -85,30 +86,32 @@ router
|
||||
* Retrieve a specific stream
|
||||
*/
|
||||
.get((req, res, next) => {
|
||||
validator({
|
||||
required: ['stream_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
stream_id: {
|
||||
$ref: 'definitions#/definitions/id'
|
||||
validator(
|
||||
{
|
||||
required: ['stream_id'],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
stream_id: {
|
||||
$ref: 'definitions#/definitions/id',
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/expand',
|
||||
},
|
||||
},
|
||||
expand: {
|
||||
$ref: 'definitions#/definitions/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: parseInt(data.stream_id, 10),
|
||||
expand: data.expand,
|
||||
});
|
||||
})
|
||||
.then((row) => {
|
||||
res.status(200)
|
||||
.send(row);
|
||||
res.status(200).send(row);
|
||||
})
|
||||
.catch(next);
|
||||
})
|
||||
@@ -119,14 +122,13 @@ router
|
||||
* Update and existing stream
|
||||
*/
|
||||
.put((req, res, next) => {
|
||||
apiValidator({$ref: 'endpoints/streams#/links/2/schema'}, req.body)
|
||||
apiValidator({ $ref: 'endpoints/streams#/links/2/schema' }, req.body)
|
||||
.then((payload) => {
|
||||
payload.id = 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);
|
||||
})
|
||||
@@ -137,10 +139,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: parseInt(req.params.stream_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -161,10 +163,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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
@@ -185,10 +187,10 @@ 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: parseInt(req.params.host_id, 10) })
|
||||
.then((result) => {
|
||||
res.status(200)
|
||||
.send(result);
|
||||
res.status(200).send(result);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
|
Reference in New Issue
Block a user