add types for hapi-server-session (#42403)

This commit is contained in:
Avery Fay
2020-02-19 15:09:26 -08:00
committed by GitHub
parent 230fd5eec4
commit 955e667056
4 changed files with 73 additions and 0 deletions
@@ -0,0 +1,20 @@
import hapiServerSessionPlugin from 'hapi-server-session';
import { Server } from '@hapi/hapi';
const server = new Server();
server.register({
plugin: hapiServerSessionPlugin,
options: {
algorithm: 'md5',
cache: { segment: 'test' },
cookie: { ttl: null },
expiresIn: 86400,
key: 'test',
name: 'test',
size: 32,
vhost: ['test'],
},
});
server.route({ path: '/', method: 'GET', handler: (request, _h) => request.session });
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for hapi-server-session 5.1
// Project: https://github.com/btmorex/hapi-server-session
// Definitions by: Avery Fay <https://github.com/btmorex>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { BinaryLike } from 'crypto';
import { CachePolicyOptions, Plugin, ServerStateCookieOptions } from '@hapi/hapi';
declare module '@hapi/hapi' {
interface Request {
session: any;
}
}
export interface Options {
algorithm?: string;
cache?: CachePolicyOptions<any>;
cookie?: ServerStateCookieOptions;
expiresIn?: number;
key?: BinaryLike;
name?: string;
size?: number;
vhost?: string | string[];
}
export const plugin: Plugin<Options>;
export default plugin;
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"paths": {
"@hapi/catbox": ["hapi__catbox"],
"@hapi/hapi": ["hapi__hapi"],
"@hapi/joi": ["hapi__joi"],
"@hapi/mimos": ["hapi__mimos"],
"@hapi/podium": ["hapi__podium"],
"@hapi/shot": ["hapi__shot"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "hapi-server-session-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }