Add glue v4 typings

This commit is contained in:
Greg Jednaszewski
2018-10-23 11:16:29 -04:00
parent 3ea5ad14c4
commit 2b602f8da3
4 changed files with 132 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
import * as glue from "glue";
import * as hapi from "hapi";
const manifest: glue.Manifest = {
server: {
debug: false,
},
connections: [
{
port: 8000,
labels: ['web']
},
{
port: 8001,
labels: ['admin']
}
],
registrations: [
{
plugin: {
register: './assets',
options: {
uglify: true
}
}
},
{
plugin: './ui-user',
options: {
select: ['web']
}
},
{
plugin: {
register: './ui-admin',
options: {
sessiontime: 500
}
},
options: {
select: ['admin'],
routes: {
prefix: '/admin'
}
}
},
{
plugin: {
register: require('./awesome-plugin.js'),
options: {
whyNot: true
}
}
},
]
};
const options: glue.Options = {
relativeTo: `${__dirname}/modules`
};
glue.compose(manifest, options, (err, server) => {
if (err) {
throw err;
}
server.start(() => {
console.log('hapi days!');
});
});
+31
View File
@@ -0,0 +1,31 @@
// Type definitions for glue 4.0
// Project: https://github.com/hapijs/glue
// Definitions by: Greg Jednaszewski <https://github.com/gjednaszewski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { Server, ServerConnectionOptions, ServerOptions } from "hapi";
export interface Options {
relativeTo: string;
preConnections?: (Server: Server, next: (err: any) => void) => void;
preRegister?: (Server: Server, next: (err: any) => void) => void;
}
export interface Plugin {
plugin: string | {
register: string;
options?: any;
};
options?: any;
}
export interface Manifest {
server: ServerOptions;
connections: ServerConnectionOptions[];
registrations?: Plugin[];
}
export function compose(manifest: Manifest,
options?: Options,
callback?: (err?: any, server?: Server) => void): Promise<Server>;
+29
View File
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"boom": [ "boom/v4" ],
"catbox": [ "catbox/v7" ],
"hapi": [ "hapi/v16" ],
"glue": [ "glue/v4" ]
}
},
"files": [
"index.d.ts",
"glue-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}