swc/crates/swc_bundler/tests/.cache/deno/07549e322b5884b0b56710f621809fef08d1866e.ts
2021-11-09 20:42:49 +09:00

26 lines
643 B
TypeScript

// Loaded from https://deno.land/x/tinyhttp@0.1.18/extensions/res/cookie.ts
import { Req, Res } from '../../deps.ts'
import * as cookie from 'https://deno.land/std@0.101.0/http/cookie.ts'
export const setCookie = <Request extends Req = Req, Response extends Res = Res>(req: Request, res: Response) => (
name: string,
value: string,
options?: Omit<cookie.Cookie, 'value' | 'name'>
): Response => {
cookie.setCookie(req, {
value,
name,
...options
})
return res
}
export const clearCookie = <Response extends Res = Res>(res: Response) => (name: string): Response => {
cookie.deleteCookie(res, name)
return res
}