mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 19:09:18 +08:00
fix: allow for synchronous Hapi plugin register fn
This commit is contained in:
2
types/hapi/index.d.ts
vendored
2
types/hapi/index.d.ts
vendored
@@ -120,7 +120,7 @@ export interface PluginBase<T> {
|
||||
* * server - the server object with a plugin-specific server.realm.
|
||||
* * options - any options passed to the plugin during registration via server.register().
|
||||
*/
|
||||
register: (server: Server, options: T) => Promise<void>;
|
||||
register: (server: Server, options: T) => void | Promise<void>;
|
||||
|
||||
/** (optional) if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */
|
||||
multiple?: boolean;
|
||||
|
||||
@@ -13,6 +13,10 @@ interface Plugin3 {
|
||||
three: 3;
|
||||
}
|
||||
|
||||
interface Plugin4 {
|
||||
four: 4;
|
||||
}
|
||||
|
||||
declare module 'hapi' {
|
||||
interface PluginProperties {
|
||||
example: {
|
||||
@@ -42,6 +46,11 @@ const plugin3: Plugin<Plugin3> = {
|
||||
register: async (server: Server, options: Plugin3) => {}
|
||||
};
|
||||
|
||||
const plugin4: Plugin<Plugin4> = {
|
||||
name: 'plugin4',
|
||||
register: (server: Server, options: Plugin4) => {}
|
||||
};
|
||||
|
||||
const server = new Server({
|
||||
port: 8000,
|
||||
});
|
||||
@@ -90,5 +99,9 @@ server.register([
|
||||
{
|
||||
plugin: plugin1,
|
||||
options: {one: 1}
|
||||
},
|
||||
{
|
||||
plugin: plugin4,
|
||||
options: {four: 4}
|
||||
}
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user