|
|
@ -2,7 +2,11 @@ import filePlugin from "./file-plugin"; |
|
|
|
import path from "path"; |
|
|
|
import { sourceDir } from "@/util"; |
|
|
|
import { plugin as routePlugin } from "@noderun/hapi-router"; |
|
|
|
import {ServerRegisterPluginObject, Plugin} from "@hapi/hapi" |
|
|
|
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>, |
|
|
@ -24,4 +28,52 @@ export default [ |
|
|
|
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>; |
|
|
|