Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function instantiatePrism(specPath: string) {
const operations = await getHttpOperationsFromResource(specPath);
return createServer(operations, {
components: { logger },
config: {
checkSecurity: true,
validateRequest: true,
validateResponse: true,
mock: { dynamic: false },
},
errors: false,
cors: true,
});
}
watcher.on('change', () => {
server.fastify.log.info('Restarting Prism...');
getHttpOperationsFromResource(options.document)
.then(operations => {
if (operations.length === 0) {
server.fastify.log.info(
'No operations found in the current file, continuing with the previously loaded spec.'
);
} else {
return server.fastify
.close()
.then(() => {
server.fastify.log.info('Loading the updated operations...');
return createPrism(options);
})
.then(newServer => {
if (newServer) {
server = newServer;
async function createPrismServerWithLogger(options: CreateBaseServerOptions, logInstance: Logger) {
const operations = await getHttpOperationsFromResource(options.document);
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 } };