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 init() {
const prism = createInstance();
await prism.load({ path: relative(process.cwd(), process.argv[2]) });
const server = fastify();
server.all('*', createRequestHandler(prism));
return server.listen(PORT);
}
} catch (e) {
return done(e);
}
}
if (typeIs(req, ['application/x-www-form-urlencoded'])) {
return done(null, body);
}
const error: Error & { status?: number } = new Error(`Unsupported media type.`);
error.status = 415;
Error.captureStackTrace(error);
return done(error);
});
const prism = createInstance(config, components);
const replyHandler: fastify.RequestHandler = (request, reply) => {
const {
req: { method, url },
body,
headers,
query,
} = request;
const input = {
method: (method ? method.toLowerCase() : 'get') as HttpMethod,
url: {
path: (url || '/').split('?')[0],
query,
baseUrl: query.__server,
},