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


TypeScript Server.start方法代码示例

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


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

示例1: it

        it('creates a healthcheck endpoint', async () => {
          server = new ApolloServer({
            typeDefs,
            resolvers,
          });
          app = new Server({ port });

          await server.applyMiddleware({ app });
          await app.start();

          httpServer = app.listener;
          const { port: appPort } = app.info;

          return new Promise((resolve, reject) => {
            request(
              {
                url: `http://localhost:${appPort}/.well-known/apollo/server-health`,
                method: 'GET',
              },
              (error, response, body) => {
                if (error) {
                  reject(error);
                } else {
                  expect(body).toEqual(JSON.stringify({ status: 'pass' }));
                  expect(response.statusCode).toEqual(200);
                  resolve();
                }
              },
            );
          });
        });
开发者ID:apollostack,项目名称:apollo-server,代码行数:31,代码来源:ApolloServer.test.ts

示例2:

server.register(Nes).then(() => {

    return server.start().then(() => {

        server.broadcast('welcome!');
    });
});
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:7,代码来源:broadcast-server.ts

示例3: 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

示例4: createApp

async function createApp(options: CreateAppOptions) {
  const server = new hapi.Server({
    host: 'localhost',
    port: 8000,
  });

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

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

  await server.start();

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

示例5: 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

示例6: start

async function start() {
    const server = new Hapi.Server();

    const env = process.env.NODE_ENV || 'development';
    process.env.NODE_ENV = env; //So the plugins load right
    const configFilePath = path.join(__dirname, "config", env + ".json");
    const userConfigFilePath = path.join(__dirname, "config", env + ".user.json");
    nconf
        .file("user_overrides", userConfigFilePath)
        .file("defaults", configFilePath);

    server.connection({
        host: nconf.get('hapi:host'),
        port: nconf.get('hapi:port')
    });

    const appLogger = new AppLogger();
    server.app.logger = await appLogger.initialize(nconf);

    await Plugin.registerAll(server, nconf);
    await Api.loadRoutes(server);

    await server.start();
    if (server.info !== null) {
        server.app.logger.info(`Server running at ${server.info.uri}`);
    }
}
开发者ID:dangelspencer,项目名称:typed-hapi,代码行数:27,代码来源:index.ts

示例7: 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

示例8: 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

示例9:

(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


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