Skip to content

Commit e4db7a4

Browse files
authored
Merge pull request #15 from atifcppprogrammer/documentation/async-functions
updated README post migration to async methods
2 parents f8d087f + 871deea commit e4db7a4

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ app.get("/login", async (req, res) => {
312312
});
313313

314314
app.get("/logout", async (req, res) => {
315-
const logoutURL = client.logout(req).toString();
315+
const logoutURL = (await client.logout(req)).toString();
316316
res.redirect(logoutURL);
317317
});
318318
```
@@ -331,19 +331,19 @@ which is provided below, To understand why is this required please keep reading.
331331
export const sessionManager = (
332332
req: Request, res: Response, next: NextFunction
333333
) => {
334-
req.setSessionItem = (itemKey: string, itemValue: unknown) => {
334+
req.setSessionItem = async (itemKey: string, itemValue: unknown) => {
335335
req.session[itemKey] = itemValue;
336336
}
337337

338-
req.getSessionItem = (itemKey: string) => {
338+
req.getSessionItem = async (itemKey: string) => {
339339
return req.session[itemKey] ?? null;
340340
}
341341

342-
req.removeSessionItem = (itemKey: string) => {
342+
req.removeSessionItem = async (itemKey: string) => {
343343
delete req.session[itemKey];
344344
}
345345

346-
req.destroySession = () => {
346+
req.destroySession = async () => {
347347
req.session.destroy(error => console.error(error));
348348
}
349349

@@ -358,11 +358,13 @@ This SDK is intended to be **framework agnostic**, consequently it exports a cus
358358
interface called `SessionManager` to enforce a contract between the end-user
359359
framework and the SDK. The definition of which is presented below.
360360
```ts
361+
type Awaitable<T> = Promise<T>;
362+
361363
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>;
366368
}
367369
```
368370

0 commit comments

Comments
 (0)