Skip to content

Commit 3421008

Browse files
authored
fix: remove unused dependencies (#229)
1 parent 6d068ff commit 3421008

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

__snapshots__/index.test.ts.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
exports['test/index.test.ts SessionOptions schema should have a valid schema 1'] = {
2+
"key": "koa.sess",
3+
"autoCommit": true,
4+
"overwrite": true,
5+
"httpOnly": true,
6+
"signed": true,
7+
"rolling": false,
8+
"renew": false
9+
}

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,15 @@
2626
"koa": "2",
2727
"mm": "4",
2828
"rimraf": "6",
29+
"snap-shot-it": "^7.9.10",
2930
"tshy": "3",
3031
"tshy-after": "1",
3132
"typescript": "5"
3233
},
3334
"license": "MIT",
3435
"dependencies": {
3536
"crc": "^3.8.0",
36-
"debug": "^4.3.3",
3737
"is-type-of": "^2.2.0",
38-
"uuid": "^8.3.2",
3938
"zod": "^3.24.1"
4039
},
4140
"engines": {

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const debug = debuglog('koa-session');
1111
const GET_CONTEXT_SESSION = Symbol('get contextSession');
1212
const CONTEXT_SESSION_INSTANCE = Symbol('contextSession instance');
1313

14-
const SessionOptionsSchema = z.object({
14+
export const SessionOptions = z.object({
1515
/**
1616
* cookie key
1717
* Default is `koa.sess`
@@ -159,9 +159,9 @@ const SessionOptionsSchema = z.object({
159159
.optional(),
160160
});
161161

162-
const DEFAULT_SESSION_OPTIONS = SessionOptionsSchema.parse({});
162+
const DEFAULT_SESSION_OPTIONS = SessionOptions.parse({});
163163

164-
export type SessionOptions = z.infer<typeof SessionOptionsSchema>;
164+
export type SessionOptions = z.infer<typeof SessionOptions>;
165165
export type CreateSessionOptions = Partial<SessionOptions>;
166166

167167
type Middleware = (ctx: any, next: any) => Promise<void>;
@@ -199,7 +199,7 @@ export function createSession(opts: CreateSessionOptions | any, app: any): Middl
199199
...DEFAULT_SESSION_OPTIONS,
200200
...opts,
201201
};
202-
SessionOptionsSchema.parse(options);
202+
SessionOptions.parse(options);
203203
options = formatOptions(options);
204204
extendContext(app.context, options);
205205

test/index.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import snapshot from 'snap-shot-it';
2+
import { SessionOptions } from '../src/index.js';
3+
4+
describe('test/index.test.ts', () => {
5+
describe('SessionOptions schema', () => {
6+
it('should have a valid schema', () => {
7+
const parsed = SessionOptions.parse({});
8+
snapshot(parsed);
9+
});
10+
});
11+
});

0 commit comments

Comments
 (0)