Skip to content

Commit

Permalink
Add plugin support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Octo8080X committed Nov 22, 2023
1 parent fd5389e commit 668c234
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ export * from "./stores/redis.ts";
export * from "./stores/kv.ts";
export * from "./stores/interface.ts";
export * from "./session.ts";
export * from "./plugins/cookie_session_plugin.ts";
export * from "./plugins/redis_session_plugin.ts";
export * from "./plugins/kv_session_plugin.ts";
3 changes: 1 addition & 2 deletions src/plugins/cookie_session_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type {
} from "../deps.ts";
import { cookieSession } from "../stores/cookie.ts";
import { CookieOptions } from "../stores/cookie_option.ts";

export type sessionModule =(req: Request, ctx: MiddlewareHandlerContext) => Promise<Response>
import { sessionModule } from "../stores/interface.ts";

export function getCookieSessionHandler(session: sessionModule, excludePath: string[]): MiddlewareHandler {
return function (req: Request, ctx: MiddlewareHandlerContext) {
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/kv_session_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type {
} from "../deps.ts";
import { kvSession } from "../stores/kv.ts";
import { CookieOptions } from "../stores/cookie_option.ts";

export type sessionModule =(req: Request, ctx: MiddlewareHandlerContext) => Promise<Response>
import { sessionModule } from "../stores/interface.ts";

export function getKvSessionHandler(session: sessionModule, excludePath: string[]): MiddlewareHandler {
return function (req: Request, ctx: MiddlewareHandlerContext) {
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/redis_session_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type {
} from "../deps.ts";
import { Store, redisSession } from "../stores/redis.ts";
import { CookieOptions } from "../stores/cookie_option.ts";

export type sessionModule =(req: Request, ctx: MiddlewareHandlerContext) => Promise<Response>
import { sessionModule } from "../stores/interface.ts";

export function getRedisSessionHandler(session: sessionModule, excludePath: string[]): MiddlewareHandler {
return function (req: Request, ctx: MiddlewareHandlerContext) {
Expand Down
3 changes: 3 additions & 0 deletions src/stores/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { MiddlewareHandlerContext } from "../deps.ts";
import { Session } from "../session.ts";
export type WithSession = {
session: Session;
};

export type sessionModule =(req: Request, ctx: MiddlewareHandlerContext) => Promise<Response>

0 comments on commit 668c234

Please sign in to comment.