当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Server.register方法代码示例

本文整理汇总了TypeScript中hapi.Server.register方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Server.register方法的具体用法?TypeScript Server.register怎么用?TypeScript Server.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hapi.Server的用法示例。


在下文中一共展示了Server.register方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createApp

function createApp(createOptions: HapiPluginOptions) {
  const server = new hapi.Server();

  server.connection({
      host: 'localhost',
      port: 8000,
  });

  server.register({
      register: apolloHapi,
      options: {
        apolloOptions: createOptions ? createOptions.apolloOptions : { schema: Schema },
        path: '/graphql',
      },
  });

  server.register({
      register: graphiqlHapi,
      options: {
        path: '/graphiql',
        graphiqlOptions: {
          endpointURL: '/graphql',
        },
      },
  });

  return server.listener;
}
开发者ID:HriBB,项目名称:apollo-server,代码行数:28,代码来源:hapiApollo.test.ts

示例2: startServer

async function startServer() {
    // Create a server with a host and port
    const options = {
        host: 'localhost',
        port: 3000,
    }

    const server = new Server(options)

    await server.register({
        options: {
            graphqlOptions: { schema },
            path: '/graphql',
        },
        plugin: graphqlHapi,
    })

    await server.register({
        options: {
            graphiqlOptions: {
                endpointURL: '/graphql',
            },
            path: '/',
        },
        plugin: graphiqlHapi,
    })

    try {
        await server.start()
        console.log(`Server is listen on ${options.port}`)
        console.log(`open browser to http://localhost:${options.port}`)
    } catch (e) {
        console.error(e)
    }
}
开发者ID:nnance,项目名称:express-hapi-graphql,代码行数:35,代码来源:hapi.ts

示例3:

(async () => {
    const server = new Hapi.Server({ port: 3000 });

    await server.register(Schwifty);
    await server.register({
        plugin: Schwifty.plugin,
        options: {
            knex: {
                client: "sqlite3",
                useNullAsDefault: true,
                connection: {
                    filename: ":memory:"
                }
            }
        }
    });

    Schwifty.assertCompatible(DogModel, DogModel);
    // Register a model with schwifty...

    server.schwifty(DogModel);

    await server.initialize();
    const Dog: typeof DogModel = server.models().Dog;

    await Dog.query().insert({ name: "Guinness" });

    // ... then start the server!

    await server.start();

    console.log(`Now, go find some dogs at ${server.info.uri}!`);
})();
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:33,代码来源:schwifty-tests.ts

示例4: startHapi

export async function startHapi(graphqlOptions) {
  const server = new hapi.Server({
      host: 'localhost',
      port: hapiPort,
  })

  await server.register({
      options: {
          graphqlOptions,
          path: '/graphql',
      },
      plugin: apollo.graphqlHapi,
  })

  await server.register({
      options: {
          graphiqlOptions: {
              endpointURL: '/graphql',
          },
          path: '/',
      },
      plugin: apollo.graphiqlHapi,
  })

  await server.start()
  console.log(`HAPI server is listen on ${hapiPort}`)
  console.log(`open browser to http://localhost:${hapiPort}`)
}
开发者ID:nnance,项目名称:swapi-apollo,代码行数:28,代码来源:hapi.ts

示例5: createApp

function createApp(options: CreateAppOptions) {
  const server = new hapi.Server();

  server.connection({
      host: 'localhost',
      port: 8000,
  });

  server.register({
      register: graphqlHapi,
      options: {
        graphqlOptions: (options && options.graphqlOptions) || { schema: Schema },
        path: '/graphql',
      },
  });

  server.register({
      register: graphiqlHapi,
      options: {
        path: '/graphiql',
        graphiqlOptions: (options && options.graphiqlOptions) || { endpointURL: '/graphql' },
      },
  });

  return server.listener;
}
开发者ID:convoyinc,项目名称:apollo-server,代码行数:26,代码来源:hapiApollo.test.ts

示例6: init

 public static init(): Hapi.Server {
     const server = new Hapi.Server();
     server.connection({
         port: 10000,
         router: {
             isCaseSensitive: false,
             stripTrailingSlash: true
         },
         routes: {
             timeout: {
                 server: 10000,
                 socket: false
             },
             cors: {
                 credentials: true,
                 origin: ['*'],
                 headers: ['Accept', 'Authorization',
                           'Content-Type', 'If-None-Match',
                           'Access-Control-Allow-Origin',
                           'Accept-Language']
             },
             files: {
                 relativeTo: Path.join(__dirname, '../')
             }
         }
     });
     server.ext('onPreResponse', corsHeaders);
     server.register(Inert, () => {});
     Api.init(server);
     return server;
 }
开发者ID:asiddeen,项目名称:BiB,代码行数:31,代码来源:server.ts

示例7: boot

async function boot() {
    const server = new Server();
    await server.register({
        plugin: yar,
        options: {
            cookieOptions: {
                password: 'test',
                isSecure: true,
            },
            cache: {
                cache: 'test',
                expiresIn: 123141243,
            }
        },
    });

    server.route({
        path: '/test',
        method: 'get',
        handler(request: Request) {
            const example = request.yar.get('example');
            return {
                id: request.yar.id,
                key: example.key,
            };
        },
    });
}
开发者ID:Flarna,项目名称:DefinitelyTyped,代码行数:28,代码来源:yar-tests.ts

示例8: async

const start = async () => {
    await server.register(AuthBearer);

    server.auth.strategy('simple', 'bearer-access-token', {
        allowQueryToken: true,              // optional, false by default
        validate: (async (request, token, h) => {
            // here is where you validate your token
            // comparing with token from your database for example
            const isValid = token === '1234';

            const credentials = { token };
            const artifacts = { test: 'info' };

            return { isValid, credentials, artifacts };
        }) as AuthBearer.Validate
    });

    server.auth.default('simple');

    server.route({
        method: 'GET',
        path: '/',
        handler: async (request, h) => {
            return { info: 'success!' };
        }
    });

    await server.start();

    return server;
};
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:hapi-auth-bearer-token-tests.ts

示例9: start

  public async start(options: Readonly<BasePathProxyServerOptions>) {
    this.log.debug('starting basepath proxy server');

    const serverOptions = getServerOptions(this.httpConfig);
    this.server = createServer(serverOptions);

    // Register hapi plugin that adds proxying functionality. It can be configured
    // through the route configuration object (see { handler: { proxy: ... } }).
    await this.server.register({ plugin: require('h2o2') });

    if (this.httpConfig.ssl.enabled) {
      const tlsOptions = serverOptions.tls as TlsOptions;
      this.httpsAgent = new HttpsAgent({
        ca: tlsOptions.ca,
        cert: tlsOptions.cert,
        key: tlsOptions.key,
        passphrase: tlsOptions.passphrase,
        rejectUnauthorized: false,
      });
    }

    this.setupRoutes(options);

    await this.server.start();

    this.log.info(
      `basepath proxy server running at ${this.server.info.uri}${this.httpConfig.basePath}`
    );
  }
开发者ID:austec-automation,项目名称:kibana,代码行数:29,代码来源:base_path_proxy_server.ts

示例10: all

            all(plugins.map((plugin) => {
                server.register(plugin.module, plugin.options, (err) => {
                    if (err) {
                        return Promise.reject(err);
                    }

                    return Promise.resolve();
                });
            }))
开发者ID:richie5um,项目名称:hapiTemplate,代码行数:9,代码来源:index.ts


注:本文中的hapi.Server.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。