How to use the @stoplight/prism-http-server.createServer function in @stoplight/prism-http-server

To help you get started, we’ve selected a few @stoplight/prism-http-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoplightio / prism / packages / cli / src / util / createServer.ts View on Github external
if (operations.length === 0) {
    throw new Error('No operations found in the current file.');
  }

  const shared: Omit = {
    validateRequest: true,
    validateResponse: true,
    checkSecurity: true,
    errors: false,
  };

  const config: IHttpProxyConfig | IHttpConfig = isProxyServerOptions(options)
    ? { ...shared, mock: false, upstream: options.upstream }
    : { ...shared, mock: { dynamic: options.dynamic } };

  const server = createHttpServer(operations, {
    cors: options.cors,
    config,
    components: { logger: logInstance.child({ name: 'HTTP SERVER' }) },
    errors: options.errors,
  });

  const address = await server.listen(options.port, options.host);

  operations.forEach(resource => {
    const path = pipe(
      createExamplePath(resource, attachTagsToParamsValues),
      E.getOrElse(() => resource.path)
    );

    logInstance.info(
      `${resource.method.toUpperCase().padEnd(10)} ${address}${transformPathParamsValues(path, chalk.bold.cyan)}`

@stoplight/prism-http-server

**NOTE:** The current API is still experimental and could change with no notice. Use at your own risk.

Apache-2.0
Latest version published 2 months ago

Package Health Score

83 / 100
Full package analysis

Popular @stoplight/prism-http-server functions

Similar packages