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