forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
easy-session.d.ts
41 lines (36 loc) · 1.44 KB
/
easy-session.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Type definitions for easy-session
// Project: https://github.com/DeadAlready/node-easy-session
// Definitions by: Karl Düüna <https://github.com/DeadAlready/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../express/express.d.ts" />
declare module Express {
interface ErrorCallback {
(err?: any): void;
}
export interface Session {
login(callback: Function): void;
login(extend: Object, callback: ErrorCallback): void;
login(role: string, callback: ErrorCallback): void;
login(role: string, extend: Object, callback: ErrorCallback): void;
logout(callback: ErrorCallback): void;
isLoggedIn(role?: string): boolean;
isGuest(): boolean;
isFresh(): boolean;
setRole(role: string): Session;
getRole(): string;
hasRole(role: string): boolean;
}
}
declare module "easy-session" {
import express = require('express');
interface SessionOptions {
ipCheck?: boolean;
uaCheck?: boolean;
freshTimeout?: number;
maxFreshTimeout?: number;
}
export function main(session: any, options?: SessionOptions): express.RequestHandler;
export function isLoggedIn(errorCallback?: Function): express.RequestHandler;
export function isFresh(errorCallback?: Function): express.RequestHandler;
export function checkRole(role: string, errorCallback?: Function): express.RequestHandler;
}