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 this.database.connect()
|
||||||
|
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
|
const _resolve = () => resolve()
|
||||||
if (!port) {
|
if (!port) {
|
||||||
this.server = this.application.server.listen(resolve)
|
this.server = this.application.server.listen(_resolve)
|
||||||
return
|
return
|
||||||
} else if (typeof port === 'number' && hostname) {
|
} 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 {
|
} 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 { IDatabase } from '../database/IDatabase';
|
||||||
import {AsyncRouter} from '../router'
|
import { IAppServer } from './IAppServer';
|
||||||
import {IRoutes} from '@rondo.dev/common'
|
|
||||||
import {IDatabase} from '../database/IDatabase'
|
|
||||||
|
|
||||||
export interface IApplication {
|
export interface IApplication {
|
||||||
readonly server: express.Application
|
readonly server: IAppServer
|
||||||
readonly database: IDatabase
|
readonly database: IDatabase
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,12 +13,13 @@ import shortid from 'shortid'
|
|||||||
import { AddressInfo } from 'net'
|
import { AddressInfo } from 'net'
|
||||||
import { createRemoteClient, FunctionPropertyNames, TAsyncified } from '@rondo.dev/jsonrpc'
|
import { createRemoteClient, FunctionPropertyNames, TAsyncified } from '@rondo.dev/jsonrpc'
|
||||||
import {Server} from 'http'
|
import {Server} from 'http'
|
||||||
|
import { IAppServer } from '../application/IAppServer'
|
||||||
|
|
||||||
export class TestUtils<T extends IRoutes> {
|
export class TestUtils<T extends IRoutes> {
|
||||||
readonly username = `test${process.env.JEST_WORKER_ID}@user.com`
|
readonly username = `test${process.env.JEST_WORKER_ID}@user.com`
|
||||||
readonly password = 'Password10'
|
readonly password = 'Password10'
|
||||||
|
|
||||||
readonly app: express.Application
|
readonly app: IAppServer
|
||||||
readonly context: string
|
readonly context: string
|
||||||
readonly transactionManager: ITransactionManager
|
readonly transactionManager: ITransactionManager
|
||||||
|
|
||||||
@ -134,7 +135,7 @@ export class TestUtils<T extends IRoutes> {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
headers: {
|
headers: {
|
||||||
"cookie": [cookies, cookie].join('; '),
|
'cookie': [cookies, cookie].join('; '),
|
||||||
'x-csrf-token': token,
|
'x-csrf-token': token,
|
||||||
},
|
},
|
||||||
userId: response.body.id,
|
userId: response.body.id,
|
||||||
@ -155,7 +156,7 @@ export class TestUtils<T extends IRoutes> {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
headers: {
|
headers: {
|
||||||
"cookie": [cookies, cookie].join('; '),
|
'cookie': [cookies, cookie].join('; '),
|
||||||
'x-csrf-token': token,
|
'x-csrf-token': token,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user