Use simpler interface for Bootstrap app server
This commit is contained in:
parent
b2205660a2
commit
b813916c19
@ -130,13 +130,14 @@ export class Bootstrap implements IBootstrap {
|
||||
await this.database.connect()
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
const _resolve = () => resolve()
|
||||
if (!port) {
|
||||
this.server = this.application.server.listen(resolve)
|
||||
this.server = this.application.server.listen(_resolve)
|
||||
return
|
||||
} else if (typeof port === 'number' && hostname) {
|
||||
this.server = this.application.server.listen(port, hostname, resolve)
|
||||
this.server = this.application.server.listen(port, hostname, _resolve)
|
||||
} else {
|
||||
this.server = this.application.server.listen(port, resolve)
|
||||
this.server = this.application.server.listen(port, _resolve)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
8
packages/server/src/application/IAppServer.ts
Normal file
8
packages/server/src/application/IAppServer.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Server } from 'http';
|
||||
|
||||
export interface IAppServer {
|
||||
listen(callback?: () => void): Server
|
||||
listen(callback?: () => void): Server
|
||||
listen(portOrPath: number | string, callback?: () => void): Server
|
||||
listen(port: number, hostname: string, callback?: () => void): Server
|
||||
}
|
||||
@ -1,9 +1,7 @@
|
||||
import express from 'express'
|
||||
import {AsyncRouter} from '../router'
|
||||
import {IRoutes} from '@rondo.dev/common'
|
||||
import {IDatabase} from '../database/IDatabase'
|
||||
import { IDatabase } from '../database/IDatabase';
|
||||
import { IAppServer } from './IAppServer';
|
||||
|
||||
export interface IApplication {
|
||||
readonly server: express.Application
|
||||
readonly server: IAppServer
|
||||
readonly database: IDatabase
|
||||
}
|
||||
|
||||
@ -13,12 +13,13 @@ import shortid from 'shortid'
|
||||
import { AddressInfo } from 'net'
|
||||
import { createRemoteClient, FunctionPropertyNames, TAsyncified } from '@rondo.dev/jsonrpc'
|
||||
import {Server} from 'http'
|
||||
import { IAppServer } from '../application/IAppServer'
|
||||
|
||||
export class TestUtils<T extends IRoutes> {
|
||||
readonly username = `test${process.env.JEST_WORKER_ID}@user.com`
|
||||
readonly password = 'Password10'
|
||||
|
||||
readonly app: express.Application
|
||||
readonly app: IAppServer
|
||||
readonly context: string
|
||||
readonly transactionManager: ITransactionManager
|
||||
|
||||
@ -134,7 +135,7 @@ export class TestUtils<T extends IRoutes> {
|
||||
|
||||
return {
|
||||
headers: {
|
||||
"cookie": [cookies, cookie].join('; '),
|
||||
'cookie': [cookies, cookie].join('; '),
|
||||
'x-csrf-token': token,
|
||||
},
|
||||
userId: response.body.id,
|
||||
@ -155,7 +156,7 @@ export class TestUtils<T extends IRoutes> {
|
||||
|
||||
return {
|
||||
headers: {
|
||||
"cookie": [cookies, cookie].join('; '),
|
||||
'cookie': [cookies, cookie].join('; '),
|
||||
'x-csrf-token': token,
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user