Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)}`