@hckrnews/express-callback
v4.1.7
Published
Express callback
Downloads
174
Readme
Express callback
import OpenAPIBackend from 'openapi-backend';
import { makeExpressCallback } from '@hckrnews/express-callback'
const specification = {
info: {
version: '1.2.3',
}
}
const logger = {}
const meta = {}
const getPetsController = ({
context,
specification,
logger,
errorLogger,
req,
res,
meta,
}) => {
// do something
return {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-store, max-age=0',
},
statusCode: 200,
body: {
},
attachment: false,
}
}
const api = new OpenAPIBackend({ definition: specification });
api.register({
getPets: makeExpressCallback({
controller: getPetsController,
specification,
logger,
errorLogger: { error: (error) => {} },
meta
})
});
api.init();