diff --git a/types/session-file-store/index.d.ts b/types/session-file-store/index.d.ts index 07afc37c1f..0cbe77d9ef 100644 --- a/types/session-file-store/index.d.ts +++ b/types/session-file-store/index.d.ts @@ -1,14 +1,21 @@ -// Type definitions for express session-file-store 1.0 +// Type definitions for express session-file-store 1.2 // Project: https://github.com/valery-barysok/session-file-store // Definitions by: Gevik Babakhani +// Junyoung Choi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -/// +import * as express from "express"; +import * as session from "express-session"; -export = FileStore; +export = f; -declare namespace FileStore { +declare function f(options: (options?: session.SessionOptions) => express.RequestHandler): f.FileStore; + +declare namespace f { + interface FileStore { + new (options?: Options): session.Store; + } /** * FileStore Options */ @@ -121,51 +128,3 @@ declare namespace FileStore { keyFunction?(secret: string, sessionId: string): string; } } - -/** - * Session file store is a provision for storing session data in - * the session file - */ -declare class FileStore { - /** - * Creates an instance of FileStore. - */ - constructor(options: FileStore.Options); - - /** - * Attempts to fetch session from a session file by the given `sessionId` - */ - get(sessionId: string, callback: (err: any, session: Express.Session) => void): void; - - /** - * Attempts to commit the given session associated with the given `sessionId` to a session file - */ - set(sessionId: string, session: Express.Session, callback: (err: any) => void): void; - - /** - * Touch the given session object associated with the given `sessionId` - */ - touch(sessionId: string, session: Express.Session, callback: (err: any) => void): void; - - /** - * Attempts to unlink a given session by its id - */ - destroy(sessionId: string, callback: (err: any) => void): void; - - /** - * Attempts to fetch number of the session files - */ - length(callback: (err: any, length: number) => void): void; - - /** - * Attempts to clear out all of the existing session files - */ - clear(callback: (err: any) => void): void; - - list(callback: (err: any, files: string[]) => void): void; - - /** - * Attempts to detect whether a session file is already expired or not - */ - expired(sessionId: string, callback: (errr: any, isExpired: boolean) => void): void; -} diff --git a/types/session-file-store/session-file-store-tests.ts b/types/session-file-store/session-file-store-tests.ts index 50d30da2ac..001aacca60 100644 --- a/types/session-file-store/session-file-store-tests.ts +++ b/types/session-file-store/session-file-store-tests.ts @@ -1,11 +1,11 @@ -import FileStore = require("session-file-store"); +import session = require("express-session"); +import f = require("session-file-store"); -const options: FileStore.Options = { +const options: f.Options = { path: "./tmp/sessions/", logFn: (a: string) => { } }; +const FileStore = f(session); -const sessionStore = new FileStore(options); - -sessionStore.list((err: any, file: string[]) => {}); +const sessionStore: session.Store = new FileStore(options);