importexpressfrom'express'import{PostRequestHandler,ErrorHandler}from'@mz3/express';// a service function// * accepts one object parameter// * returns a promise resolving with an object// * the object will be sent in the API response via res.jsonconststatus={checkStatus(params: any): Promise<any>=>Promise.resolve({ status: 'okay'})}// create express appconstapp=express()// create an express handler// * passes req.body as parameter to checkStatus// * calls checkStatus and sends the result via res.json// * returns a function that can be provided to app.postapp.post(PostRequestHandler(status.checkStatus))// this package also includes a default error handler that can be provided to app.useapp.use(ErrorHandler)// start appconstport=3000app.listen(port,()=>console.log(`app listening on port ${port}`))
Yarn
yarn test# run jest tests
yarn build # compiles code from src to dist