Skip to content

ZeRiix/duplojs-cookie-v2

Repository files navigation

Duplo cookie V2

Intallation:

npm install @duplo/cookie-v2

How to use ?:

Configuration:

// main.ts
import Duplo from '@duplojs/core';
import duploCookieV2 from '@duplojs/cookie-v2';
//...

const duplo = new Duplo({
	plugins: [
		(duplo) => void duploCookieV2(duplo, { secret: "my-secret" }),
		//...
	],
	environment: "DEV",
	//...
});

Example:

// ./routes/path/to/your/route.ts
export const myRoute = duplo.
	.declareRoute("GET", "/path/to/your/route")
	.extract({
    	cookie: {
        	cookie: zod.string().optional()
    	}
	})
	.cut((floor, response) => {
    	if(floor.pickup("cookie")) {
			response.code(403).dropCookie("cookie").send();
		}
	})
	.handler((floor, response) => {
    	response.code(200).setCookie("cookie", "i like cookie mmmmh").send();	
	});

Authors:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published