Skip to content

prismyland/prismy-cookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prismy-cookie

🍪 Cookie for prismy.

Build Status codecov NPM download Language grade: JavaScript

Installation

npm i prismy-cookie

Usage

import {
  prismy,
  res,
  createUrlEncodedBodySelector,
  methodSelector,
  contextSelector,
  Context
} from 'prismy'
import {
  createCookiesSelector,
  ParsedCookies,
  appendCookie
} from 'prismy-cookie'

const urlEncodedBodySelector = createUrlEncodedBodySelector()
const cookiesSelector = createCookiesSelector()
const handler = prismy(
  [methodSelector, cookiesSelector, contextSelector],
  async (method, cookies, context) => {
    if (method === 'POST') {
      const { message } = await urlEncodedBodySelector(context)

      return appendCookie(res('OK!'), ['message', message as string])
    }

    return res(cookies.message)
  }
)

export default prismy(handler)

License

MIT

About

🍪 Cookie for prismy.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •