mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-17 03:24:15 +08:00
Update session-file-store (#22602)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
488ae4510d
commit
2cede8d8c9
63
types/session-file-store/index.d.ts
vendored
63
types/session-file-store/index.d.ts
vendored
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user