diff --git a/types/hapi-server-session/hapi-server-session-tests.ts b/types/hapi-server-session/hapi-server-session-tests.ts new file mode 100644 index 0000000000..0a9a3fd787 --- /dev/null +++ b/types/hapi-server-session/hapi-server-session-tests.ts @@ -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 }); diff --git a/types/hapi-server-session/index.d.ts b/types/hapi-server-session/index.d.ts new file mode 100644 index 0000000000..e874b5e9db --- /dev/null +++ b/types/hapi-server-session/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for hapi-server-session 5.1 +// Project: https://github.com/btmorex/hapi-server-session +// Definitions by: Avery Fay +// 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; + cookie?: ServerStateCookieOptions; + expiresIn?: number; + key?: BinaryLike; + name?: string; + size?: number; + vhost?: string | string[]; +} + +export const plugin: Plugin; + +export default plugin; diff --git a/types/hapi-server-session/tsconfig.json b/types/hapi-server-session/tsconfig.json new file mode 100644 index 0000000000..f61fc8da8d --- /dev/null +++ b/types/hapi-server-session/tsconfig.json @@ -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"] +} diff --git a/types/hapi-server-session/tslint.json b/types/hapi-server-session/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hapi-server-session/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }