Skip to content

Commit a2d76aa

Browse files
authored
TypeScript (#109)
1 parent 16abec2 commit a2d76aa

22 files changed

+1628
-546
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22
node_js:
3-
- "10"
4-
- "12"
3+
- "18"
4+
- "20"
55

66
env:
77
- IN_TRAVIS=yes

Changelog.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ The format is based on Keep a Changelog and this project adheres to Semantic Ver
66

77
## 5.0.0
88

9-
- Updated code for modern Node 18+
10-
- Class syntax instead of prototype
11-
- async/await
9+
- Rewritten in TypeScript (with class syntax and async/await) targeting modern Node 18+
10+
- Tests rewritten to use Node test runner
1211
- eslint
1312
- prettier
14-
- Node test runner
15-
- ES Modules (.mjs)
16-
- ES Module example
13+
- ES Module examples (.mjs)
14+
- Configuation options improved
1715

1816
## 4.0.2
1917

Readme.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ See [Changelog.md](Changelog.md)
2525

2626
## Options
2727

28-
- `tablename='sessions'` Tablename to use. Defaults to 'sessions'.
29-
- `sidfieldname='sid'` Field name in table to use for storing session ids. Defaults to 'sid'.
28+
- `cleanupInterval` milliseconds between clearing expired sessions. Defaults to 60000. 0 disables the automatic clearing of expired sessions.
29+
- `createTable` if the table for sessions should be created automatically or not.
3030
- `knex` knex instance to use. Defaults to a new knex instance, using sqlite3 with a file named 'connect-session-knex.sqlite'
31-
- `createtable` if the table for sessions should be created automatically or not.
32-
- `clearInterval` milliseconds between clearing expired sessions. Defaults to 60000.
33-
- `disableDbCleanup` disables the automatic clearing of expired sessions. Defaults to false.
31+
- `tableName='sessions'` Tablename to use. Defaults to 'sessions'.
32+
- `sidFieldName='sid'` Field name in table to use for storing session ids. Defaults to 'sid'.
3433

35-
If the table does not exist in the schema, this module will attempt to create it unless the 'createtable' option is false.
34+
If the table does not exist in the schema, this module will attempt to create it unless the `createTable` option is false.
3635

37-
If a knex instance is not provided, this module will attempt to create a sqlite3 database, with a file named 'connect-session-knex.sqlite', in the working directory of the process.
36+
If a knex instance is not provided, this module will attempt to create a sqlite3 database, with a file named `connect-session-knex.sqlite`, in the working directory of the process.
3837

3938
## Schema
4039

dist/index.d.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference types="node" />
2+
import { Knex } from "knex";
3+
import { SessionData, Store } from "express-session";
4+
interface Options {
5+
cleanupInterval: number;
6+
createTable: boolean;
7+
knex: Knex;
8+
onDbCleanupError: (err: unknown) => void;
9+
tableName: string;
10+
sidFieldName: string;
11+
}
12+
export declare class ConnectSessionKnexStore extends Store {
13+
options: Options;
14+
nextDbCleanup: NodeJS.Timeout | undefined;
15+
ready: Promise<unknown>;
16+
constructor(incomingOptions: Partial<Options>);
17+
get(sid: string, callback: (err: any, session?: SessionData | null) => void): Promise<SessionData | null>;
18+
set(sid: string, session: SessionData, callback?: (err?: any) => void): Promise<void>;
19+
touch(sid: string, session: SessionData, callback?: () => void): Promise<void>;
20+
destroy(sid: string, callback?: (err?: any) => void): Promise<number>;
21+
length(callback: (err: any, length?: number) => void): Promise<number | undefined>;
22+
clear(callback?: (err?: any) => void): Promise<number>;
23+
all(callback: (err: any, obj?: SessionData[] | {
24+
[sid: string]: SessionData;
25+
} | null) => void): Promise<any[]>;
26+
private dbCleanup;
27+
}
28+
export {};
29+
//# sourceMappingURL=index.d.ts.map

dist/index.d.ts.map

+1
Original file line numberDiff line numberDiff line change

dist/index.js

+255
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)