Update session-file-store (#22602)

This commit is contained in:
Junyoung Choi (Sai)
2018-01-09 03:34:12 +09:00
committed by Ryan Cavanaugh
parent 488ae4510d
commit 2cede8d8c9
2 changed files with 16 additions and 57 deletions

View File

@@ -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 <https://github.com/blendsdk>
// Junyoung Choi <https://github.com/rokt33r>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="express-session" />
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;
}

View File

@@ -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);