prismy-method-router
v2.0.0
Published
:vertical-traffic-light: Method router for Primsy
Downloads
7
Readme
prismy-method-router
:vertical-traffic-light: Method router for Primsy
npm i prismy-method-router
Example
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)
})
})