:vertical-traffic-light: Method router for Primsy
npm i prismy-method-router
import {
prismy,
createUrlEncodedBodySelector,
res
} from 'prismy'
import {
methodRouter
} from 'prismy-method-router'
const urlEncodedBodySelector = createUrlEncodedBodySelector()
export default methodRouter({
get: prismy([], () => {
return res(
[
'<!DOCTYPE html>',
'<body>',
'<form action="/" method="post">',
'<input name="message">',
'<button type="submit">Send</button>',
'</form>',
'</body>'
].join('')
)
}),
post: prismy([urlEncodedBodySelector], body => {
return res(body)
})
})