@stoplight/prism-http-server
TypeScript icon, indicating that this package has built-in type declarations

5.8.1 • Public • Published

Prism Server

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

Usage:

const { createServer } = require('@stoplight/prism-http-server');
const { getHttpOperationsFromSpec } = require('@stoplight/prism-cli/dist/operations');
const { createLogger } = require('@stoplight/prism-core');

async function createPrismServer() {
  const operations = await getHttpOperationsFromSpec('YOUR-URL');

  const server = createServer(operations, {
    components: {
      logger: createLogger('TestLogger'),
    },
    cors: true,
    config: {
      checkSecurity: true,
      validateRequest: true,
      validateResponse: true,
      mock: { dynamic: false },
      isProxy: false,
      errors: false,
    },
  });
  await server.listen(4010);

  return {
    close: server.close.bind(server),
  };
}

const server = await createPrismServer();

server.close();

Readme

Keywords

none

Package Sidebar

Install

npm i @stoplight/prism-http-server

Weekly Downloads

59,587

Version

5.8.1

License

Apache-2.0

Unpacked Size

25.6 kB

Total Files

13

Last publish

Collaborators

  • stoplight-devops