The new handler.
import createServer, { json, schema, validate } from '@egomobile/http-server'
import { handleApiValidationError } from '@egomobile/api-utils'
interface IMySchema {
// ...
}
const app = createServer()
const mySchema = schema.object({
// ...
})
const mySchemaErrorHandler = handleApiValidationError()
app.post(
'/',
[json(), validate(mySchema, mySchemaErrorHandler)],
async (request, response) => {
const body = request.body as IMySchema;
// ...
}
)
// ...
app.listen()
.catch(console.error)
Generated using TypeDoc
Creates a new handler, that handles failed input data validation, check by a schema.