Skip to content

prismyland/prismy-method-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prismy-method-router

:vertical-traffic-light: Method router for Primsy

Build Status codecov NPM download Language grade: JavaScript

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)
  })
})