Guest User

Untitled

a guest
Oct 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. const micro = require('micro');
  2. const query = require('micro-urlencoded');
  3.  
  4. module.exports = (...args) => handler => micro((req, res) => {
  5. if(req.method === 'POST') {
  6. return query(req).then(
  7. ({body}) => handler(body, req, res)
  8. );
  9. }
  10.  
  11. res.setHeader('content-type', 'text/html');
  12. return String.raw(...args);
  13. });
Add Comment
Please, Sign In to add comment