mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
Fix sqlite middleware
This commit is contained in:
parent
f74069deb6
commit
3697423fda
13
src/http.js
13
src/http.js
@ -6,8 +6,7 @@ const { join } = require('path');
|
||||
const { files } = require('node-dir');
|
||||
|
||||
module.exports = client => {
|
||||
|
||||
// cors plugins
|
||||
// cors plugin
|
||||
fastify.register(require('@fastify/cors'), {
|
||||
credentials: true,
|
||||
methods: ['DELETE', 'GET', 'PATCH', 'PUT', 'POST'],
|
||||
@ -112,13 +111,13 @@ module.exports = client => {
|
||||
: res.statusCode >= 200
|
||||
? '&2'
|
||||
: '&f') + res.statusCode;
|
||||
let response_time = res.getResponseTime().toFixed(2);
|
||||
response_time = (response_time >= 20
|
||||
let responseTime = res.getResponseTime().toFixed(2);
|
||||
responseTime = (responseTime >= 20
|
||||
? '&c'
|
||||
: response_time >= 5
|
||||
: responseTime >= 5
|
||||
? '&e'
|
||||
: '&a') + response_time + 'ms';
|
||||
client.log.info.http(short(`${req.ip} ${req.method} ${req.routerPath ?? '*'} &m-+>&r ${status}&b in ${response_time}`));
|
||||
: '&a') + responseTime + 'ms';
|
||||
client.log.info.http(short(`${req.ip} ${req.method} ${req.routerPath ?? '*'} &m-+>&r ${status}&b in ${responseTime}`));
|
||||
done();
|
||||
});
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
* @license GNU-GPLv3
|
||||
*/
|
||||
|
||||
|
||||
const pkg = require('../package.json');
|
||||
const fs = require('fs');
|
||||
const semver = require('semver');
|
||||
@ -42,7 +41,7 @@ if (!semver.satisfies(process.versions.node, pkg.engines.node)) {
|
||||
}
|
||||
|
||||
if (process.env.ENCRYPTION_KEY === undefined) {
|
||||
console.log('\x07' + colours.redBright('Error: The "ENCRYPTION_KEY" environment variable is not set.\nRun "npm run keygen" to generate a key, or set it to "false" to disable encryption (not recommended).'));
|
||||
console.log('\x07' + colours.redBright('Error: The "ENCRYPTION_KEY" environment variable is not set.\nRun "npm run keygen" to generate a key.'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,16 @@ const traverse = (obj, action) => {
|
||||
prop = 'create';
|
||||
traverse(obj[prop], action);
|
||||
} else if (jsonFields.includes(prop) && obj[prop] !== null && obj[prop] !== undefined) {
|
||||
if (action === 'SERIALISE' && typeof obj[prop] !== 'string') {
|
||||
obj[prop] = JSON.stringify(obj[prop]);
|
||||
if (action === 'SERIALISE') {
|
||||
if (typeof obj[prop] === 'string') {
|
||||
try {
|
||||
JSON.parse(obj[prop]);
|
||||
} catch {
|
||||
obj[prop] = JSON.stringify(obj[prop]);
|
||||
}
|
||||
} else {
|
||||
obj[prop] = JSON.stringify(obj[prop]);
|
||||
}
|
||||
} else if (action === 'PARSE' && typeof obj[prop] === 'string') {
|
||||
obj[prop] = JSON.parse(obj[prop]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user