Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import + update typings from DefinitelyTyped #155

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Type definitions for connect-pg-simple 4.2

import { RequestHandler } from "express";
import { Store, SessionData, SessionOptions } from "express-session";
import { Pool, PoolConfig } from "pg";

declare function connectPgSimple(session: (options?: SessionOptions) => RequestHandler): typeof connectPgSimple.PGStore;

declare namespace connectPgSimple {
class PGStore extends Store {
constructor(options?: PGStoreOptions);
close(): void;
pruneSessions(callback?: (err: Error) => void): void;

get(sid: string, callback: (err: any, session?: SessionData | null) => void): void;
set(sid: string, session: SessionData, callback?: (err?: any) => void): void;
destroy(sid: string, callback?: (err?: any) => void): void;

touch(sid: string, session: SessionData, callback?: () => void): void;
}
interface PGStoreOptions {
pool?: Pool;
pgPromise?: object; // not typed to avoid dependency to "pg-promise" module (which includes its own types)
conString?: string;
conObject?: PoolConfig;
ttl?: number;
schemaName?: string;
tableName?: string;
pruneSessionInterval?: false | number;
// tslint:disable-next-line:prefer-method-signature
errorLog?: (...args: any[]) => void;
}
}

export = connectPgSimple;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "6.0.1",
"description": "A simple, minimal PostgreSQL session store for Connect/Express",
"url": "http://github.com/voxpelli/node-connect-pg-simple",
"typings": "index.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/voxpelli/node-connect-pg-simple.git"
Expand Down