Skip to content

Commit

Permalink
fix: remove unused dependencies (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Jan 19, 2025
1 parent 6d068ff commit 3421008
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
9 changes: 9 additions & 0 deletions __snapshots__/index.test.ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exports['test/index.test.ts SessionOptions schema should have a valid schema 1'] = {
"key": "koa.sess",
"autoCommit": true,
"overwrite": true,
"httpOnly": true,
"signed": true,
"rolling": false,
"renew": false
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@
"koa": "2",
"mm": "4",
"rimraf": "6",
"snap-shot-it": "^7.9.10",
"tshy": "3",
"tshy-after": "1",
"typescript": "5"
},
"license": "MIT",
"dependencies": {
"crc": "^3.8.0",
"debug": "^4.3.3",
"is-type-of": "^2.2.0",
"uuid": "^8.3.2",
"zod": "^3.24.1"
},
"engines": {
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const debug = debuglog('koa-session');
const GET_CONTEXT_SESSION = Symbol('get contextSession');
const CONTEXT_SESSION_INSTANCE = Symbol('contextSession instance');

const SessionOptionsSchema = z.object({
export const SessionOptions = z.object({
/**
* cookie key
* Default is `koa.sess`
Expand Down Expand Up @@ -159,9 +159,9 @@ const SessionOptionsSchema = z.object({
.optional(),
});

const DEFAULT_SESSION_OPTIONS = SessionOptionsSchema.parse({});
const DEFAULT_SESSION_OPTIONS = SessionOptions.parse({});

export type SessionOptions = z.infer<typeof SessionOptionsSchema>;
export type SessionOptions = z.infer<typeof SessionOptions>;
export type CreateSessionOptions = Partial<SessionOptions>;

type Middleware = (ctx: any, next: any) => Promise<void>;
Expand Down Expand Up @@ -199,7 +199,7 @@ export function createSession(opts: CreateSessionOptions | any, app: any): Middl
...DEFAULT_SESSION_OPTIONS,
...opts,
};
SessionOptionsSchema.parse(options);
SessionOptions.parse(options);
options = formatOptions(options);
extendContext(app.context, options);

Expand Down
11 changes: 11 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import snapshot from 'snap-shot-it';
import { SessionOptions } from '../src/index.js';

describe('test/index.test.ts', () => {
describe('SessionOptions schema', () => {
it('should have a valid schema', () => {
const parsed = SessionOptions.parse({});
snapshot(parsed);
});
});
});

0 comments on commit 3421008

Please sign in to comment.