Rename configureApplication to configureServer
This commit is contained in:
parent
8ca6107ce6
commit
5688a65cb0
@ -5,8 +5,8 @@ import { AddressInfo } from 'net'
|
||||
import { Database } from '../database/Database'
|
||||
import { IDatabase } from '../database/IDatabase'
|
||||
import { loggerFactory, SqlLogger } from '../logger'
|
||||
import { configureApplication } from './configureApplication'
|
||||
import { createApplication } from './createApplication'
|
||||
import { configureServer } from './configureServer'
|
||||
import { createServer } from './createServer'
|
||||
import { IApplication } from './IApplication'
|
||||
import { IBootstrap } from './IBootstrap'
|
||||
import { IConfig } from './IConfig'
|
||||
@ -37,7 +37,7 @@ export class Bootstrap implements IBootstrap {
|
||||
}
|
||||
|
||||
protected createApplication(database: IDatabase): IApplication {
|
||||
return createApplication(configureApplication(this.getConfig(), database))
|
||||
return createServer(configureServer(this.getConfig(), database))
|
||||
}
|
||||
|
||||
async exec(command: string = 'listen') {
|
||||
|
||||
@ -4,17 +4,17 @@ import { ILogger } from '@rondo.dev/logger'
|
||||
import { IServices } from './IServices'
|
||||
import { RequestHandlerParams, ErrorRequestHandler } from 'express-serve-static-core'
|
||||
|
||||
export interface IApplicationMiddleware {
|
||||
export interface IServerMiddleware {
|
||||
path: string
|
||||
handle: RequestHandlerParams[]
|
||||
error?: ErrorRequestHandler
|
||||
}
|
||||
|
||||
export interface IApplicationConfig {
|
||||
export interface IServerConfig {
|
||||
readonly config: IConfig
|
||||
readonly database: IDatabase
|
||||
readonly logger: ILogger
|
||||
readonly services: IServices
|
||||
readonly globalErrorHandler: ErrorRequestHandler
|
||||
readonly framework: Record<string, IApplicationMiddleware>
|
||||
readonly framework: Record<string, IServerMiddleware>
|
||||
}
|
||||
@ -6,7 +6,7 @@ import * as Middleware from '../middleware'
|
||||
import * as Services from '../services'
|
||||
import * as Team from '../team'
|
||||
import * as User from '../user'
|
||||
import { IApplicationConfig } from './IApplicationConfig'
|
||||
import { IServerConfig } from './IServerConfig'
|
||||
import { IConfig } from './IConfig'
|
||||
import { IServices } from './IServices'
|
||||
import * as routes from '../routes'
|
||||
@ -15,13 +15,13 @@ import { IRoutes, IContext } from '@rondo.dev/common'
|
||||
import { Express } from 'express-serve-static-core'
|
||||
|
||||
export type AppConfigurator<
|
||||
T extends IApplicationConfig = IApplicationConfig
|
||||
T extends IServerConfig = IServerConfig
|
||||
> = (
|
||||
config: IConfig,
|
||||
database: IDatabase,
|
||||
) => T
|
||||
|
||||
export const configureApplication: AppConfigurator = (config, database) => {
|
||||
export const configureServer: AppConfigurator = (config, database) => {
|
||||
|
||||
const logger = loggerFactory.getLogger('api')
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { IApplicationConfig } from './IApplicationConfig'
|
||||
import { IServerConfig } from './IServerConfig'
|
||||
import { IApplication } from './IApplication'
|
||||
import express from 'express'
|
||||
|
||||
export function createApplication(appConfig: IApplicationConfig): IApplication {
|
||||
export function createServer(appConfig: IServerConfig): IApplication {
|
||||
const {config, database, framework} = appConfig
|
||||
const server = express()
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
export * from './Application'
|
||||
export * from './Bootstrap'
|
||||
export * from './IApplication'
|
||||
export * from './IApplicationConfig'
|
||||
export * from './IConfig'
|
||||
export * from './IServerConfig'
|
||||
export * from './IServices'
|
||||
export * from './configureApplication'
|
||||
export * from './createApplication'
|
||||
export * from './configureServer'
|
||||
export * from './createServer'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user