Add ability to run app minified
This commit is contained in:
parent
f102ff1d70
commit
a672aab11d
@ -2,6 +2,7 @@
|
||||
app:
|
||||
name: Notify
|
||||
baseUrl: http://localhost:3000/notify
|
||||
assets: []
|
||||
session:
|
||||
httpsOnly: false
|
||||
secret:
|
||||
|
||||
@ -39,9 +39,25 @@ export class Bootstrap implements IBootstrap {
|
||||
return new Application(this.getConfig(), database)
|
||||
}
|
||||
|
||||
async exec(command: string = 'listen') {
|
||||
switch (command) {
|
||||
case 'listen':
|
||||
await this.listen()
|
||||
return
|
||||
case 'migrate':
|
||||
await this.migrate()
|
||||
return
|
||||
case 'migrate-undo':
|
||||
await this.migrateUndo()
|
||||
return
|
||||
default:
|
||||
throw new Error('Unknown command: ' + command)
|
||||
}
|
||||
}
|
||||
|
||||
async listen(
|
||||
port: number | string | undefined = process.env.PORT,
|
||||
hostname?: string,
|
||||
port: number | string | undefined = process.env.PORT || 3000,
|
||||
hostname: string | undefined= process.env.BIND_HOST,
|
||||
) {
|
||||
const apiLogger = loggerFactory.getLogger('api')
|
||||
try {
|
||||
@ -53,6 +69,18 @@ export class Bootstrap implements IBootstrap {
|
||||
}
|
||||
}
|
||||
|
||||
async migrate() {
|
||||
const connection = await this.database.connect()
|
||||
await connection.runMigrations()
|
||||
await connection.close()
|
||||
}
|
||||
|
||||
async migrateUndo() {
|
||||
const connection = await this.database.connect()
|
||||
await connection.undoLastMigration()
|
||||
await connection.close()
|
||||
}
|
||||
|
||||
protected async start(
|
||||
port: number | string | undefined = process.env.PORT,
|
||||
hostname?: string,
|
||||
|
||||
@ -6,6 +6,7 @@ export interface IConfig {
|
||||
readonly name: string
|
||||
readonly baseUrl: UrlWithStringQuery
|
||||
readonly context: string
|
||||
readonly assets: string[]
|
||||
readonly session: {
|
||||
readonly name: string
|
||||
readonly secret: string | string[]
|
||||
|
||||
@ -9,6 +9,7 @@ const baseUrl = URL.parse(cfg.get('app.baseUrl'))
|
||||
export const config: IConfig = {
|
||||
app: {
|
||||
name: cfg.get('app.name'),
|
||||
assets: cfg.get('app.assets'),
|
||||
baseUrl,
|
||||
context: baseUrl.path!,
|
||||
session: {
|
||||
|
||||
15
scripts/pack-migrations.js
Executable file
15
scripts/pack-migrations.js
Executable file
@ -0,0 +1,15 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const dir = process.argv[2]
|
||||
|
||||
const index = fs.readdirSync(dir)
|
||||
.filter(item => item.endsWith('.ts') && !item.endsWith('index.ts'))
|
||||
.map(item => item.replace(/\.ts$/, ''))
|
||||
.sort()
|
||||
.map(item => `export * from './${item}'\n`)
|
||||
.reduce((str, item) => str += item, '')
|
||||
|
||||
const out = path.join(dir, 'index.ts')
|
||||
console.log('Writing to %s', out)
|
||||
fs.writeFileSync(path.join(dir, 'index.ts'), index)
|
||||
Loading…
x
Reference in New Issue
Block a user