Hapi
@adminjs/hapi
To setup AdminJS panel with Hapi you need to have @hapi/hapi installed and required peer dependencies:
$ yarn add @hapi/hapi @hapi/boom @hapi/cookie @hapi/inertAfterwards, follow one of the examples below.
Simple
import AdminJSHapi from '@adminjs/hapi'
import Hapi from '@hapi/hapi'
const PORT = 3000
const start = async () => {
const server = Hapi.server({ port: PORT })
const adminOptions: ExtendedAdminJSOptions = {
resources: [],
rootPath: '/admin',
auth: {
isSecure: process.env.NODE_ENV === 'production',
},
registerInert: true,
}
await server.register({
plugin: AdminJSHapi,
options: adminOptions,
})
await server.start();
console.log(`AdminJS available at ${server.info.uri}${adminOptions.rootPath}`);
}
start()Authentication
To add authentication, all you have to do is extend auth config with authenticate, cookieName and cookiePassword.
Last updated
