@@ -312,7 +312,7 @@ app.get("/login", async (req, res) => {
312
312
});
313
313
314
314
app .get (" /logout" , async (req , res ) => {
315
- const logoutURL = client .logout (req ).toString ();
315
+ const logoutURL = ( await client .logout (req ) ).toString ();
316
316
res .redirect (logoutURL );
317
317
});
318
318
```
@@ -331,19 +331,19 @@ which is provided below, To understand why is this required please keep reading.
331
331
export const sessionManager = (
332
332
req : Request , res : Response , next : NextFunction
333
333
) => {
334
- req .setSessionItem = (itemKey : string , itemValue : unknown ) => {
334
+ req .setSessionItem = async (itemKey : string , itemValue : unknown ) => {
335
335
req .session [itemKey ] = itemValue ;
336
336
}
337
337
338
- req .getSessionItem = (itemKey : string ) => {
338
+ req .getSessionItem = async (itemKey : string ) => {
339
339
return req .session [itemKey ] ?? null ;
340
340
}
341
341
342
- req .removeSessionItem = (itemKey : string ) => {
342
+ req .removeSessionItem = async (itemKey : string ) => {
343
343
delete req .session [itemKey ];
344
344
}
345
345
346
- req .destroySession = () => {
346
+ req .destroySession = async () => {
347
347
req .session .destroy (error => console .error (error ));
348
348
}
349
349
@@ -358,11 +358,13 @@ This SDK is intended to be **framework agnostic**, consequently it exports a cus
358
358
interface called ` SessionManager ` to enforce a contract between the end-user
359
359
framework and the SDK. The definition of which is presented below.
360
360
``` ts
361
+ type Awaitable <T > = Promise <T >;
362
+
361
363
interface SessionManager {
362
- getSessionItem: (itemKey : string ) => unknown | null ;
363
- setSessionItem: (itemKey : string , itemValue : unknown ) => void ;
364
- removeSessionItem: (itemKey : string ) => void ;
365
- destroySession: () => void ;
364
+ getSessionItem: (itemKey : string ) => Awaitable < unknown | null > ;
365
+ setSessionItem: (itemKey : string , itemValue : unknown ) => Awaitable < void > ;
366
+ removeSessionItem: (itemKey : string ) => Awaitable < void > ;
367
+ destroySession: () => Awaitable < void > ;
366
368
}
367
369
```
368
370
0 commit comments