aboutsummaryrefslogtreecommitdiff
path: root/src/api/structures/Route.js
diff options
context:
space:
mode:
authorKana <[email protected]>2021-01-08 19:48:25 +0900
committerGitHub <[email protected]>2021-01-08 19:48:25 +0900
commit3cfb2721ce64ab94fdbc9c97b54602acc3c654be (patch)
treeb427becf78c51081e58f1b2af98b2662f7626a39 /src/api/structures/Route.js
parentMerge pull request #248 from WeebDev/feature/stats-dashboard (diff)
parentfix: pg driver doesn't return anything without .returning() (diff)
downloadhost.fuwn.me-3cfb2721ce64ab94fdbc9c97b54602acc3c654be.tar.xz
host.fuwn.me-3cfb2721ce64ab94fdbc9c97b54602acc3c654be.zip
Merge pull request #250 from Zephyrrus/feature/system_status_page
Feature/system status page
Diffstat (limited to 'src/api/structures/Route.js')
-rw-r--r--src/api/structures/Route.js36
1 files changed, 1 insertions, 35 deletions
diff --git a/src/api/structures/Route.js b/src/api/structures/Route.js
index bb7ba87..24d45b2 100644
--- a/src/api/structures/Route.js
+++ b/src/api/structures/Route.js
@@ -1,39 +1,5 @@
-const nodePath = require('path');
const JWT = require('jsonwebtoken');
-const db = require('knex')({
- client: process.env.DB_CLIENT,
- connection: {
- host: process.env.DB_HOST,
- user: process.env.DB_USER,
- password: process.env.DB_PASSWORD,
- database: process.env.DB_DATABASE,
- filename: nodePath.join(__dirname, '../../../database/database.sqlite')
- },
- postProcessResponse: result => {
- /*
- Fun fact: Depending on the database used by the user and given that I don't want
- to force a specific database for everyone because of the nature of this project,
- some things like different data types for booleans need to be considered like in
- the implementation below where sqlite returns 1 and 0 instead of true and false.
- */
- const booleanFields = ['enabled', 'enableDownload', 'isAdmin', 'nsfw'];
-
- const processResponse = row => {
- Object.keys(row).forEach(key => {
- if (booleanFields.includes(key)) {
- if (row[key] === 0) row[key] = false;
- else if (row[key] === 1) row[key] = true;
- }
- });
- return row;
- };
-
- if (Array.isArray(result)) return result.map(row => processResponse(row));
- if (typeof result === 'object') return processResponse(result);
- return result;
- },
- useNullAsDefault: process.env.DB_CLIENT === 'sqlite3'
-});
+const db = require('./Database');
const moment = require('moment');
const log = require('../utils/Log');