mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
48 lines
912 B
TypeScript
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;
|
|
},
|
|
});
|