INNER CODE UNIT · TypeScript

registerHooks

midwayjs/hooks · packages/dev-pack/src/app.ts:42

function registerHooks() {
  process.on('uncaughtException', async (err: Error) => {
    ipc.send(process, AppEvents.UncaughtException, err)
    await closeApp(1)
  })

  process.on('SIGINT', async () => {
    await closeApp(0)
  })

  ipc.once(process, ServerEvents.Close).then(() => closeApp(0))

  let service: MidwayWebRouterService
  ipc.on<MatchInfo>(process, ServerEvents.IsMatch, async ({ data }) => {
    if (!service) {
      const appCtx = app.getApplicationContext()
      service = isServer
        ? await appCtx.getAsync(MidwayWebRouterService)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…