diff --git a/glue/hapi-glue-test.ts b/glue/hapi-glue-test.ts new file mode 100644 index 0000000000..2d34fdb489 --- /dev/null +++ b/glue/hapi-glue-test.ts @@ -0,0 +1,20 @@ +import * as Glue from "glue"; +import * as Hapi from "hapi"; + +const manifest: Glue.Manifest = { + server: { + port: 3000 + }, + register: { + plugins: [ + { + plugin: "./test", + routes: { + prefix: "test" + } + } + ] + } +} + +Glue.compose(manifest); \ No newline at end of file diff --git a/glue/index.d.ts b/glue/index.d.ts new file mode 100644 index 0000000000..5f40ba924b --- /dev/null +++ b/glue/index.d.ts @@ -0,0 +1,35 @@ +// Type definitions for glue +// Project: https://github.com/hapijs/glue +// Definitions by: Gareth Parker +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.7 + +declare module "glue" { + + import { Server, ServerOptions } from "hapi"; + + export interface Options { + relativeTo: string; + preConnections?: (Server:Server, next:(err:any)=>void ) => void; + preRegister?: (Server:Server, next:(err:any)=>void ) => void; + } + + interface Plugin { + plugin: string | { + register:string; + options?:any; + }; + options?: any; + routes?: any + } + + interface Manifest { + server: ServerOptions; + register?: { + plugins: Array + } + } + + export function compose(manifest: Manifest, options?: Options): Server; + +} diff --git a/glue/tsconfig.json b/glue/tsconfig.json new file mode 100644 index 0000000000..0aa40c6c06 --- /dev/null +++ b/glue/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2017", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "experimentalDecorators": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "hapi-glue-test.ts" + ] +} \ No newline at end of file diff --git a/glue/tslint.json b/glue/tslint.json new file mode 100644 index 0000000000..f84eea1584 --- /dev/null +++ b/glue/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // This package uses the Function type, and it will take effort to fix. + "ban-types": false + } +} \ No newline at end of file