mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-05 17:51:27 +03:00
fix: http, improve env
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
/* eslint-disable no-console */
|
||||
const { randomBytes } = require('crypto');
|
||||
const fs = require('fs');
|
||||
const { short } = require('leeks.js');
|
||||
|
||||
function log (...strings) {
|
||||
console.log(short('&9[preinstall]&r'), ...strings);
|
||||
}
|
||||
|
||||
const env = {
|
||||
DB_CONNECTION_URL: '',
|
||||
@@ -7,18 +13,22 @@ const env = {
|
||||
DISCORD_SECRET: '',
|
||||
DISCORD_TOKEN: '',
|
||||
ENCRYPTION_KEY: randomBytes(24).toString('hex'),
|
||||
HTTP_BIND: 8080,
|
||||
HTTP_EXTERNAL: 'http://localhost:8080',
|
||||
HTTP_EXTERNAL: 'http://127.0.0.1:8080',
|
||||
HTTP_HOST: '127.0.0.1',
|
||||
HTTP_PORT: 8080,
|
||||
HTTP_TRUST_PROXY: false,
|
||||
OVERRIDE_ARCHIVE: '',
|
||||
PUBLIC_BOT: false,
|
||||
SETTINGS_BIND: 8888,
|
||||
SETTINGS_HOST: '127.0.0.1',
|
||||
SETTINGS_PORT: 8169,
|
||||
SUPER: '319467558166069248',
|
||||
};
|
||||
|
||||
// check DISCORD_TOKEN because we don't want to force use of the .env file
|
||||
if (!process.env.DISCORD_TOKEN && !fs.existsSync('./.env')) {
|
||||
console.log('[preinstall] Generating ENCRYPTION_KEY');
|
||||
// check ENCRYPTION_KEY because we don't want to force use of the .env file
|
||||
if (!process.env.ENCRYPTION_KEY && !fs.existsSync('./.env')) {
|
||||
log('generating ENCRYPTION_KEY');
|
||||
fs.writeFileSync('./.env', Object.entries(env).map(([k, v]) => `${k}=${v}`).join('\n'));
|
||||
console.log('[preinstall] Created .env file');
|
||||
log('created .env file');
|
||||
} else {
|
||||
console.log('[preinstall] Nothing to do');
|
||||
log('nothing to do');
|
||||
}
|
Reference in New Issue
Block a user