diff options
| author | Kana <[email protected]> | 2021-06-19 02:03:57 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-19 02:03:57 +0900 |
| commit | 065c5221a0250838f1d1f9bb7a7922ff4f55e038 (patch) | |
| tree | 8a69a81f00e6bff2752f4f7c59dcbbf21f893b20 /src/api/structures/Server.js | |
| parent | chore: docs update (diff) | |
| parent | fix: potentially fix the blocked extensions array splitting (diff) | |
| download | host.fuwn.me-065c5221a0250838f1d1f9bb7a7922ff4f55e038.tar.xz host.fuwn.me-065c5221a0250838f1d1f9bb7a7922ff4f55e038.zip | |
Merge pull request #278 from Zephyrrus/Zephyrrus-feature/database_based_settings
Zephyrrus feature/database based settings
Diffstat (limited to 'src/api/structures/Server.js')
| -rw-r--r-- | src/api/structures/Server.js | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/api/structures/Server.js b/src/api/structures/Server.js index 268ba68..f584fe8 100644 --- a/src/api/structures/Server.js +++ b/src/api/structures/Server.js @@ -5,6 +5,11 @@ if (!process.env.SERVER_PORT) { process.exit(0); } +if (!process.env.DOMAIN) { + console.log('You failed to provide a domain for your instance. Edit the .env file manually and fix it.'); + process.exit(0); +} + const { loadNuxt, build } = require('nuxt'); const express = require('express'); const helmet = require('helmet'); @@ -19,11 +24,10 @@ const CronJob = require('cron').CronJob; const log = require('../utils/Log'); const Util = require('../utils/Util'); - // eslint-disable-next-line no-unused-vars const rateLimiter = new RateLimit({ - windowMs: parseInt(process.env.RATE_LIMIT_WINDOW, 10), - max: parseInt(process.env.RATE_LIMIT_MAX, 10), + windowMs: parseInt(Util.config.rateLimitWindow, 10), + max: parseInt(Util.config.rateLimitMax, 10), delayMs: 0 }); @@ -72,8 +76,8 @@ class Server { for (const File of routes) { try { const route = new File(); - this.server[route.method](process.env.ROUTE_PREFIX + route.path, route.authorize.bind(route)); - log.info(`Found route ${route.method.toUpperCase()} ${process.env.ROUTE_PREFIX}${route.path}`); + this.server[route.method](Util.config.routePrefix + route.path, route.authorize.bind(route)); + log.info(`Found route ${route.method.toUpperCase()} ${Util.config.routePrefix}${route.path}`); } catch (e) { log.error(`Failed loading route from file ${routeFile} with error: ${e.message}`); } @@ -110,4 +114,10 @@ class Server { } } -new Server().start(); +const start = async () => { + const conf = await Util.config; + new Server().start(); +}; + +start(); + |