Skip to content

Commit 48c02d1

Browse files
Merge pull request #2942 from simister/master
docs: fix typo
2 parents 1bce5b0 + 4e8c294 commit 48c02d1

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

content/techniques/cookies.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You can pass several options to the `cookieParser` middleware:
2626

2727
The middleware will parse the `Cookie` header on the request and expose the cookie data as the property `req.cookies` and, if a secret was provided, as the property `req.signedCookies`. These properties are name value pairs of the cookie name to cookie value.
2828

29-
When secret is provided, this module will unsign and validate any signed cookie values and move those name value pairs from `req.cookies` into `req.signedCookies`. A signed cookie is a cookie that has a value prefixed with `s:`. Signed cookies that fail signature validation will have the value `false` instead of the tampered value.
29+
When a secret is provided, this module will unsign and validate any signed cookie values and move those name value pairs from `req.cookies` into `req.signedCookies`. A signed cookie is a cookie that has a value prefixed with `s:`. Signed cookies that fail signature validation will have the value `false` instead of the tampered value.
3030

3131
With this in place, you can now read cookies from within the route handlers, as follows:
3232

@@ -67,10 +67,7 @@ Once the installation is complete, register the `@fastify/cookie` plugin:
6767
import fastifyCookie from '@fastify/cookie';
6868

6969
// somewhere in your initialization file
70-
const app = await NestFactory.create<NestFastifyApplication>(
71-
AppModule,
72-
new FastifyAdapter(),
73-
);
70+
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
7471
await app.register(fastifyCookie, {
7572
secret: 'my-secret', // for cookies signature
7673
});
@@ -109,12 +106,10 @@ To provide a convenient, declarative way of accessing incoming cookies, we can c
109106
```typescript
110107
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
111108

112-
export const Cookies = createParamDecorator(
113-
(data: string, ctx: ExecutionContext) => {
114-
const request = ctx.switchToHttp().getRequest();
115-
return data ? request.cookies?.[data] : request.cookies;
116-
},
117-
);
109+
export const Cookies = createParamDecorator((data: string, ctx: ExecutionContext) => {
110+
const request = ctx.switchToHttp().getRequest();
111+
return data ? request.cookies?.[data] : request.cookies;
112+
});
118113
```
119114

120115
The `@Cookies()` decorator will extract all cookies, or a named cookie from the `req.cookies` object and populate the decorated parameter with that value.

0 commit comments

Comments
 (0)