Merge pull request #2 from tycrek/x-dev-15

a couple smol things
pull/245/head
X 1 year ago committed by GitHub
commit 8dcb966760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,13 +9,13 @@ import { path, isProd } from '@tycrek/joint';
import { epcss } from '@tycrek/express-postcss';
import { log } from './log';
import { JSONDatabase, ensureFiles } from './sql/json';
import { get } from './data';
import { UserConfig } from './UserConfig';
import { MySQLDatabase } from './sql/mysql';
import { buildFrontendRouter } from './routers/_frontend';
import { DBManager } from './sql/database';
import { JSONDatabase } from './sql/json';
import { MySQLDatabase } from './sql/mysql';
import { PostgreSQLDatabase } from './sql/postgres';
import { buildFrontendRouter } from './routers/_frontend';
/**
* Top-level metadata exports
@ -79,8 +79,9 @@ async function main() {
App.pkgVersion = pkg.version;
// Ensure data files exist
await ensureFiles();
// Ensure data directory exists
log.debug('Checking data dir')
await fs.ensureDir(path.join('.ass-data'));
// Set default server configuration
const serverConfig: ServerConfiguration = {
@ -130,6 +131,7 @@ async function main() {
}
} catch (err) { throw new Error(`Failed to configure SQL`); }
} else { // default to json database
log.debug('DB not set! Defaulting to JSON');
await DBManager.use(new JSONDatabase());
}

@ -1,7 +1,4 @@
import { AssFile, AssUser, NID, FilesSchema, UsersSchema } from 'ass';
import fs from 'fs-extra';
import { path } from '@tycrek/joint';
import { AssFile, AssUser, NID } from 'ass';
import { log } from './log';
import { UserConfig } from './UserConfig';
@ -12,14 +9,6 @@ import { DBManager } from './sql/database';
*/
type DataSector = 'files' | 'users';
/**
* Absolute filepaths for JSON data files
*/
const PATHS = {
files: path.join('.ass-data/files.json'),
users: path.join('.ass-data/users.json')
};
/**
* database kind -> name mapping
*/

@ -45,14 +45,9 @@ router.post('/setup', BodyParserJson(), async (req, res) => {
}
// set rate limits
if (UserConfig.config.rateLimit?.api) setRateLimiter('api', UserConfig.config.rateLimit.api);
if (UserConfig.config.rateLimit?.login) setRateLimiter('login', UserConfig.config.rateLimit.login);
if (UserConfig.config.rateLimit?.upload) setRateLimiter('upload', UserConfig.config.rateLimit.upload);
// set rate limits
if (UserConfig.config.rateLimit?.api) setRateLimiter('api', UserConfig.config.rateLimit.api);
if (UserConfig.config.rateLimit?.login) setRateLimiter('login', UserConfig.config.rateLimit.login);
if (UserConfig.config.rateLimit?.upload) setRateLimiter('upload', UserConfig.config.rateLimit.upload);
if (UserConfig.config.rateLimit?.api) setRateLimiter('api', UserConfig.config.rateLimit.api);
if (UserConfig.config.rateLimit?.login) setRateLimiter('login', UserConfig.config.rateLimit.login);
if (UserConfig.config.rateLimit?.upload) setRateLimiter('upload', UserConfig.config.rateLimit.upload);;
log.success('Setup', 'completed');

@ -58,8 +58,6 @@ export const ensureFiles = (): Promise<void> => new Promise(async (resolve, reje
log.debug('Checking data files');
try {
// Create data directory
await fs.ensureDir(path.join('.ass-data'));
// * Default files.json
await createEmptyJson(PATHS.files, {

@ -113,8 +113,8 @@ document.addEventListener('DOMContentLoaded', () => {
password: Elements.mySqlPassword.value,
database: Elements.mySqlDatabase.value
}
}
};
};
}
} else if (Elements.pgsqlTab.active) {
if (Elements.pgsqlHost.value != null && Elements.pgsqlHost.value != '') {
config.database = {
@ -126,8 +126,8 @@ document.addEventListener('DOMContentLoaded', () => {
password: Elements.pgsqlPassword.value,
database: Elements.pgsqlDatabase.value
}
}
};
};
}
}
// append rate limit config, if specified

Loading…
Cancel
Save