Split services into core and request
This commit is contained in:
48
express/core/index.ts
Normal file
48
express/core/index.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import nunjucks from "nunjucks";
|
||||
import { db, migrate, migrationStatus } from "../database";
|
||||
import { getLogs, log } from "../logging";
|
||||
|
||||
// FIXME: This doesn't belong here; move it somewhere else.
|
||||
const conf = {
|
||||
templateEngine: () => {
|
||||
return {
|
||||
renderTemplate: (template: string, context: object) => {
|
||||
return nunjucks.renderString(template, context);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const database = {
|
||||
db,
|
||||
migrate,
|
||||
migrationStatus,
|
||||
};
|
||||
|
||||
const logging = {
|
||||
log,
|
||||
getLogs,
|
||||
};
|
||||
|
||||
const random = {
|
||||
randomNumber: () => {
|
||||
return Math.random();
|
||||
},
|
||||
};
|
||||
|
||||
const misc = {
|
||||
sleep: (ms: number) => {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
},
|
||||
};
|
||||
|
||||
// Keep this asciibetically sorted
|
||||
const core = {
|
||||
conf,
|
||||
database,
|
||||
logging,
|
||||
misc,
|
||||
random,
|
||||
};
|
||||
|
||||
export { core };
|
||||
Reference in New Issue
Block a user