You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

79 lines
2.2 KiB

import filePlugin from "./file-plugin";
import path from "path";
import { sourceDir } from "@/util";
import { plugin as routePlugin } from "@noderun/hapi-router";
import {ServerRegisterPluginObject, Plugin, Server, Request, ResponseObject} from "@hapi/hapi"
import Hoek from "@hapi/hoek"
import HapiYar from "@hapi/yar";
import HapiCrumb from "@hapi/crumb"
export default [
{
plugin: filePlugin as unknown as Plugin<any>,
},
{
plugin: routePlugin as Plugin<any>,
options: {
auth: ['/api'],
sourceDir: [
{
dir: path.resolve(sourceDir, "route/api"),
prefix: "api"
},
{
dir: path.resolve(sourceDir, "route/views"),
prefix: ""
},
],
type: "session"
},
},
{
plugin: {
name: "flash",
version: "0.0.1",
// https://github.com/hks-epod/paydash/blob/master/lib/flash.js
register: function (server: Server, options) {
server.ext('onPreResponse', function(request: Request, h) {
// @ts-ignore
if (request.yar && request.yar.flash && request.response.variety === 'view') {
var flash = request.yar.flash();
request.yar.set('_flash', {});
// @ts-ignore
request.response.source.context = Hoek.applyToDefaults(
{
flash: flash
},
// @ts-ignore
request.response.source.context
);
// @ts-ignore
}
return h.continue;
});
}
} as Plugin<any>
},
{
plugin: HapiYar,
options: {
storeBlank: false,
cookieOptions: {
password: "dsRhw1Y5UZqB8SjfClbkrX9PF7yuDMV3JItcW0G4vgpaxONo6mzenHLQET2AiKyPUjjdgjo10amjfghy",
isSecure: false
}
}
},
{
plugin: HapiCrumb,
options: {
autoGenerate: true,
// skip: function(request, reply) {
// return true;
// },
cookieOptions: {
isSecure: false
}
}
},
] as unknown as ServerRegisterPluginObject<any>;