DefinitelyTyped/types/crumb/crumb-tests.ts
2018-11-29 13:12:37 +01:00

48 lines
912 B
TypeScript

import * as hapi from 'hapi';
import * as crumb from 'crumb';
const server = new hapi.Server({ port: 8000 });
server.register({
plugin: crumb,
options: {
key: 'csrf-token',
size: 50,
autoGenerate: true,
addToViewContext: true,
cookieOptions: {
path: '/',
},
headerName: 'X-CSRF-Token',
restful: true,
skip: () => false,
enforce: true,
logUnauthorized: false,
}
});
server.route({
method: 'get',
path: '/',
handler: async (_, h) => {
return h.continue;
},
});
server.route({
method: 'get',
path: '/custom',
options: {
plugins: {
crumb: {
key: 'x-csrf-token',
source: 'query',
restful: true,
},
},
},
handler: async (_, h) => {
return h.continue;
},
});