forked from ArtOfCode-/openletter
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathconsole.ts
23 lines (18 loc) · 882 Bytes
/
console.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import repl from 'repl';
import mysql from 'mysql2';
import * as queryHelpers from './query_helpers';
import * as renderHelpers from './render_helpers';
import * as viewHelpers from './view_helpers';
import config from './config/config';
import { BaseModel } from './models/base';
import { Signatory } from './models/signatory';
(async () => {
const pool = mysql.createPool(config.database.connectionObject());
BaseModel.pool = pool;
await queryHelpers.queries(pool, [[], []], "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES';", "SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES';");
const re = repl.start('openletter> ');
const context = {};
Object.assign(context, queryHelpers, renderHelpers, viewHelpers, config);
Object.assign(context, { BaseModel, Signatory });
Object.assign(re.context, context);
})();