I am using this code and created a microservice
const { json, send } = require('micro')
const { router, post } = require('microrouter')
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY)
console.log(process.env.STRIPE_SECRET_KEY)
module.exports = router(
post('/', async (req, res) => {
const data = await json(req)
try {
const { status } = await stripe.charges.create(data)
send(res, 200, { status })
} catch (err) {
send(res, 500, { message: err.message })
}
})
)
I can make a post
request here using microrouter
but how can I validate the payload body to get only the required fields only.
Please help if someone know any module to validate microservice post payload.