update nginx/dep updates/fix eslint/change line endings

Signed-off-by: Zoey <zoey@z0ey.de>
This commit is contained in:
Zoey
2024-03-25 18:24:21 +01:00
parent ef5ac4cbd8
commit 906d7ce04a
96 changed files with 2579 additions and 2859 deletions

View File

@@ -1,14 +1,14 @@
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 userIdFromMe = require('../../lib/express/user-id-from-me');
const internalUser = require('../../internal/user');
const apiValidator = require('../../lib/validator/api');
let router = express.Router({
const router = express.Router({
caseSensitive: true,
strict: true,
mergeParams: true
strict: true,
mergeParams: true,
});
/**
@@ -27,26 +27,28 @@ router
* Retrieve all users
*/
.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 internalUser.getAll(res.locals.access, data.expand, data.query);
})
.then((users) => {
res.status(200)
.send(users);
res.status(200).send(users);
})
.catch(next);
})
@@ -57,13 +59,12 @@ router
* Create a new User
*/
.post((req, res, next) => {
apiValidator({$ref: 'endpoints/users#/links/1/schema'}, req.body)
apiValidator({ $ref: 'endpoints/users#/links/1/schema' }, req.body)
.then((payload) => {
return internalUser.create(res.locals.access, payload);
})
.then((result) => {
res.status(201)
.send(result);
res.status(201).send(result);
})
.catch(next);
});
@@ -87,31 +88,33 @@ router
* Retrieve a specific user
*/
.get((req, res, next) => {
validator({
required: ['user_id'],
additionalProperties: false,
properties: {
user_id: {
$ref: 'definitions#/definitions/id'
validator(
{
required: ['user_id'],
additionalProperties: false,
properties: {
user_id: {
$ref: 'definitions#/definitions/id',
},
expand: {
$ref: 'definitions#/definitions/expand',
},
},
expand: {
$ref: 'definitions#/definitions/expand'
}
}
}, {
user_id: req.params.user_id,
expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null)
})
},
{
user_id: req.params.user_id,
expand: typeof req.query.expand === 'string' ? req.query.expand.split(',') : null,
},
)
.then((data) => {
return internalUser.get(res.locals.access, {
id: data.user_id,
id: data.user_id,
expand: data.expand,
omit: internalUser.getUserOmisionsByAccess(res.locals.access, data.user_id)
omit: internalUser.getUserOmisionsByAccess(res.locals.access, data.user_id),
});
})
.then((user) => {
res.status(200)
.send(user);
res.status(200).send(user);
})
.catch(next);
})
@@ -122,14 +125,13 @@ router
* Update and existing user
*/
.put((req, res, next) => {
apiValidator({$ref: 'endpoints/users#/links/2/schema'}, req.body)
apiValidator({ $ref: 'endpoints/users#/links/2/schema' }, req.body)
.then((payload) => {
payload.id = req.params.user_id;
return internalUser.update(res.locals.access, payload);
})
.then((result) => {
res.status(200)
.send(result);
res.status(200).send(result);
})
.catch(next);
})
@@ -140,10 +142,10 @@ router
* Update and existing user
*/
.delete((req, res, next) => {
internalUser.delete(res.locals.access, {id: req.params.user_id})
internalUser
.delete(res.locals.access, { id: req.params.user_id })
.then((result) => {
res.status(200)
.send(result);
res.status(200).send(result);
})
.catch(next);
});
@@ -167,14 +169,13 @@ router
* Update password for a user
*/
.put((req, res, next) => {
apiValidator({$ref: 'endpoints/users#/links/4/schema'}, req.body)
apiValidator({ $ref: 'endpoints/users#/links/4/schema' }, req.body)
.then((payload) => {
payload.id = req.params.user_id;
return internalUser.setPassword(res.locals.access, payload);
})
.then((result) => {
res.status(201)
.send(result);
res.status(201).send(result);
})
.catch(next);
});
@@ -198,14 +199,13 @@ router
* Set some or all permissions for a user
*/
.put((req, res, next) => {
apiValidator({$ref: 'endpoints/users#/links/5/schema'}, req.body)
apiValidator({ $ref: 'endpoints/users#/links/5/schema' }, req.body)
.then((payload) => {
payload.id = req.params.user_id;
return internalUser.setPermissions(res.locals.access, payload);
})
.then((result) => {
res.status(201)
.send(result);
res.status(201).send(result);
})
.catch(next);
});
@@ -228,10 +228,10 @@ router
* Log in as a user
*/
.post((req, res, next) => {
internalUser.loginAs(res.locals.access, {id: parseInt(req.params.user_id, 10)})
internalUser
.loginAs(res.locals.access, { id: parseInt(req.params.user_id, 10) })
.then((result) => {
res.status(201)
.send(result);
res.status(201).send(result);
})
.catch(next);
});