To handle cookies in Deepkit, you can use the @deepkit/http
package. The HttpRequest
object has a cookies
property that allows you to access and manipulate cookies. You can use the setCookie
method to set a new cookie and the getCookie
method to retrieve a cookie by its name. Here is an example:
import { HttpMiddleware, HttpRequest, HttpResponse } from '@deepkit/http'; class CookieMiddleware implements HttpMiddleware { execute(request: HttpRequest, response: HttpResponse, next: (err?: any) => void) { // Set a cookie response.setCookie('myCookie', 'value', { maxAge: 3600, secure: true }); // Get a cookie const myCookie = request.cookies.getCookie('myCookie'); next(); } }