๐Ÿ“ฆ payloadcms / plugin-template

๐Ÿ“„ onInitExtension.ts ยท 17 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17import type { Payload } from 'payload/dist/payload'

import type { PluginTypes } from './types'

export const onInitExtension = (pluginOptions: PluginTypes, payload: Payload): void => {
  const { express: app } = payload

  if (!app) return

  try {
    // You can use the existing express app here to add middleware, routes, etc.
    // app.use(...)
  } catch (err: unknown) {
    payload.logger.error({ msg: 'Error in onInitExtension', err })
  }
}