├── .gitignore ├── README.md ├── package.json ├── src ├── app.ts ├── index.ts ├── routes.ts ├── storage.spec.ts └── storage.ts ├── test ├── mocha.js └── mocha.opts ├── tsconfig.json ├── tslint.json ├── typings ├── assertion-error │ └── assertion-error.d.ts ├── bcryptjs │ └── bcryptjs.d.ts ├── bluebird │ └── bluebird.d.ts ├── body-parser │ └── body-parser.d.ts ├── bunyan │ └── bunyan.d.ts ├── chai │ └── chai.d.ts ├── connect-flash │ └── connect-flash.d.ts ├── consolidate │ └── consolidate.d.ts ├── cookie-parser │ └── cookie-parser.d.ts ├── express-serve-static-core │ └── express-serve-static-core.d.ts ├── express-session │ └── express-session.d.ts ├── express │ └── express.d.ts ├── form-data │ └── form-data.d.ts ├── lodash │ └── lodash.d.ts ├── method-override │ └── method-override.d.ts ├── mime │ └── mime.d.ts ├── mocha │ └── mocha.d.ts ├── node-uuid │ ├── node-uuid-base.d.ts │ ├── node-uuid-cjs.d.ts │ └── node-uuid.d.ts ├── node │ └── node.d.ts ├── passport-local │ └── passport-local.d.ts ├── passport │ └── passport.d.ts ├── request-promise │ └── request-promise.d.ts ├── request │ └── request.d.ts ├── sequelize │ └── sequelize.d.ts ├── serve-static │ └── serve-static.d.ts └── validator │ └── validator.d.ts └── views ├── index.dust ├── partials ├── footer.dust ├── header.dust └── loggedin.dust └── settings.dust /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | bld/ 3 | coverage/ 4 | node_modules/ 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # example-typescript-sequelize 2 | 3 | $ npm run build && EXAMPLE_USERNAME=postgresuserfoo npm start -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express-typescript-sequelize", 3 | "version": "1.0.0", 4 | "description": "A proof of concept.", 5 | "main": "bld/app.js", 6 | "scripts": { 7 | "lint": "tslint -c ./tslint.json -t verbose src/**/*.ts", 8 | "prebuild": "npm run lint", 9 | "build": "tsc", 10 | "pretest": "npm run build", 11 | "test": "istanbul cover node_modules/mocha/bin/_mocha -x *.spec.js -- --reporter spec", 12 | "posttest": "istanbul check-coverage --statements 50 --functions 50 --lines 50", 13 | "start": "node bld/app.js | bunyan --no-color --no-pager -0", 14 | "clean": "rimraf bld coverage" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/ngerakines/express-typescript-sequelize" 19 | }, 20 | "author": "Nick Gerakines", 21 | "license": "SEE LICENSE IN LICENSE.md", 22 | "bugs": { 23 | "url": "https://github.com/ngerakines/express-typescript-sequelize/issues" 24 | }, 25 | "homepage": "https://github.com/ngerakines/express-typescript-sequelize#readme", 26 | "devDependencies": { 27 | "chai": "^3.5.0", 28 | "istanbul": "^0.4.3", 29 | "mocha": "^2.4.5", 30 | "mocha-junit-reporter": "^1.10.0", 31 | "request-promise": "^2.0.1", 32 | "rimraf": "^2.5.2", 33 | "source-map-support": "^0.4.0", 34 | "tslint": "^3.7.1", 35 | "typemoq": "0.0.6", 36 | "typescript": "^1.8.9" 37 | }, 38 | "dependencies": { 39 | "bcryptjs": "^2.3.0", 40 | "bluebird": "^3.3.4", 41 | "body-parser": "^1.15.0", 42 | "bunyan": "^1.8.0", 43 | "connect-flash": "^0.1.1", 44 | "consolidate": "^0.14.0", 45 | "cookie-parser": "^1.4.1", 46 | "dustjs-linkedin": "^2.7.2", 47 | "ect": "^0.5.9", 48 | "express": "^4.13.4", 49 | "express-session": "^1.13.0", 50 | "lodash": "^4.9.0", 51 | "method-override": "^2.3.5", 52 | "moment": "^2.12.0", 53 | "node-uuid": "^1.4.7", 54 | "passport": "^0.3.2", 55 | "passport-local": "^1.0.0", 56 | "pg": "^4.5.3", 57 | "request-promise": "^2.0.1", 58 | "sequelize": "^3.21.0" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/app.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ngerakines on 4/11/16. 3 | */ 4 | 5 | import {start} from "./index"; 6 | 7 | start(); 8 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ngerakines on 4/11/16. 3 | */ 4 | 5 | import * as express from "express"; 6 | import methodOverride = require("method-override"); 7 | import bodyParser = require("body-parser"); 8 | import * as Promise from "bluebird"; 9 | import {Logger, createLogger} from "bunyan"; 10 | import * as session from "express-session"; 11 | import * as cookieParser from "cookie-parser"; 12 | var flash = require('connect-flash'); 13 | import * as cons from "consolidate"; 14 | import {compareSync} from "bcryptjs"; 15 | 16 | import * as passport from "passport"; 17 | import {Strategy as LocalStrategy} from "passport-local"; 18 | 19 | import {StorageManager, SequelizeStorageManager} from "./storage"; 20 | import {ApplicationController} from "./routes"; 21 | 22 | function loggedIn(req:express.Request, res:express.Response, next:express.NextFunction) { 23 | if (req.user) { 24 | next(); 25 | } else { 26 | res.redirect("/"); 27 | } 28 | } 29 | 30 | export function configureExpress(logger:Logger, storageManager:StorageManager):Promise { 31 | return Promise 32 | .resolve(express()) 33 | .then((app) => { 34 | app.set('view options', {pretty: false}); 35 | app.set("etag", false); 36 | app.disable("x-powered-by"); 37 | 38 | app.engine("dust", cons.dust); 39 | 40 | app.set("views", __dirname + "/../views"); 41 | app.set("view engine", "dust"); 42 | 43 | app.use(express.static(__dirname + "/../public")); 44 | 45 | passport.use(new LocalStrategy( 46 | function(username, password, done) { 47 | storageManager.getAccountByEmail(username) 48 | .then((account:any) => { 49 | if (account === null) { 50 | return done(null, false, { message: 'Incorrect account.' }); 51 | } 52 | if (compareSync(password, account.password)) { 53 | return done(null, account); 54 | } 55 | return done(null, false, { message: 'Incorrect password.' }); 56 | }) 57 | .catch((err:any) => { 58 | console.log(err); 59 | return done(null, false, { message: 'Internal error.' }); 60 | }); 61 | } 62 | )); 63 | 64 | passport.serializeUser(function(account, done) { 65 | done(null, account.id); 66 | }); 67 | 68 | passport.deserializeUser(function(id, done) { 69 | storageManager.getAccountById(id) 70 | .then((account:any) => { 71 | if (account !== undefined) { 72 | return done(null, account); 73 | } 74 | return done(new Error("Invalid account"), null) 75 | }) 76 | .catch((err:any) => { 77 | done(err, null); 78 | }); 79 | }); 80 | 81 | app.use(methodOverride()); 82 | app.use(bodyParser.json()); 83 | app.use(bodyParser.urlencoded({extended: false})); 84 | 85 | app.use(cookieParser()); 86 | app.use(session({ secret: 'keyboard cat' })); 87 | app.use(passport.initialize()); 88 | app.use(passport.session()); 89 | 90 | app.use(flash()); 91 | 92 | app.use((req:express.Request, res:express.Response, next:express.NextFunction) => { 93 | logger.info({method: req.method, url: req.url, protocol: req.protocol, ip: req.ip, hostname: req.hostname}, req.method + " " + req.path); 94 | next(); 95 | }); 96 | 97 | return app; 98 | }); 99 | } 100 | 101 | export function congifureRoutes(app:express.Application, logger:Logger, storageManager:StorageManager):Promise { 102 | return new Promise((resolve) => { 103 | let applicationController = new ApplicationController(logger, storageManager); 104 | app.get("/", applicationController.home); 105 | app.post("/register", applicationController.completeRegistration); 106 | app.post("/login", 107 | passport.authenticate("local", { successRedirect: "/settings", 108 | failureRedirect: "/", 109 | failureFlash: true }) 110 | ); 111 | app.get('/logout', function(req, res){ 112 | req.logout(); 113 | res.redirect("/"); 114 | }); 115 | app.get("/settings", loggedIn, applicationController.settings); 116 | app.post("/settings/address", loggedIn, applicationController.addAddress); 117 | 118 | resolve(); 119 | }); 120 | } 121 | 122 | export function start(logger?:Logger):Promise { 123 | logger = logger || createLogger({ 124 | name: "express-typescript-sequelize", 125 | stream: process.stdout, 126 | level: "info" 127 | }); 128 | let storageManager = new SequelizeStorageManager({database: "example", username: process.env.EXAMPLE_USERNAME || "username", password: ""}, logger); 129 | 130 | return storageManager.init() 131 | .then(() => { 132 | return configureExpress(logger, storageManager) 133 | .then((app:express.Application) => { 134 | return congifureRoutes(app, logger, storageManager) 135 | .then(() => { 136 | return app; 137 | }); 138 | }) 139 | .then((app:express.Application) => { 140 | return new Promise((resolve) => { 141 | var server = app.listen(3000, () => { 142 | resolve(server); 143 | }); 144 | }); 145 | }) 146 | }); 147 | } 148 | -------------------------------------------------------------------------------- /src/routes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ngerakines on 4/11/16. 3 | */ 4 | 5 | import {Logger} from "bunyan"; 6 | import * as express from "express"; 7 | import {StorageManager} from "./storage"; 8 | 9 | export abstract class BaseController { 10 | protected logger:Logger; 11 | 12 | constructor(logger:Logger) { 13 | this.logger = logger; 14 | } 15 | 16 | } 17 | 18 | interface HomeView { 19 | messages?:any[]; 20 | errors?:any[]; 21 | account?:any; 22 | } 23 | 24 | interface SettingsView { 25 | messages?:any[]; 26 | errors?:any[]; 27 | account?:any; 28 | addresses:any[]; 29 | } 30 | 31 | export class ApplicationController extends BaseController { 32 | 33 | private storageManager:StorageManager; 34 | 35 | constructor(logger:Logger, storageManager:StorageManager) { 36 | super(logger.child({component: "ApplicationController"})); 37 | this.storageManager = storageManager; 38 | } 39 | 40 | home = (req:express.Request, res:express.Response) => { 41 | let view:HomeView = { 42 | messages: req.flash("message"), 43 | errors: req.flash("error") 44 | }; 45 | if (req.user !== undefined) { 46 | view.account = req.user; 47 | } 48 | res.render("index", view); 49 | }; 50 | 51 | completeRegistration = (req:express.Request, res:express.Response) => { 52 | this.storageManager 53 | .register(req.body.name, req.body.email, req.body.password) 54 | .then((account) => { 55 | req.login(account, function(err) { 56 | if (err) { 57 | throw new Error(err.toString()); 58 | } 59 | req.flash("message", "Welcome, " + account.name + "!"); 60 | return res.redirect("/settings"); 61 | }); 62 | }) 63 | .catch((err:any) => { 64 | req.flash("error", "Error creating account."); 65 | return res.redirect("/"); 66 | }) 67 | 68 | }; 69 | 70 | settings = (req:express.Request, res:express.Response) => { 71 | req.user.getAddresses() 72 | .then((addresses:any[]) => { 73 | let view:SettingsView = { 74 | messages: req.flash("message"), 75 | errors: req.flash("error"), 76 | account: req.user, 77 | addresses: addresses 78 | }; 79 | res.render("settings", view); 80 | }) 81 | }; 82 | 83 | addAddress = (req:express.Request, res:express.Response) => { 84 | this.storageManager 85 | .addAddress(req.user, req.body.street, req.body.city, req.body.state, req.body.zip) 86 | .then(() => { 87 | req.flash("message", "Created address!"); 88 | return res.redirect("/settings"); 89 | }) 90 | .catch((err:any) => { 91 | req.flash("error", "Error creating address."); 92 | return res.redirect("/settings"); 93 | }) 94 | }; 95 | } 96 | -------------------------------------------------------------------------------- /src/storage.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ngerakines on 4/11/16. 3 | */ 4 | 5 | import chai = require("chai"); 6 | var expect = chai.expect; 7 | 8 | import {Logger, createLogger} from "bunyan"; 9 | import {SequelizeStorageManager} from "./storage"; 10 | 11 | //import {Mock, It, Times} from "typemoq"; 12 | 13 | var logger:Logger = createLogger({ 14 | name: "express-typescript-sequelize", 15 | stream: process.stderr, 16 | level: process.env.LOG_LEVEL || "fatal" 17 | }); 18 | 19 | describe("Storage", () => { 20 | 21 | describe("Accounts", () => { 22 | it("can be created", (done) => { 23 | let storage = new SequelizeStorageManager({database: "example-test", username: "username", password: ""}, logger); 24 | storage.init(true) 25 | .then(() => { 26 | return storage.register("Nick Gerakines", "nick@gerakines.net", "password"); 27 | }) 28 | .then((account) => { 29 | expect(account).to.have.property("name", "Nick Gerakines"); 30 | expect(account).to.have.property("email", "nick@gerakines.net"); 31 | expect(account).to.have.property("password"); 32 | }) 33 | .then(() => done()) 34 | .catch((err) => done(err)); 35 | }); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /src/storage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by ngerakines on 4/11/16. 3 | */ 4 | 5 | import * as Promise from "bluebird"; 6 | import * as Sequelize from "sequelize"; 7 | import {Logger} from "bunyan"; 8 | import * as uuid from "node-uuid"; 9 | import {hashSync} from "bcryptjs"; 10 | 11 | export interface AccountAttribute { 12 | id?:string; 13 | name?:string; 14 | email?:string; 15 | password?:string; 16 | } 17 | 18 | export interface AddressAttribute { 19 | id?:string; 20 | street?:string; 21 | city?:string; 22 | state?:string, 23 | zip?:string; 24 | } 25 | 26 | export interface AccountInstance extends Sequelize.Instance, AccountAttribute { 27 | getAddresses: Sequelize.HasManyGetAssociationsMixin; 28 | setAddresses: Sequelize.HasManySetAssociationsMixin; 29 | addAddresses: Sequelize.HasManyAddAssociationsMixin; 30 | addAddress: Sequelize.HasManyAddAssociationMixin; 31 | createAddress: Sequelize.HasManyCreateAssociationMixin; 32 | removeAddress: Sequelize.HasManyRemoveAssociationMixin; 33 | removeAddresses: Sequelize.HasManyRemoveAssociationsMixin; 34 | hasAddress: Sequelize.HasManyHasAssociationMixin; 35 | hasAddresses: Sequelize.HasManyHasAssociationsMixin; 36 | countAddresses: Sequelize.HasManyCountAssociationsMixin; 37 | } 38 | 39 | export interface AddressInstance extends Sequelize.Instance, AddressAttribute { 40 | getAccount: Sequelize.BelongsToGetAssociationMixin; 41 | setAccount: Sequelize.BelongsToSetAssociationMixin; 42 | createAccount: Sequelize.BelongsToCreateAssociationMixin; 43 | } 44 | 45 | export interface AccountModel extends Sequelize.Model { } 46 | 47 | export interface AddresstModel extends Sequelize.Model { } 48 | 49 | export interface SequelizeStorageConfig { 50 | database:string; 51 | username:string; 52 | password:string 53 | } 54 | 55 | export interface StorageManager { 56 | init(force?:boolean):Promise; 57 | register(name:string, email:string, rawPassword:string):Promise; 58 | getAccountById(id:string):Promise; 59 | getAccountByEmail(email:string):Promise; 60 | addAddress(account:any, street:string, city:string, state:string, zip:string):Promise; 61 | } 62 | 63 | export class SequelizeStorageManager implements StorageManager { 64 | public sequelize:Sequelize.Sequelize; 65 | /* tslint:disable */ 66 | public Account:AccountModel; 67 | public Address:AddresstModel; 68 | 69 | private logger:Logger; 70 | private config:SequelizeStorageConfig; 71 | 72 | constructor(config:SequelizeStorageConfig, logger:Logger) { 73 | this.config = config; 74 | this.logger = logger.child({component: "Storage"}); 75 | 76 | this.sequelize = new Sequelize(this.config.database, this.config.username, this.config.password, { dialect: "postgres" }); 77 | this.Account = this.sequelize.define("Account", { 78 | "id": { 79 | "type": Sequelize.UUID, 80 | "allowNull": false, 81 | "primaryKey": true 82 | }, 83 | "name": { 84 | "type": Sequelize.STRING(128), 85 | "allowNull": false 86 | }, 87 | "email": { 88 | "type": Sequelize.STRING(128), 89 | "allowNull": false, 90 | "unique": true, 91 | "validate": { 92 | "isEmail": true 93 | } 94 | }, 95 | "password": { 96 | "type": Sequelize.STRING(128), 97 | "allowNull": false 98 | } 99 | }, 100 | { 101 | "tableName": "accounts", 102 | "timestamps": true, 103 | "createdAt": "created_at", 104 | "updatedAt": "updated_at", 105 | }); 106 | this.Address = this.sequelize.define("Address", { 107 | "id": { 108 | "type": Sequelize.UUID, 109 | "allowNull": false, 110 | "primaryKey": true 111 | }, 112 | "street": { 113 | "type": Sequelize.STRING(128), 114 | "allowNull": false 115 | }, 116 | "city": { 117 | "type": Sequelize.STRING(128), 118 | "allowNull": false 119 | }, 120 | "state": { 121 | "type": Sequelize.STRING(128), 122 | "allowNull": false 123 | }, 124 | "zip": { 125 | "type": Sequelize.INTEGER, 126 | "allowNull": false 127 | } 128 | }, 129 | { 130 | "tableName": "addresses", 131 | "timestamps": true, 132 | "createdAt": "created_at", 133 | "updatedAt": "updated_at", 134 | }); 135 | 136 | this.Address.belongsTo(this.Account); 137 | this.Account.hasMany(this.Address); 138 | } 139 | 140 | init(force?:boolean):Promise { 141 | force = force || false; 142 | return this.sequelize.sync({force: force, logging: true}); 143 | } 144 | 145 | register(name:string, email:string, rawPassword:string):Promise { 146 | return this.sequelize.transaction((transaction:Sequelize.Transaction) => { 147 | let accountId = uuid.v4(); 148 | return this.hashPassword(rawPassword) 149 | .then((password) => { 150 | return this.Account 151 | .create({ 152 | id: accountId, 153 | name: name, 154 | email: email, 155 | password: password 156 | }, {transaction: transaction}) 157 | }); 158 | }); 159 | } 160 | 161 | getAccountById(id:string):Promise { 162 | return this.Account.find({where: {id: id}}); 163 | } 164 | 165 | getAccountByEmail(email:string):Promise { 166 | return this.Account.find({where: {email: email}}); 167 | } 168 | 169 | addAddress(account:any, street:string, city:string, state:string, zip:string):Promise { 170 | account = account; 171 | return account 172 | .createAddress({ 173 | id: uuid.v4(), 174 | street:street, 175 | city: city, 176 | state: state, 177 | zip: zip 178 | }); 179 | } 180 | 181 | private hashPassword(password:string):Promise { 182 | return new Promise((resolve) => { 183 | resolve(hashSync(password)); 184 | }); 185 | } 186 | 187 | } 188 | -------------------------------------------------------------------------------- /test/mocha.js: -------------------------------------------------------------------------------- 1 | require('source-map-support').install(); 2 | require('chai').expect(); 3 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --require ./test/mocha 2 | 3 | bld/**/*.spec.js 4 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "noResolve": false, 6 | "experimentalDecorators": true, 7 | "noEmitOnError": true, 8 | "noImplicitAny": true, 9 | "declaration": true, 10 | "sourceMap": true, 11 | "sourceRoot": "src", 12 | "outDir": "bld" 13 | }, 14 | "exclude": [ 15 | "bld", 16 | "node_modules" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "class-name": true, 4 | "curly": true, 5 | "eofline": true, 6 | "indent": "tabs", 7 | "label-position": true, 8 | "label-undefined": true, 9 | "member-ordering": [true, 10 | "public-before-private", 11 | "static-before-instance", 12 | "variables-before-functions" 13 | ], 14 | "no-consecutive-blank-lines": true, 15 | "no-empty": true, 16 | "no-eval": true, 17 | "no-unreachable": true, 18 | "no-unused-expression": true, 19 | "no-unused-variable": true, 20 | "semicolon": "always", 21 | "triple-equals": [true, "allow-null-check"], 22 | "variable-name": [true, "check-format"] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /typings/assertion-error/assertion-error.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for assertion-error 1.0.0 2 | // Project: https://github.com/chaijs/assertion-error 3 | // Definitions by: Bart van der Schoor 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | declare module 'assertion-error' { 7 | class AssertionError implements Error { 8 | constructor(message: string, props?: any, ssf?: Function); 9 | name: string; 10 | message: string; 11 | showDiff: boolean; 12 | stack: string; 13 | } 14 | export = AssertionError; 15 | } 16 | -------------------------------------------------------------------------------- /typings/bcryptjs/bcryptjs.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for bcryptjs v2.3.0 2 | // Project: https://github.com/dcodeIO/bcrypt.js 3 | // Definitions by: Joshua Filby 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | declare module "bcryptjs" { 7 | 8 | /** 9 | * Sets the pseudo random number generator to use as a fallback if neither node's crypto module nor the Web Crypto API is available. 10 | * Please note: It is highly important that the PRNG used is cryptographically secure and that it is seeded properly! 11 | * @param random Function taking the number of bytes to generate as its sole argument, returning the corresponding array of cryptographically secure random byte values. 12 | */ 13 | export function setRandomFallback(random: (random: number) => number[]): void; 14 | 15 | /** 16 | * Synchronously generates a salt. 17 | * @param rounds Number of rounds to use, defaults to 10 if omitted 18 | * @return Resulting salt 19 | */ 20 | export function genSaltSync(rounds?: number): string; 21 | 22 | /** 23 | * Asynchronously generates a salt. 24 | * @param callback Callback receiving the error, if any, and the resulting salt 25 | */ 26 | export function genSalt(callback: (err: Error, salt: string) => void): void; 27 | 28 | /** 29 | * Asynchronously generates a salt. 30 | * @param rounds Number of rounds to use, defaults to 10 if omitted 31 | * @param callback Callback receiving the error, if any, and the resulting salt 32 | */ 33 | export function genSalt(rounds: number, callback: (err: Error, salt: string) => void): void; 34 | 35 | /** 36 | * Synchronously generates a hash for the given string. 37 | * @param s String to hash 38 | * @param salt Salt length to generate or salt to use, default to 10 39 | * @return Resulting hash 40 | */ 41 | export function hashSync(s: string, salt?: number | string): string; 42 | 43 | /** 44 | * Asynchronously generates a hash for the given string. 45 | * @param s String to hash 46 | * @param salt Salt length to generate or salt to use 47 | * @param callback Callback receiving the error, if any, and the resulting hash 48 | * @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms. 49 | */ 50 | export function hash(s: string, salt: number | string, callback: (err: Error, hash: string) => void, progressCallback?: (percent: number) => void): void; 51 | 52 | /** 53 | * Synchronously tests a string against a hash. 54 | * @param s String to compare 55 | * @param hash Hash to test against 56 | * @return true if matching, otherwise false 57 | */ 58 | export function compareSync(s: string, hash: string): boolean; 59 | 60 | /** 61 | * Asynchronously compares the given data against the given hash. 62 | * @param s Data to compare 63 | * @param hash Data to be compared to 64 | * @param callback Callback receiving the error, if any, otherwise the result 65 | * @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms. 66 | */ 67 | export function compare(s: string, hash: string, callback: (err: Error, success: boolean) => void, progressCallback?: (percent: number) => void): void; 68 | 69 | /** 70 | * Gets the number of rounds used to encrypt the specified hash. 71 | * @param hash Hash to extract the used number of rounds from 72 | * @return Number of rounds used 73 | */ 74 | export function getRounds(hash: string): number; 75 | 76 | /** 77 | * Gets the salt portion from a hash. Does not validate the hash. 78 | * @param hash Hash to extract the salt from 79 | * @return Extracted salt part 80 | */ 81 | export function getSalt(hash: string): string; 82 | } 83 | -------------------------------------------------------------------------------- /typings/bluebird/bluebird.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for bluebird 2.0.0 2 | // Project: https://github.com/petkaantonov/bluebird 3 | // Definitions by: Bart van der Schoor , falsandtru 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | // ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts 7 | // By: Campredon 8 | 9 | // Warning: recommended to use `tsc > v0.9.7` (critical bugs in earlier generic code): 10 | // - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/1563 11 | 12 | // Note: replicate changes to all overloads in both definition and test file 13 | // Note: keep both static and instance members inline (so similar) 14 | 15 | // TODO fix remaining TODO annotations in both definition and test 16 | 17 | // TODO verify support to have no return statement in handlers to get a Promise (more overloads?) 18 | 19 | declare var Promise: PromiseConstructor; 20 | 21 | interface PromiseConstructor { 22 | /** 23 | * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. 24 | */ 25 | new (callback: (resolve: (thenableOrResult?: T | PromiseLike) => void, reject: (error: any) => void) => void): Promise; 26 | 27 | config(options: { 28 | warnings?: boolean | {wForgottenReturn?: boolean}; 29 | longStackTraces?: boolean; 30 | cancellation?: boolean; 31 | monitoring?: boolean; 32 | }): void; 33 | 34 | // Ideally, we'd define e.g. "export class RangeError extends Error {}", 35 | // but as Error is defined as an interface (not a class), TypeScript doesn't 36 | // allow extending Error, only implementing it. 37 | // However, if we want to catch() only a specific error type, we need to pass 38 | // a constructor function to it. So, as a workaround, we define them here as such. 39 | RangeError(): RangeError; 40 | CancellationError(): Promise.CancellationError; 41 | TimeoutError(): Promise.TimeoutError; 42 | TypeError(): Promise.TypeError; 43 | RejectionError(): Promise.RejectionError; 44 | OperationalError(): Promise.OperationalError; 45 | 46 | /** 47 | * Changes how bluebird schedules calls a-synchronously. 48 | * 49 | * @param scheduler Should be a function that asynchronously schedules 50 | * the calling of the passed in function 51 | */ 52 | setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void; 53 | 54 | /** 55 | * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. 56 | * 57 | * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call. 58 | * 59 | * Alias for `attempt();` for compatibility with earlier ECMAScript version. 60 | */ 61 | try(fn: () => T | PromiseLike, args?: any[], ctx?: any): Promise; 62 | 63 | attempt(fn: () => T | PromiseLike, args?: any[], ctx?: any): Promise; 64 | 65 | /** 66 | * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. 67 | * This method is convenient when a function can sometimes return synchronously or throw synchronously. 68 | */ 69 | method(fn: Function): Function; 70 | 71 | /** 72 | * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state. 73 | */ 74 | resolve(value: T | PromiseLike): Promise; 75 | resolve(): Promise; 76 | 77 | /** 78 | * Create a promise that is rejected with the given `reason`. 79 | */ 80 | reject(reason: any): Promise; 81 | reject(reason: any): Promise; 82 | 83 | /** 84 | * Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution). 85 | */ 86 | defer(): Promise.Resolver; 87 | 88 | /** 89 | * Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable. 90 | */ 91 | cast(value: T | PromiseLike): Promise; 92 | 93 | /** 94 | * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. 95 | */ 96 | bind(thisArg: any): Promise; 97 | 98 | /** 99 | * See if `value` is a trusted Promise. 100 | */ 101 | is(value: any): boolean; 102 | 103 | /** 104 | * Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. 105 | */ 106 | longStackTraces(): void; 107 | 108 | /** 109 | * Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise. 110 | */ 111 | // TODO enable more overloads 112 | delay(ms: number, value: T | PromiseLike): Promise; 113 | delay(ms: number): Promise; 114 | 115 | /** 116 | * Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. 117 | * 118 | * If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them. 119 | * 120 | * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`. 121 | */ 122 | promisify(func: (callback: (err: any, result: T) => void) => void, receiver?: any): () => Promise; 123 | promisify(func: (arg1: A1, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1) => Promise; 124 | promisify(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2) => Promise; 125 | promisify(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3) => Promise; 126 | promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Promise; 127 | promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Promise; 128 | promisify(nodeFunction: Function, receiver?: any): Function; 129 | 130 | /** 131 | * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object. 132 | * 133 | * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. 134 | */ 135 | // TODO how to model promisifyAll? 136 | promisifyAll(target: Object, options?: Promise.PromisifyAllOptions): any; 137 | 138 | 139 | /** 140 | * Returns a promise that is resolved by a node style callback function. 141 | */ 142 | fromNode(resolver: (callback: (err: any, result?: any) => void) => void, options? : {multiArgs? : boolean}): Promise; 143 | fromCallback(resolver: (callback: (err: any, result?: any) => void) => void, options? : {multiArgs? : boolean}): Promise; 144 | 145 | /** 146 | * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. 147 | */ 148 | // TODO fix coroutine GeneratorFunction 149 | coroutine(generatorFunction: Function): Function; 150 | 151 | /** 152 | * Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. 153 | */ 154 | // TODO fix spawn GeneratorFunction 155 | spawn(generatorFunction: Function): Promise; 156 | 157 | /** 158 | * This is relevant to browser environments with no module loader. 159 | * 160 | * Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else. 161 | */ 162 | noConflict(): typeof Promise; 163 | 164 | /** 165 | * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers. 166 | * 167 | * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections. 168 | */ 169 | onPossiblyUnhandledRejection(handler: (reason: any) => any): void; 170 | 171 | /** 172 | * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason. 173 | */ 174 | // TODO enable more overloads 175 | // promise of array with promises of value 176 | all(values: PromiseLike[]>): Promise; 177 | // promise of array with values 178 | all(values: PromiseLike): Promise; 179 | // array with promises of value 180 | all(values: PromiseLike[]): Promise; 181 | // array with promises of different types 182 | all(values: [PromiseLike, PromiseLike, PromiseLike, PromiseLike, PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; 183 | all(values: [PromiseLike, PromiseLike, PromiseLike, PromiseLike]): Promise<[T1, T2, T3, T4]>; 184 | all(values: [PromiseLike, PromiseLike, PromiseLike]): Promise<[T1, T2, T3]>; 185 | all(values: [PromiseLike, PromiseLike]): Promise<[T1, T2]>; 186 | // array with values 187 | all(values: T[]): Promise; 188 | 189 | /** 190 | * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. 191 | * 192 | * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties. 193 | * 194 | * *The original object is not modified.* 195 | */ 196 | // TODO verify this is correct 197 | // trusted promise for object 198 | props(object: Promise): Promise; 199 | // object 200 | props(object: Object): Promise; 201 | 202 | /** 203 | * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array. 204 | * 205 | * *original: The array is not modified. The input array sparsity is retained in the resulting array.* 206 | */ 207 | // promise of array with promises of value 208 | settle(values: PromiseLike[]>): Promise[]>; 209 | // promise of array with values 210 | settle(values: PromiseLike): Promise[]>; 211 | // array with promises of value 212 | settle(values: PromiseLike[]): Promise[]>; 213 | // array with values 214 | settle(values: T[]): Promise[]>; 215 | 216 | /** 217 | * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly. 218 | */ 219 | // promise of array with promises of value 220 | any(values: PromiseLike[]>): Promise; 221 | // promise of array with values 222 | any(values: PromiseLike): Promise; 223 | // array with promises of value 224 | any(values: PromiseLike[]): Promise; 225 | // array with values 226 | any(values: T[]): Promise; 227 | 228 | /** 229 | * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value. 230 | * 231 | * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending. 232 | */ 233 | // promise of array with promises of value 234 | race(values: PromiseLike[]>): Promise; 235 | // promise of array with values 236 | race(values: PromiseLike): Promise; 237 | // array with promises of value 238 | race(values: PromiseLike[]): Promise; 239 | // array with values 240 | race(values: T[]): Promise; 241 | 242 | /** 243 | * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. 244 | * 245 | * If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in. 246 | * 247 | * *The original array is not modified.* 248 | */ 249 | // promise of array with promises of value 250 | some(values: PromiseLike[]>, count: number): Promise; 251 | // promise of array with values 252 | some(values: PromiseLike, count: number): Promise; 253 | // array with promises of value 254 | some(values: PromiseLike[], count: number): Promise; 255 | // array with values 256 | some(values: T[], count: number): Promise; 257 | 258 | /** 259 | * Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments. 260 | */ 261 | // variadic array with promises of value 262 | join(...values: PromiseLike[]): Promise; 263 | // variadic array with values 264 | join(...values: T[]): Promise; 265 | 266 | /** 267 | * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. 268 | * 269 | * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. 270 | * 271 | * *The original array is not modified.* 272 | */ 273 | // promise of array with promises of value 274 | map(values: PromiseLike[]>, mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; 275 | 276 | // promise of array with values 277 | map(values: PromiseLike, mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; 278 | 279 | // array with promises of value 280 | map(values: PromiseLike[], mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; 281 | 282 | // array with values 283 | map(values: T[], mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; 284 | 285 | /** 286 | * Similar to `map` with concurrency set to 1 but guaranteed to execute in sequential order 287 | * 288 | * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. 289 | * 290 | * *The original array is not modified.* 291 | */ 292 | // promise of array with promises of value 293 | mapSeries(values: PromiseLike[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike): Promise; 294 | 295 | // promise of array with values 296 | mapSeries(values: PromiseLike, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike): Promise; 297 | 298 | // array with promises of value 299 | mapSeries(values: PromiseLike[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike): Promise; 300 | 301 | // array with values 302 | mapSeries(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike): Promise; 303 | 304 | 305 | /** 306 | * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. 307 | * 308 | * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. 309 | * 310 | * *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.* 311 | */ 312 | // promise of array with promises of value 313 | reduce(values: PromiseLike[]>, reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; 314 | 315 | // promise of array with values 316 | reduce(values: PromiseLike, reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; 317 | 318 | // array with promises of value 319 | reduce(values: PromiseLike[], reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; 320 | 321 | // array with values 322 | reduce(values: T[], reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; 323 | 324 | /** 325 | * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. 326 | * 327 | * The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result. 328 | * 329 | * *The original array is not modified. 330 | */ 331 | // promise of array with promises of value 332 | filter(values: PromiseLike[]>, filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike, option?: Promise.ConcurrencyOption): Promise; 333 | 334 | // promise of array with values 335 | filter(values: PromiseLike, filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike, option?: Promise.ConcurrencyOption): Promise; 336 | 337 | // array with promises of value 338 | filter(values: PromiseLike[], filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike, option?: Promise.ConcurrencyOption): Promise; 339 | 340 | // array with values 341 | filter(values: T[], filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike, option?: Promise.ConcurrencyOption): Promise; 342 | 343 | /** 344 | * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. 345 | * 346 | * Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. 347 | */ 348 | // promise of array with promises of value 349 | each(values: PromiseLike[]>, iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike): Promise; 350 | // array with promises of value 351 | each(values: PromiseLike[], iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike): Promise; 352 | // array with values OR promise of array with values 353 | each(values: T[] | PromiseLike, iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike): Promise; 354 | } 355 | 356 | interface Promise extends PromiseLike, Promise.Inspection { 357 | /** 358 | * Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. 359 | */ 360 | then(onFulfill: (value: T) => U | PromiseLike, onReject?: (error: any) => U | PromiseLike, onProgress?: (note: any) => any): Promise; 361 | then(onFulfill: (value: T) => U | PromiseLike, onReject?: (error: any) => void | PromiseLike, onProgress?: (note: any) => any): Promise; 362 | 363 | /** 364 | * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. 365 | * 366 | * Alias `.caught();` for compatibility with earlier ECMAScript version. 367 | */ 368 | catch(onReject?: (error: any) => T | PromiseLike | void | PromiseLike): Promise; 369 | caught(onReject?: (error: any) => T | PromiseLike | void | PromiseLike): Promise; 370 | 371 | catch(onReject?: (error: any) => U | PromiseLike): Promise; 372 | caught(onReject?: (error: any) => U | PromiseLike): Promise; 373 | 374 | /** 375 | * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. 376 | * 377 | * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called. 378 | * 379 | * Alias `.caught();` for compatibility with earlier ECMAScript version. 380 | */ 381 | catch(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Promise; 382 | caught(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Promise; 383 | 384 | catch(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike): Promise; 385 | caught(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike): Promise; 386 | 387 | catch(ErrorClass: Function, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Promise; 388 | caught(ErrorClass: Function, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Promise; 389 | 390 | catch(ErrorClass: Function, onReject: (error: any) => U | PromiseLike): Promise; 391 | caught(ErrorClass: Function, onReject: (error: any) => U | PromiseLike): Promise; 392 | 393 | 394 | /** 395 | * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. 396 | */ 397 | error(onReject: (reason: any) => PromiseLike): Promise; 398 | error(onReject: (reason: any) => U): Promise; 399 | 400 | /** 401 | * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. 402 | * 403 | * Alias `.lastly();` for compatibility with earlier ECMAScript version. 404 | */ 405 | finally(handler: () => U | PromiseLike): Promise; 406 | 407 | lastly(handler: () => U | PromiseLike): Promise; 408 | 409 | /** 410 | * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. 411 | */ 412 | bind(thisArg: any): Promise; 413 | 414 | /** 415 | * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error. 416 | */ 417 | done(onFulfilled?: (value: T) => PromiseLike, onRejected?: (error: any) => U | PromiseLike, onProgress?: (note: any) => any): void; 418 | done(onFulfilled?: (value: T) => U, onRejected?: (error: any) => U | PromiseLike, onProgress?: (note: any) => any): void; 419 | 420 | /** 421 | * Like `.finally()`, but not called for rejections. 422 | */ 423 | tap(onFulFill: (value: T) => U | PromiseLike): Promise; 424 | 425 | /** 426 | * Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise. 427 | */ 428 | progressed(handler: (note: any) => any): Promise; 429 | 430 | /** 431 | * Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 432 | */ 433 | delay(ms: number): Promise; 434 | 435 | /** 436 | * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance. 437 | * 438 | * You may specify a custom error message with the `message` parameter. 439 | */ 440 | timeout(ms: number, message?: string): Promise; 441 | 442 | /** 443 | * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success. 444 | * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything. 445 | */ 446 | nodeify(callback: (err: any, value?: T) => void, options?: Promise.SpreadOption): Promise; 447 | nodeify(...sink: any[]): Promise; 448 | 449 | /** 450 | * Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise. 451 | */ 452 | cancellable(): Promise; 453 | 454 | /** 455 | * Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending. 456 | * 457 | * That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason. 458 | * 459 | * In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`. 460 | * 461 | * Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable. 462 | */ 463 | // TODO what to do with this? 464 | cancel(reason?: any): Promise; 465 | 466 | /** 467 | * Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors. 468 | */ 469 | fork(onFulfilled?: (value: T) => U | PromiseLike, onRejected?: (error: any) => U | PromiseLike, onProgress?: (note: any) => any): Promise; 470 | 471 | /** 472 | * Create an uncancellable promise based on this promise. 473 | */ 474 | uncancellable(): Promise; 475 | 476 | /** 477 | * See if this promise can be cancelled. 478 | */ 479 | isCancellable(): boolean; 480 | 481 | /** 482 | * See if this `promise` has been fulfilled. 483 | */ 484 | isFulfilled(): boolean; 485 | 486 | /** 487 | * See if this `promise` has been rejected. 488 | */ 489 | isRejected(): boolean; 490 | 491 | /** 492 | * See if this `promise` is still defer. 493 | */ 494 | isPending(): boolean; 495 | 496 | /** 497 | * See if this `promise` is resolved -> either fulfilled or rejected. 498 | */ 499 | isResolved(): boolean; 500 | 501 | /** 502 | * Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet. 503 | * 504 | * throws `TypeError` 505 | */ 506 | value(): T; 507 | 508 | /** 509 | * Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet. 510 | * 511 | * throws `TypeError` 512 | */ 513 | reason(): any; 514 | 515 | /** 516 | * Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`. 517 | */ 518 | inspect(): Promise.Inspection; 519 | 520 | /** 521 | * This is a convenience method for doing: 522 | * 523 | * 524 | * promise.then(function(obj){ 525 | * return obj[propertyName].call(obj, arg...); 526 | * }); 527 | * 528 | */ 529 | call(propertyName: string, ...args: any[]): Promise; 530 | 531 | /** 532 | * This is a convenience method for doing: 533 | * 534 | * 535 | * promise.then(function(obj){ 536 | * return obj[propertyName]; 537 | * }); 538 | * 539 | */ 540 | // TODO find way to fix get() 541 | // get(propertyName: string): Promise; 542 | 543 | /** 544 | * Convenience method for: 545 | * 546 | * 547 | * .then(function() { 548 | * return value; 549 | * }); 550 | * 551 | * 552 | * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()` 553 | * 554 | * Alias `.thenReturn();` for compatibility with earlier ECMAScript version. 555 | */ 556 | return(): Promise; 557 | thenReturn(): Promise; 558 | return(value: U): Promise; 559 | thenReturn(value: U): Promise; 560 | 561 | /** 562 | * Convenience method for: 563 | * 564 | * 565 | * .then(function() { 566 | * throw reason; 567 | * }); 568 | * 569 | * Same limitations apply as with `.return()`. 570 | * 571 | * Alias `.thenThrow();` for compatibility with earlier ECMAScript version. 572 | */ 573 | throw(reason: Error): Promise; 574 | thenThrow(reason: Error): Promise; 575 | 576 | /** 577 | * Convert to String. 578 | */ 579 | toString(): string; 580 | 581 | /** 582 | * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`. 583 | */ 584 | toJSON(): Object; 585 | 586 | /** 587 | * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers. 588 | */ 589 | // TODO how to model instance.spread()? like Q? 590 | spread(onFulfill: Function, onReject?: (reason: any) => U | PromiseLike): Promise; 591 | /* 592 | // TODO or something like this? 593 | spread(onFulfill: (...values: W[]) => PromiseLike, onReject?: (reason: any) => PromiseLike): Promise; 594 | spread(onFulfill: (...values: W[]) => PromiseLike, onReject?: (reason: any) => U): Promise; 595 | spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => PromiseLike): Promise; 596 | spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise; 597 | */ 598 | /** 599 | * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 600 | */ 601 | // TODO type inference from array-resolving promise? 602 | all(): Promise; 603 | 604 | /** 605 | * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 606 | */ 607 | // TODO how to model instance.props()? 608 | props(): Promise; 609 | 610 | /** 611 | * Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 612 | */ 613 | // TODO type inference from array-resolving promise? 614 | settle(): Promise[]>; 615 | 616 | /** 617 | * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 618 | */ 619 | // TODO type inference from array-resolving promise? 620 | any(): Promise; 621 | 622 | /** 623 | * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 624 | */ 625 | // TODO type inference from array-resolving promise? 626 | some(count: number): Promise; 627 | 628 | /** 629 | * Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 630 | */ 631 | // TODO type inference from array-resolving promise? 632 | race(): Promise; 633 | 634 | /** 635 | * Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 636 | */ 637 | // TODO type inference from array-resolving promise? 638 | map(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; 639 | 640 | /** 641 | * Same as `Promise.mapSeries(thisPromise, mapper)`. 642 | */ 643 | // TODO type inference from array-resolving promise? 644 | mapSeries(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike): Promise; 645 | 646 | /** 647 | * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 648 | */ 649 | // TODO type inference from array-resolving promise? 650 | reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; 651 | 652 | /** 653 | * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 654 | */ 655 | // TODO type inference from array-resolving promise? 656 | filter(filterer: (item: U, index: number, arrayLength: number) => boolean | PromiseLike, options?: Promise.ConcurrencyOption): Promise; 657 | 658 | /** 659 | * Same as calling ``Promise.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. 660 | */ 661 | each(iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike): Promise; 662 | } 663 | 664 | /** 665 | * Don't use variable namespace such as variables, functions, and classes. 666 | * If you use this namespace, it will conflict in es6. 667 | */ 668 | declare namespace Promise { 669 | export interface RangeError extends Error { 670 | } 671 | export interface CancellationError extends Error { 672 | } 673 | export interface TimeoutError extends Error { 674 | } 675 | export interface TypeError extends Error { 676 | } 677 | export interface RejectionError extends Error { 678 | } 679 | export interface OperationalError extends Error { 680 | } 681 | 682 | export interface ConcurrencyOption { 683 | concurrency: number; 684 | } 685 | export interface SpreadOption { 686 | spread: boolean; 687 | } 688 | export interface PromisifyAllOptions { 689 | suffix?: string; 690 | filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean; 691 | // The promisifier gets a reference to the original method and should return a function which returns a promise 692 | promisifier?: (originalMethod: Function) => () => PromiseLike; 693 | } 694 | 695 | export interface Resolver { 696 | /** 697 | * Returns a reference to the controlled promise that can be passed to clients. 698 | */ 699 | promise: Promise; 700 | 701 | /** 702 | * Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state. 703 | */ 704 | resolve(value: T): void; 705 | resolve(): void; 706 | 707 | /** 708 | * Reject the underlying promise with `reason` as the rejection reason. 709 | */ 710 | reject(reason: any): void; 711 | 712 | /** 713 | * Progress the underlying promise with `value` as the progression value. 714 | */ 715 | progress(value: any): void; 716 | 717 | /** 718 | * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. 719 | * 720 | * If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values. 721 | */ 722 | // TODO specify resolver callback 723 | callback: (err: any, value: T, ...values: T[]) => void; 724 | } 725 | 726 | export interface Inspection { 727 | /** 728 | * See if the underlying promise was fulfilled at the creation time of this inspection object. 729 | */ 730 | isFulfilled(): boolean; 731 | 732 | /** 733 | * See if the underlying promise was rejected at the creation time of this inspection object. 734 | */ 735 | isRejected(): boolean; 736 | 737 | /** 738 | * See if the underlying promise was defer at the creation time of this inspection object. 739 | */ 740 | isPending(): boolean; 741 | 742 | /** 743 | * Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object. 744 | * 745 | * throws `TypeError` 746 | */ 747 | value(): T; 748 | 749 | /** 750 | * Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object. 751 | * 752 | * throws `TypeError` 753 | */ 754 | reason(): any; 755 | } 756 | } 757 | 758 | declare module 'bluebird' { 759 | export = Promise; 760 | } 761 | -------------------------------------------------------------------------------- /typings/body-parser/body-parser.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for body-parser 2 | // Project: http://expressjs.com 3 | // Definitions by: Santi Albo , VILIC VANE , Jonathan Häberle 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare module "body-parser" { 9 | import * as express from "express"; 10 | 11 | /** 12 | * bodyParser: use individual json/urlencoded middlewares 13 | * @deprecated 14 | */ 15 | 16 | function bodyParser(options?: { 17 | /** 18 | * if deflated bodies will be inflated. (default: true) 19 | */ 20 | inflate?: boolean; 21 | /** 22 | * maximum request body size. (default: '100kb') 23 | */ 24 | limit?: any; 25 | /** 26 | * function to verify body content, the parsing can be aborted by throwing an error. 27 | */ 28 | verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void; 29 | /** 30 | * only parse objects and arrays. (default: true) 31 | */ 32 | strict?: boolean; 33 | /** 34 | * passed to JSON.parse(). 35 | */ 36 | receiver?: (key: string, value: any) => any; 37 | /** 38 | * parse extended syntax with the qs module. (default: true) 39 | */ 40 | extended?: boolean; 41 | }): express.RequestHandler; 42 | 43 | namespace bodyParser { 44 | export function json(options?: { 45 | /** 46 | * if deflated bodies will be inflated. (default: true) 47 | */ 48 | inflate?: boolean; 49 | /** 50 | * maximum request body size. (default: '100kb') 51 | */ 52 | limit?: any; 53 | /** 54 | * request content-type to parse, passed directly to the type-is library. (default: 'json') 55 | */ 56 | type?: any; 57 | /** 58 | * function to verify body content, the parsing can be aborted by throwing an error. 59 | */ 60 | verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void; 61 | /** 62 | * only parse objects and arrays. (default: true) 63 | */ 64 | strict?: boolean; 65 | /** 66 | * passed to JSON.parse(). 67 | */ 68 | receiver?: (key: string, value: any) => any; 69 | }): express.RequestHandler; 70 | 71 | export function raw(options?: { 72 | /** 73 | * if deflated bodies will be inflated. (default: true) 74 | */ 75 | inflate?: boolean; 76 | /** 77 | * maximum request body size. (default: '100kb') 78 | */ 79 | limit?: any; 80 | /** 81 | * request content-type to parse, passed directly to the type-is library. (default: 'application/octet-stream') 82 | */ 83 | type?: any; 84 | /** 85 | * function to verify body content, the parsing can be aborted by throwing an error. 86 | */ 87 | verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void; 88 | }): express.RequestHandler; 89 | 90 | export function text(options?: { 91 | /** 92 | * if deflated bodies will be inflated. (default: true) 93 | */ 94 | inflate?: boolean; 95 | /** 96 | * maximum request body size. (default: '100kb') 97 | */ 98 | limit?: any; 99 | /** 100 | * request content-type to parse, passed directly to the type-is library. (default: 'text/plain') 101 | */ 102 | type?: any; 103 | /** 104 | * function to verify body content, the parsing can be aborted by throwing an error. 105 | */ 106 | verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void; 107 | /** 108 | * the default charset to parse as, if not specified in content-type. (default: 'utf-8') 109 | */ 110 | defaultCharset?: string; 111 | }): express.RequestHandler; 112 | 113 | export function urlencoded(options: { 114 | /** 115 | * if deflated bodies will be inflated. (default: true) 116 | */ 117 | inflate?: boolean; 118 | /** 119 | * maximum request body size. (default: '100kb') 120 | */ 121 | limit?: any; 122 | /** 123 | * request content-type to parse, passed directly to the type-is library. (default: 'urlencoded') 124 | */ 125 | type?: any; 126 | /** 127 | * function to verify body content, the parsing can be aborted by throwing an error. 128 | */ 129 | verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void; 130 | /** 131 | * parse extended syntax with the qs module. 132 | */ 133 | extended: boolean; 134 | }): express.RequestHandler; 135 | } 136 | 137 | export = bodyParser; 138 | } 139 | -------------------------------------------------------------------------------- /typings/bunyan/bunyan.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for node-bunyan 2 | // Project: https://github.com/trentm/node-bunyan 3 | // Definitions by: Alex Mikhalev 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare module "bunyan" { 9 | import { EventEmitter } from 'events'; 10 | 11 | class Logger extends EventEmitter { 12 | constructor(options:LoggerOptions); 13 | addStream(stream:Stream):void; 14 | addSerializers(serializers:Serializers):void; 15 | child(options:LoggerOptions, simple?:boolean):Logger; 16 | child(obj:Object, simple?:boolean):Logger; 17 | reopenFileStreams():void; 18 | 19 | level():string|number; 20 | level(value: number | string):void; 21 | levels(name: number | string, value: number | string):void; 22 | 23 | trace(error:Error, format?:any, ...params:any[]):void; 24 | trace(buffer:Buffer, format?:any, ...params:any[]):void; 25 | trace(obj:Object, format?:any, ...params:any[]):void; 26 | trace(format:string, ...params:any[]):void; 27 | debug(error:Error, format?:any, ...params:any[]):void; 28 | debug(buffer:Buffer, format?:any, ...params:any[]):void; 29 | debug(obj:Object, format?:any, ...params:any[]):void; 30 | debug(format:string, ...params:any[]):void; 31 | info(error:Error, format?:any, ...params:any[]):void; 32 | info(buffer:Buffer, format?:any, ...params:any[]):void; 33 | info(obj:Object, format?:any, ...params:any[]):void; 34 | info(format:string, ...params:any[]):void; 35 | warn(error:Error, format?:any, ...params:any[]):void; 36 | warn(buffer:Buffer, format?:any, ...params:any[]):void; 37 | warn(obj:Object, format?:any, ...params:any[]):void; 38 | warn(format:string, ...params:any[]):void; 39 | error(error:Error, format?:any, ...params:any[]):void; 40 | error(buffer:Buffer, format?:any, ...params:any[]):void; 41 | error(obj:Object, format?:any, ...params:any[]):void; 42 | error(format:string, ...params:any[]):void; 43 | fatal(error:Error, format?:any, ...params:any[]):void; 44 | fatal(buffer:Buffer, format?:any, ...params:any[]):void; 45 | fatal(obj:Object, format?:any, ...params:any[]):void; 46 | fatal(format:string, ...params:any[]):void; 47 | } 48 | 49 | interface LoggerOptions { 50 | name: string; 51 | streams?: Stream[]; 52 | level?: string | number; 53 | stream?: NodeJS.WritableStream; 54 | serializers?: Serializers; 55 | src?: boolean; 56 | } 57 | 58 | interface Serializers { 59 | [key:string]: (input:any) => string; 60 | } 61 | 62 | interface Stream { 63 | type?: string; 64 | level?: number | string; 65 | path?: string; 66 | stream?: NodeJS.WritableStream | Stream; 67 | closeOnExit?: boolean; 68 | period?: string; 69 | count?: number; 70 | } 71 | 72 | export var stdSerializers:Serializers; 73 | 74 | export var TRACE:number; 75 | export var DEBUG:number; 76 | export var INFO:number; 77 | export var WARN:number; 78 | export var ERROR:number; 79 | export var FATAL:number; 80 | 81 | export function resolveLevel(value: number | string):number; 82 | 83 | export function createLogger(options:LoggerOptions):Logger; 84 | 85 | class RingBuffer extends EventEmitter { 86 | constructor(options:RingBufferOptions); 87 | 88 | writable:boolean; 89 | records:any[]; 90 | 91 | write(record:any):void; 92 | end(record?:any):void; 93 | destroy():void; 94 | destroySoon():void; 95 | } 96 | 97 | interface RingBufferOptions { 98 | limit?: number; 99 | } 100 | 101 | export function safeCycles():(key:string, value:any) => any; 102 | } 103 | -------------------------------------------------------------------------------- /typings/chai/chai.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for chai 3.4.0 2 | // Project: http://chaijs.com/ 3 | // Definitions by: Jed Mao , 4 | // Bart van der Schoor , 5 | // Andrew Brown , 6 | // Olivier Chevet , 7 | // Matt Wistrand 8 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 9 | 10 | // 11 | 12 | declare namespace Chai { 13 | 14 | interface ChaiStatic { 15 | expect: ExpectStatic; 16 | should(): Should; 17 | /** 18 | * Provides a way to extend the internals of Chai 19 | */ 20 | use(fn: (chai: any, utils: any) => void): ChaiStatic; 21 | assert: AssertStatic; 22 | config: Config; 23 | AssertionError: typeof AssertionError; 24 | } 25 | 26 | export interface ExpectStatic extends AssertionStatic { 27 | fail(actual?: any, expected?: any, message?: string, operator?: string): void; 28 | } 29 | 30 | export interface AssertStatic extends Assert { 31 | } 32 | 33 | export interface AssertionStatic { 34 | (target: any, message?: string): Assertion; 35 | } 36 | 37 | interface ShouldAssertion { 38 | equal(value1: any, value2: any, message?: string): void; 39 | Throw: ShouldThrow; 40 | throw: ShouldThrow; 41 | exist(value: any, message?: string): void; 42 | } 43 | 44 | interface Should extends ShouldAssertion { 45 | not: ShouldAssertion; 46 | fail(actual: any, expected: any, message?: string, operator?: string): void; 47 | } 48 | 49 | interface ShouldThrow { 50 | (actual: Function): void; 51 | (actual: Function, expected: string|RegExp, message?: string): void; 52 | (actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void; 53 | } 54 | 55 | interface Assertion extends LanguageChains, NumericComparison, TypeComparison { 56 | not: Assertion; 57 | deep: Deep; 58 | any: KeyFilter; 59 | all: KeyFilter; 60 | a: TypeComparison; 61 | an: TypeComparison; 62 | include: Include; 63 | includes: Include; 64 | contain: Include; 65 | contains: Include; 66 | ok: Assertion; 67 | true: Assertion; 68 | false: Assertion; 69 | null: Assertion; 70 | undefined: Assertion; 71 | NaN: Assertion; 72 | exist: Assertion; 73 | empty: Assertion; 74 | arguments: Assertion; 75 | Arguments: Assertion; 76 | equal: Equal; 77 | equals: Equal; 78 | eq: Equal; 79 | eql: Equal; 80 | eqls: Equal; 81 | property: Property; 82 | ownProperty: OwnProperty; 83 | haveOwnProperty: OwnProperty; 84 | ownPropertyDescriptor: OwnPropertyDescriptor; 85 | haveOwnPropertyDescriptor: OwnPropertyDescriptor; 86 | length: Length; 87 | lengthOf: Length; 88 | match: Match; 89 | matches: Match; 90 | string(string: string, message?: string): Assertion; 91 | keys: Keys; 92 | key(string: string): Assertion; 93 | throw: Throw; 94 | throws: Throw; 95 | Throw: Throw; 96 | respondTo: RespondTo; 97 | respondsTo: RespondTo; 98 | itself: Assertion; 99 | satisfy: Satisfy; 100 | satisfies: Satisfy; 101 | closeTo: CloseTo; 102 | approximately: CloseTo; 103 | members: Members; 104 | increase: PropertyChange; 105 | increases: PropertyChange; 106 | decrease: PropertyChange; 107 | decreases: PropertyChange; 108 | change: PropertyChange; 109 | changes: PropertyChange; 110 | extensible: Assertion; 111 | sealed: Assertion; 112 | frozen: Assertion; 113 | oneOf(list: any[], message?: string): Assertion; 114 | } 115 | 116 | interface LanguageChains { 117 | to: Assertion; 118 | be: Assertion; 119 | been: Assertion; 120 | is: Assertion; 121 | that: Assertion; 122 | which: Assertion; 123 | and: Assertion; 124 | has: Assertion; 125 | have: Assertion; 126 | with: Assertion; 127 | at: Assertion; 128 | of: Assertion; 129 | same: Assertion; 130 | } 131 | 132 | interface NumericComparison { 133 | above: NumberComparer; 134 | gt: NumberComparer; 135 | greaterThan: NumberComparer; 136 | least: NumberComparer; 137 | gte: NumberComparer; 138 | below: NumberComparer; 139 | lt: NumberComparer; 140 | lessThan: NumberComparer; 141 | most: NumberComparer; 142 | lte: NumberComparer; 143 | within(start: number, finish: number, message?: string): Assertion; 144 | } 145 | 146 | interface NumberComparer { 147 | (value: number, message?: string): Assertion; 148 | } 149 | 150 | interface TypeComparison { 151 | (type: string, message?: string): Assertion; 152 | instanceof: InstanceOf; 153 | instanceOf: InstanceOf; 154 | } 155 | 156 | interface InstanceOf { 157 | (constructor: Object, message?: string): Assertion; 158 | } 159 | 160 | interface CloseTo { 161 | (expected: number, delta: number, message?: string): Assertion; 162 | } 163 | 164 | interface Deep { 165 | equal: Equal; 166 | include: Include; 167 | property: Property; 168 | members: Members; 169 | } 170 | 171 | interface KeyFilter { 172 | keys: Keys; 173 | } 174 | 175 | interface Equal { 176 | (value: any, message?: string): Assertion; 177 | } 178 | 179 | interface Property { 180 | (name: string, value?: any, message?: string): Assertion; 181 | } 182 | 183 | interface OwnProperty { 184 | (name: string, message?: string): Assertion; 185 | } 186 | 187 | interface OwnPropertyDescriptor { 188 | (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; 189 | (name: string, message?: string): Assertion; 190 | } 191 | 192 | interface Length extends LanguageChains, NumericComparison { 193 | (length: number, message?: string): Assertion; 194 | } 195 | 196 | interface Include { 197 | (value: Object, message?: string): Assertion; 198 | (value: string, message?: string): Assertion; 199 | (value: number, message?: string): Assertion; 200 | keys: Keys; 201 | members: Members; 202 | any: KeyFilter; 203 | all: KeyFilter; 204 | } 205 | 206 | interface Match { 207 | (regexp: RegExp|string, message?: string): Assertion; 208 | } 209 | 210 | interface Keys { 211 | (...keys: string[]): Assertion; 212 | (keys: any[]): Assertion; 213 | (keys: Object): Assertion; 214 | } 215 | 216 | interface Throw { 217 | (): Assertion; 218 | (expected: string, message?: string): Assertion; 219 | (expected: RegExp, message?: string): Assertion; 220 | (constructor: Error, expected?: string, message?: string): Assertion; 221 | (constructor: Error, expected?: RegExp, message?: string): Assertion; 222 | (constructor: Function, expected?: string, message?: string): Assertion; 223 | (constructor: Function, expected?: RegExp, message?: string): Assertion; 224 | } 225 | 226 | interface RespondTo { 227 | (method: string, message?: string): Assertion; 228 | } 229 | 230 | interface Satisfy { 231 | (matcher: Function, message?: string): Assertion; 232 | } 233 | 234 | interface Members { 235 | (set: any[], message?: string): Assertion; 236 | } 237 | 238 | interface PropertyChange { 239 | (object: Object, prop: string, msg?: string): Assertion; 240 | } 241 | 242 | export interface Assert { 243 | /** 244 | * @param expression Expression to test for truthiness. 245 | * @param message Message to display on error. 246 | */ 247 | (expression: any, message?: string): void; 248 | 249 | fail(actual?: any, expected?: any, msg?: string, operator?: string): void; 250 | 251 | ok(val: any, msg?: string): void; 252 | isOk(val: any, msg?: string): void; 253 | notOk(val: any, msg?: string): void; 254 | isNotOk(val: any, msg?: string): void; 255 | 256 | equal(act: any, exp: any, msg?: string): void; 257 | notEqual(act: any, exp: any, msg?: string): void; 258 | 259 | strictEqual(act: any, exp: any, msg?: string): void; 260 | notStrictEqual(act: any, exp: any, msg?: string): void; 261 | 262 | deepEqual(act: any, exp: any, msg?: string): void; 263 | notDeepEqual(act: any, exp: any, msg?: string): void; 264 | 265 | isTrue(val: any, msg?: string): void; 266 | isFalse(val: any, msg?: string): void; 267 | 268 | isNotTrue(val: any, msg?: string): void; 269 | isNotFalse(val: any, msg?: string): void; 270 | 271 | isNull(val: any, msg?: string): void; 272 | isNotNull(val: any, msg?: string): void; 273 | 274 | isUndefined(val: any, msg?: string): void; 275 | isDefined(val: any, msg?: string): void; 276 | 277 | isNaN(val: any, msg?: string): void; 278 | isNotNaN(val: any, msg?: string): void; 279 | 280 | isAbove(val: number, abv: number, msg?: string): void; 281 | isBelow(val: number, blw: number, msg?: string): void; 282 | 283 | isAtLeast(val: number, atlst: number, msg?: string): void; 284 | isAtMost(val: number, atmst: number, msg?: string): void; 285 | 286 | isFunction(val: any, msg?: string): void; 287 | isNotFunction(val: any, msg?: string): void; 288 | 289 | isObject(val: any, msg?: string): void; 290 | isNotObject(val: any, msg?: string): void; 291 | 292 | isArray(val: any, msg?: string): void; 293 | isNotArray(val: any, msg?: string): void; 294 | 295 | isString(val: any, msg?: string): void; 296 | isNotString(val: any, msg?: string): void; 297 | 298 | isNumber(val: any, msg?: string): void; 299 | isNotNumber(val: any, msg?: string): void; 300 | 301 | isBoolean(val: any, msg?: string): void; 302 | isNotBoolean(val: any, msg?: string): void; 303 | 304 | typeOf(val: any, type: string, msg?: string): void; 305 | notTypeOf(val: any, type: string, msg?: string): void; 306 | 307 | instanceOf(val: any, type: Function, msg?: string): void; 308 | notInstanceOf(val: any, type: Function, msg?: string): void; 309 | 310 | include(exp: string, inc: any, msg?: string): void; 311 | include(exp: any[], inc: any, msg?: string): void; 312 | 313 | notInclude(exp: string, inc: any, msg?: string): void; 314 | notInclude(exp: any[], inc: any, msg?: string): void; 315 | 316 | match(exp: any, re: RegExp, msg?: string): void; 317 | notMatch(exp: any, re: RegExp, msg?: string): void; 318 | 319 | property(obj: Object, prop: string, msg?: string): void; 320 | notProperty(obj: Object, prop: string, msg?: string): void; 321 | deepProperty(obj: Object, prop: string, msg?: string): void; 322 | notDeepProperty(obj: Object, prop: string, msg?: string): void; 323 | 324 | propertyVal(obj: Object, prop: string, val: any, msg?: string): void; 325 | propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; 326 | 327 | deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void; 328 | deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; 329 | 330 | lengthOf(exp: any, len: number, msg?: string): void; 331 | //alias frenzy 332 | throw(fn: Function, msg?: string): void; 333 | throw(fn: Function, regExp: RegExp): void; 334 | throw(fn: Function, errType: Function, msg?: string): void; 335 | throw(fn: Function, errType: Function, regExp: RegExp): void; 336 | 337 | throws(fn: Function, msg?: string): void; 338 | throws(fn: Function, regExp: RegExp): void; 339 | throws(fn: Function, errType: Function, msg?: string): void; 340 | throws(fn: Function, errType: Function, regExp: RegExp): void; 341 | 342 | Throw(fn: Function, msg?: string): void; 343 | Throw(fn: Function, regExp: RegExp): void; 344 | Throw(fn: Function, errType: Function, msg?: string): void; 345 | Throw(fn: Function, errType: Function, regExp: RegExp): void; 346 | 347 | doesNotThrow(fn: Function, msg?: string): void; 348 | doesNotThrow(fn: Function, regExp: RegExp): void; 349 | doesNotThrow(fn: Function, errType: Function, msg?: string): void; 350 | doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; 351 | 352 | operator(val: any, operator: string, val2: any, msg?: string): void; 353 | closeTo(act: number, exp: number, delta: number, msg?: string): void; 354 | approximately(act: number, exp: number, delta: number, msg?: string): void; 355 | 356 | sameMembers(set1: any[], set2: any[], msg?: string): void; 357 | sameDeepMembers(set1: any[], set2: any[], msg?: string): void; 358 | includeMembers(superset: any[], subset: any[], msg?: string): void; 359 | 360 | ifError(val: any, msg?: string): void; 361 | 362 | isExtensible(obj: {}, msg?: string): void; 363 | extensible(obj: {}, msg?: string): void; 364 | isNotExtensible(obj: {}, msg?: string): void; 365 | notExtensible(obj: {}, msg?: string): void; 366 | 367 | isSealed(obj: {}, msg?: string): void; 368 | sealed(obj: {}, msg?: string): void; 369 | isNotSealed(obj: {}, msg?: string): void; 370 | notSealed(obj: {}, msg?: string): void; 371 | 372 | isFrozen(obj: Object, msg?: string): void; 373 | frozen(obj: Object, msg?: string): void; 374 | isNotFrozen(obj: Object, msg?: string): void; 375 | notFrozen(obj: Object, msg?: string): void; 376 | 377 | oneOf(inList: any, list: any[], msg?: string): void; 378 | } 379 | 380 | export interface Config { 381 | includeStack: boolean; 382 | } 383 | 384 | export class AssertionError { 385 | constructor(message: string, _props?: any, ssf?: Function); 386 | name: string; 387 | message: string; 388 | showDiff: boolean; 389 | stack: string; 390 | } 391 | } 392 | 393 | declare var chai: Chai.ChaiStatic; 394 | 395 | declare module "chai" { 396 | export = chai; 397 | } 398 | 399 | interface Object { 400 | should: Chai.Assertion; 401 | } 402 | -------------------------------------------------------------------------------- /typings/connect-flash/connect-flash.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for connect-flash 2 | // Project: https://github.com/jaredhanson/connect-flash 3 | // Definitions by: Andreas Gassmann 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare namespace Express { 9 | export interface Request { 10 | flash(message: string): any; 11 | flash(event: string, message: string): any; 12 | } 13 | } 14 | 15 | declare module "connect-flash" { 16 | import express = require('express'); 17 | interface IConnectFlashOptions { 18 | unsafe?: boolean; 19 | } 20 | function e(options?: IConnectFlashOptions): express.RequestHandler; 21 | export = e; 22 | } 23 | -------------------------------------------------------------------------------- /typings/consolidate/consolidate.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for consolidate 2 | // Project: https://github.com/visionmedia/consolidate.js 3 | // Definitions by: Carlos Ballesteros Velasco , Theo Sherry 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | // Imported from: https://github.com/soywiz/typescript-node-definitions/consolidate.d.ts 7 | 8 | /// 9 | /// 10 | 11 | declare module "consolidate" { 12 | var cons: Consolidate; 13 | 14 | export = cons; 15 | 16 | interface Consolidate { 17 | /** 18 | * expose the instance of the engine 19 | */ 20 | requires: Object; 21 | 22 | /** 23 | * Clear the cache. 24 | * 25 | * @api public 26 | */ 27 | clearCache(): void; 28 | // template engines 29 | atpl: RendererInterface; 30 | dot: RendererInterface; 31 | dust: RendererInterface; 32 | eco: RendererInterface; 33 | ejs: RendererInterface; 34 | ect: RendererInterface; 35 | haml: RendererInterface; 36 | // TODO figure out how to do haml-coffee 37 | hamlet: RendererInterface; 38 | handlebars: RendererInterface; 39 | hogan: RendererInterface; 40 | htmling: RendererInterface; 41 | jade: RendererInterface; 42 | jazz: RendererInterface; 43 | jqtpl: RendererInterface; 44 | just: RendererInterface; 45 | liquid: RendererInterface; 46 | liquor: RendererInterface; 47 | lodash: RendererInterface; 48 | mote: RendererInterface; 49 | mustache: RendererInterface; 50 | nunjucks: RendererInterface; 51 | qejs: RendererInterface; 52 | ractive: RendererInterface; 53 | react: RendererInterface; 54 | swig: RendererInterface; 55 | templayed: RendererInterface; 56 | toffee: RendererInterface; 57 | underscore: RendererInterface; 58 | walrus: RendererInterface; 59 | whiskers: RendererInterface; 60 | } 61 | 62 | interface RendererInterface { 63 | render(path: String, fn: (err: Error, html: String) => any): any; 64 | 65 | render(path: String, options: {cache?: boolean, [otherOptions: string]: any}, fn: (err: Error, html: String) => any): any; 66 | 67 | render(path: String, options?: { cache?: boolean, [otherOptions: string]: any }): Promise; 68 | 69 | (path: String, fn: (err: Error, html: String) => any): any; 70 | 71 | (path: String, options: { cache?: boolean, [otherOptions: string]: any }, fn: (err: Error, html: String) => any): any; 72 | 73 | (path: String, options?: { cache?: boolean, [otherOptions: string]: any }): Promise; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /typings/cookie-parser/cookie-parser.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for cookie-parser v1.3.4 2 | // Project: https://github.com/expressjs/cookie-parser 3 | // Definitions by: Santi Albo 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare module "cookie-parser" { 9 | import express = require('express'); 10 | function e(secret?: string, options?: any): express.RequestHandler; 11 | namespace e{} 12 | export = e; 13 | } -------------------------------------------------------------------------------- /typings/express-serve-static-core/express-serve-static-core.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Express 4.x 2 | // Project: http://expressjs.com 3 | // Definitions by: Boris Yankov 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | // This extracts the core definitions from express to prevent a circular dependency between express and serve-static 6 | /// 7 | 8 | declare namespace Express { 9 | 10 | // These open interfaces may be extended in an application-specific manner via declaration merging. 11 | // See for example method-override.d.ts (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/method-override/method-override.d.ts) 12 | export interface Request { } 13 | export interface Response { } 14 | export interface Application { } 15 | } 16 | 17 | declare module "express-serve-static-core" { 18 | import * as http from "http"; 19 | 20 | interface IRoute { 21 | path: string; 22 | stack: any; 23 | all(...handler: RequestHandler[]): IRoute; 24 | get(...handler: RequestHandler[]): IRoute; 25 | post(...handler: RequestHandler[]): IRoute; 26 | put(...handler: RequestHandler[]): IRoute; 27 | delete(...handler: RequestHandler[]): IRoute; 28 | patch(...handler: RequestHandler[]): IRoute; 29 | options(...handler: RequestHandler[]): IRoute; 30 | head(...handler: RequestHandler[]): IRoute; 31 | } 32 | 33 | interface IRouterMatcher { 34 | (name: string | RegExp, ...handlers: RequestHandler[]): T; 35 | } 36 | 37 | interface IRouter extends RequestHandler { 38 | /** 39 | * Map the given param placeholder `name`(s) to the given callback(s). 40 | * 41 | * Parameter mapping is used to provide pre-conditions to routes 42 | * which use normalized placeholders. For example a _:user_id_ parameter 43 | * could automatically load a user's information from the database without 44 | * any additional code, 45 | * 46 | * The callback uses the samesignature as middleware, the only differencing 47 | * being that the value of the placeholder is passed, in this case the _id_ 48 | * of the user. Once the `next()` function is invoked, just like middleware 49 | * it will continue on to execute the route, or subsequent parameter functions. 50 | * 51 | * app.param('user_id', function(req, res, next, id){ 52 | * User.find(id, function(err, user){ 53 | * if (err) { 54 | * next(err); 55 | * } else if (user) { 56 | * req.user = user; 57 | * next(); 58 | * } else { 59 | * next(new Error('failed to load user')); 60 | * } 61 | * }); 62 | * }); 63 | * 64 | * @param name 65 | * @param fn 66 | */ 67 | param(name: string, handler: RequestParamHandler): T; 68 | param(name: string, matcher: RegExp): T; 69 | param(name: string, mapper: (param: any) => any): T; 70 | // Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param() API 71 | param(callback: (name: string, matcher: RegExp) => RequestParamHandler): T; 72 | 73 | /** 74 | * Special-cased "all" method, applying the given route `path`, 75 | * middleware, and callback to _every_ HTTP method. 76 | * 77 | * @param path 78 | * @param fn 79 | */ 80 | all: IRouterMatcher; 81 | get: IRouterMatcher; 82 | post: IRouterMatcher; 83 | put: IRouterMatcher; 84 | delete: IRouterMatcher; 85 | patch: IRouterMatcher; 86 | options: IRouterMatcher; 87 | head: IRouterMatcher; 88 | 89 | route(path: string): IRoute; 90 | 91 | use(...handler: RequestHandler[]): T; 92 | use(handler: ErrorRequestHandler | RequestHandler): T; 93 | use(path: string, ...handler: RequestHandler[]): T; 94 | use(path: string, handler: ErrorRequestHandler | RequestHandler): T; 95 | use(path: string[], ...handler: RequestHandler[]): T; 96 | use(path: string[], handler: ErrorRequestHandler): T; 97 | use(path: RegExp, ...handler: RequestHandler[]): T; 98 | use(path: RegExp, handler: ErrorRequestHandler): T; 99 | use(path: string, router: Router): T; 100 | } 101 | 102 | 103 | export interface Router extends IRouter { } 104 | 105 | interface CookieOptions { 106 | maxAge?: number; 107 | signed?: boolean; 108 | expires?: Date; 109 | httpOnly?: boolean; 110 | path?: string; 111 | domain?: string; 112 | secure?: boolean; 113 | } 114 | 115 | interface Errback { (err: Error): void; } 116 | 117 | interface Request extends http.ServerRequest, Express.Request { 118 | 119 | /** 120 | * Return request header. 121 | * 122 | * The `Referrer` header field is special-cased, 123 | * both `Referrer` and `Referer` are interchangeable. 124 | * 125 | * Examples: 126 | * 127 | * req.get('Content-Type'); 128 | * // => "text/plain" 129 | * 130 | * req.get('content-type'); 131 | * // => "text/plain" 132 | * 133 | * req.get('Something'); 134 | * // => undefined 135 | * 136 | * Aliased as `req.header()`. 137 | * 138 | * @param name 139 | */ 140 | get(name: string): string; 141 | 142 | header(name: string): string; 143 | 144 | headers: { [key: string]: string; }; 145 | 146 | /** 147 | * Check if the given `type(s)` is acceptable, returning 148 | * the best match when true, otherwise `undefined`, in which 149 | * case you should respond with 406 "Not Acceptable". 150 | * 151 | * The `type` value may be a single mime type string 152 | * such as "application/json", the extension name 153 | * such as "json", a comma-delimted list such as "json, html, text/plain", 154 | * or an array `["json", "html", "text/plain"]`. When a list 155 | * or array is given the _best_ match, if any is returned. 156 | * 157 | * Examples: 158 | * 159 | * // Accept: text/html 160 | * req.accepts('html'); 161 | * // => "html" 162 | * 163 | * // Accept: text/*, application/json 164 | * req.accepts('html'); 165 | * // => "html" 166 | * req.accepts('text/html'); 167 | * // => "text/html" 168 | * req.accepts('json, text'); 169 | * // => "json" 170 | * req.accepts('application/json'); 171 | * // => "application/json" 172 | * 173 | * // Accept: text/*, application/json 174 | * req.accepts('image/png'); 175 | * req.accepts('png'); 176 | * // => undefined 177 | * 178 | * // Accept: text/*;q=.5, application/json 179 | * req.accepts(['html', 'json']); 180 | * req.accepts('html, json'); 181 | * // => "json" 182 | */ 183 | accepts(type: string): string; 184 | 185 | accepts(type: string[]): string; 186 | 187 | /** 188 | * Returns the first accepted charset of the specified character sets, 189 | * based on the request’s Accept-Charset HTTP header field. 190 | * If none of the specified charsets is accepted, returns false. 191 | * 192 | * For more information, or if you have issues or concerns, see accepts. 193 | * @param charset 194 | */ 195 | acceptsCharsets(charset?: string | string[]): string[]; 196 | 197 | /** 198 | * Returns the first accepted encoding of the specified encodings, 199 | * based on the request’s Accept-Encoding HTTP header field. 200 | * If none of the specified encodings is accepted, returns false. 201 | * 202 | * For more information, or if you have issues or concerns, see accepts. 203 | * @param encoding 204 | */ 205 | acceptsEncodings(encoding?: string | string[]): string[]; 206 | 207 | /** 208 | * Returns the first accepted language of the specified languages, 209 | * based on the request’s Accept-Language HTTP header field. 210 | * If none of the specified languages is accepted, returns false. 211 | * 212 | * For more information, or if you have issues or concerns, see accepts. 213 | * 214 | * @param lang 215 | */ 216 | acceptsLanguages(lang?: string | string[]): string[]; 217 | 218 | /** 219 | * Parse Range header field, 220 | * capping to the given `size`. 221 | * 222 | * Unspecified ranges such as "0-" require 223 | * knowledge of your resource length. In 224 | * the case of a byte range this is of course 225 | * the total number of bytes. If the Range 226 | * header field is not given `null` is returned, 227 | * `-1` when unsatisfiable, `-2` when syntactically invalid. 228 | * 229 | * NOTE: remember that ranges are inclusive, so 230 | * for example "Range: users=0-3" should respond 231 | * with 4 users when available, not 3. 232 | * 233 | * @param size 234 | */ 235 | range(size: number): any[]; 236 | 237 | /** 238 | * Return an array of Accepted media types 239 | * ordered from highest quality to lowest. 240 | */ 241 | accepted: MediaType[]; 242 | 243 | /** 244 | * Return the value of param `name` when present or `defaultValue`. 245 | * 246 | * - Checks route placeholders, ex: _/user/:id_ 247 | * - Checks body params, ex: id=12, {"id":12} 248 | * - Checks query string params, ex: ?id=12 249 | * 250 | * To utilize request bodies, `req.body` 251 | * should be an object. This can be done by using 252 | * the `connect.bodyParser()` middleware. 253 | * 254 | * @param name 255 | * @param defaultValue 256 | */ 257 | param(name: string, defaultValue?: any): string; 258 | 259 | /** 260 | * Check if the incoming request contains the "Content-Type" 261 | * header field, and it contains the give mime `type`. 262 | * 263 | * Examples: 264 | * 265 | * // With Content-Type: text/html; charset=utf-8 266 | * req.is('html'); 267 | * req.is('text/html'); 268 | * req.is('text/*'); 269 | * // => true 270 | * 271 | * // When Content-Type is application/json 272 | * req.is('json'); 273 | * req.is('application/json'); 274 | * req.is('application/*'); 275 | * // => true 276 | * 277 | * req.is('html'); 278 | * // => false 279 | * 280 | * @param type 281 | */ 282 | is(type: string): boolean; 283 | 284 | /** 285 | * Return the protocol string "http" or "https" 286 | * when requested with TLS. When the "trust proxy" 287 | * setting is enabled the "X-Forwarded-Proto" header 288 | * field will be trusted. If you're running behind 289 | * a reverse proxy that supplies https for you this 290 | * may be enabled. 291 | */ 292 | protocol: string; 293 | 294 | /** 295 | * Short-hand for: 296 | * 297 | * req.protocol == 'https' 298 | */ 299 | secure: boolean; 300 | 301 | /** 302 | * Return the remote address, or when 303 | * "trust proxy" is `true` return 304 | * the upstream addr. 305 | */ 306 | ip: string; 307 | 308 | /** 309 | * When "trust proxy" is `true`, parse 310 | * the "X-Forwarded-For" ip address list. 311 | * 312 | * For example if the value were "client, proxy1, proxy2" 313 | * you would receive the array `["client", "proxy1", "proxy2"]` 314 | * where "proxy2" is the furthest down-stream. 315 | */ 316 | ips: string[]; 317 | 318 | /** 319 | * Return subdomains as an array. 320 | * 321 | * Subdomains are the dot-separated parts of the host before the main domain of 322 | * the app. By default, the domain of the app is assumed to be the last two 323 | * parts of the host. This can be changed by setting "subdomain offset". 324 | * 325 | * For example, if the domain is "tobi.ferrets.example.com": 326 | * If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`. 327 | * If "subdomain offset" is 3, req.subdomains is `["tobi"]`. 328 | */ 329 | subdomains: string[]; 330 | 331 | /** 332 | * Short-hand for `url.parse(req.url).pathname`. 333 | */ 334 | path: string; 335 | 336 | /** 337 | * Parse the "Host" header field hostname. 338 | */ 339 | hostname: string; 340 | 341 | /** 342 | * @deprecated Use hostname instead. 343 | */ 344 | host: string; 345 | 346 | /** 347 | * Check if the request is fresh, aka 348 | * Last-Modified and/or the ETag 349 | * still match. 350 | */ 351 | fresh: boolean; 352 | 353 | /** 354 | * Check if the request is stale, aka 355 | * "Last-Modified" and / or the "ETag" for the 356 | * resource has changed. 357 | */ 358 | stale: boolean; 359 | 360 | /** 361 | * Check if the request was an _XMLHttpRequest_. 362 | */ 363 | xhr: boolean; 364 | 365 | //body: { username: string; password: string; remember: boolean; title: string; }; 366 | body: any; 367 | 368 | //cookies: { string; remember: boolean; }; 369 | cookies: any; 370 | 371 | method: string; 372 | 373 | params: any; 374 | 375 | user: any; 376 | 377 | authenticatedUser: any; 378 | 379 | /** 380 | * Clear cookie `name`. 381 | * 382 | * @param name 383 | * @param options 384 | */ 385 | clearCookie(name: string, options?: any): Response; 386 | 387 | query: any; 388 | 389 | route: any; 390 | 391 | signedCookies: any; 392 | 393 | originalUrl: string; 394 | 395 | url: string; 396 | 397 | baseUrl: string; 398 | 399 | app: Application; 400 | } 401 | 402 | interface MediaType { 403 | value: string; 404 | quality: number; 405 | type: string; 406 | subtype: string; 407 | } 408 | 409 | interface Send { 410 | (status: number, body?: any): Response; 411 | (body: any): Response; 412 | } 413 | 414 | interface Response extends http.ServerResponse, Express.Response { 415 | /** 416 | * Set status `code`. 417 | * 418 | * @param code 419 | */ 420 | status(code: number): Response; 421 | 422 | /** 423 | * Set the response HTTP status code to `statusCode` and send its string representation as the response body. 424 | * @link http://expressjs.com/4x/api.html#res.sendStatus 425 | * 426 | * Examples: 427 | * 428 | * res.sendStatus(200); // equivalent to res.status(200).send('OK') 429 | * res.sendStatus(403); // equivalent to res.status(403).send('Forbidden') 430 | * res.sendStatus(404); // equivalent to res.status(404).send('Not Found') 431 | * res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error') 432 | * 433 | * @param code 434 | */ 435 | sendStatus(code: number): Response; 436 | 437 | /** 438 | * Set Link header field with the given `links`. 439 | * 440 | * Examples: 441 | * 442 | * res.links({ 443 | * next: 'http://api.example.com/users?page=2', 444 | * last: 'http://api.example.com/users?page=5' 445 | * }); 446 | * 447 | * @param links 448 | */ 449 | links(links: any): Response; 450 | 451 | /** 452 | * Send a response. 453 | * 454 | * Examples: 455 | * 456 | * res.send(new Buffer('wahoo')); 457 | * res.send({ some: 'json' }); 458 | * res.send('

some html

'); 459 | * res.send(404, 'Sorry, cant find that'); 460 | * res.send(404); 461 | */ 462 | send: Send; 463 | 464 | /** 465 | * Send JSON response. 466 | * 467 | * Examples: 468 | * 469 | * res.json(null); 470 | * res.json({ user: 'tj' }); 471 | * res.json(500, 'oh noes!'); 472 | * res.json(404, 'I dont have that'); 473 | */ 474 | json: Send; 475 | 476 | /** 477 | * Send JSON response with JSONP callback support. 478 | * 479 | * Examples: 480 | * 481 | * res.jsonp(null); 482 | * res.jsonp({ user: 'tj' }); 483 | * res.jsonp(500, 'oh noes!'); 484 | * res.jsonp(404, 'I dont have that'); 485 | */ 486 | jsonp: Send; 487 | 488 | /** 489 | * Transfer the file at the given `path`. 490 | * 491 | * Automatically sets the _Content-Type_ response header field. 492 | * The callback `fn(err)` is invoked when the transfer is complete 493 | * or when an error occurs. Be sure to check `res.sentHeader` 494 | * if you wish to attempt responding, as the header and some data 495 | * may have already been transferred. 496 | * 497 | * Options: 498 | * 499 | * - `maxAge` defaulting to 0 (can be string converted by `ms`) 500 | * - `root` root directory for relative filenames 501 | * - `headers` object of headers to serve with file 502 | * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them 503 | * 504 | * Other options are passed along to `send`. 505 | * 506 | * Examples: 507 | * 508 | * The following example illustrates how `res.sendFile()` may 509 | * be used as an alternative for the `static()` middleware for 510 | * dynamic situations. The code backing `res.sendFile()` is actually 511 | * the same code, so HTTP cache support etc is identical. 512 | * 513 | * app.get('/user/:uid/photos/:file', function(req, res){ 514 | * var uid = req.params.uid 515 | * , file = req.params.file; 516 | * 517 | * req.user.mayViewFilesFrom(uid, function(yes){ 518 | * if (yes) { 519 | * res.sendFile('/uploads/' + uid + '/' + file); 520 | * } else { 521 | * res.send(403, 'Sorry! you cant see that.'); 522 | * } 523 | * }); 524 | * }); 525 | * 526 | * @api public 527 | */ 528 | sendFile(path: string): void; 529 | sendFile(path: string, options: any): void; 530 | sendFile(path: string, fn: Errback): void; 531 | sendFile(path: string, options: any, fn: Errback): void; 532 | 533 | /** 534 | * @deprecated Use sendFile instead. 535 | */ 536 | sendfile(path: string): void; 537 | /** 538 | * @deprecated Use sendFile instead. 539 | */ 540 | sendfile(path: string, options: any): void; 541 | /** 542 | * @deprecated Use sendFile instead. 543 | */ 544 | sendfile(path: string, fn: Errback): void; 545 | /** 546 | * @deprecated Use sendFile instead. 547 | */ 548 | sendfile(path: string, options: any, fn: Errback): void; 549 | 550 | /** 551 | * Transfer the file at the given `path` as an attachment. 552 | * 553 | * Optionally providing an alternate attachment `filename`, 554 | * and optional callback `fn(err)`. The callback is invoked 555 | * when the data transfer is complete, or when an error has 556 | * ocurred. Be sure to check `res.headerSent` if you plan to respond. 557 | * 558 | * This method uses `res.sendfile()`. 559 | */ 560 | download(path: string): void; 561 | download(path: string, filename: string): void; 562 | download(path: string, fn: Errback): void; 563 | download(path: string, filename: string, fn: Errback): void; 564 | 565 | /** 566 | * Set _Content-Type_ response header with `type` through `mime.lookup()` 567 | * when it does not contain "/", or set the Content-Type to `type` otherwise. 568 | * 569 | * Examples: 570 | * 571 | * res.type('.html'); 572 | * res.type('html'); 573 | * res.type('json'); 574 | * res.type('application/json'); 575 | * res.type('png'); 576 | * 577 | * @param type 578 | */ 579 | contentType(type: string): Response; 580 | 581 | /** 582 | * Set _Content-Type_ response header with `type` through `mime.lookup()` 583 | * when it does not contain "/", or set the Content-Type to `type` otherwise. 584 | * 585 | * Examples: 586 | * 587 | * res.type('.html'); 588 | * res.type('html'); 589 | * res.type('json'); 590 | * res.type('application/json'); 591 | * res.type('png'); 592 | * 593 | * @param type 594 | */ 595 | type(type: string): Response; 596 | 597 | /** 598 | * Respond to the Acceptable formats using an `obj` 599 | * of mime-type callbacks. 600 | * 601 | * This method uses `req.accepted`, an array of 602 | * acceptable types ordered by their quality values. 603 | * When "Accept" is not present the _first_ callback 604 | * is invoked, otherwise the first match is used. When 605 | * no match is performed the server responds with 606 | * 406 "Not Acceptable". 607 | * 608 | * Content-Type is set for you, however if you choose 609 | * you may alter this within the callback using `res.type()` 610 | * or `res.set('Content-Type', ...)`. 611 | * 612 | * res.format({ 613 | * 'text/plain': function(){ 614 | * res.send('hey'); 615 | * }, 616 | * 617 | * 'text/html': function(){ 618 | * res.send('

hey

'); 619 | * }, 620 | * 621 | * 'appliation/json': function(){ 622 | * res.send({ message: 'hey' }); 623 | * } 624 | * }); 625 | * 626 | * In addition to canonicalized MIME types you may 627 | * also use extnames mapped to these types: 628 | * 629 | * res.format({ 630 | * text: function(){ 631 | * res.send('hey'); 632 | * }, 633 | * 634 | * html: function(){ 635 | * res.send('

hey

'); 636 | * }, 637 | * 638 | * json: function(){ 639 | * res.send({ message: 'hey' }); 640 | * } 641 | * }); 642 | * 643 | * By default Express passes an `Error` 644 | * with a `.status` of 406 to `next(err)` 645 | * if a match is not made. If you provide 646 | * a `.default` callback it will be invoked 647 | * instead. 648 | * 649 | * @param obj 650 | */ 651 | format(obj: any): Response; 652 | 653 | /** 654 | * Set _Content-Disposition_ header to _attachment_ with optional `filename`. 655 | * 656 | * @param filename 657 | */ 658 | attachment(filename?: string): Response; 659 | 660 | /** 661 | * Set header `field` to `val`, or pass 662 | * an object of header fields. 663 | * 664 | * Examples: 665 | * 666 | * res.set('Foo', ['bar', 'baz']); 667 | * res.set('Accept', 'application/json'); 668 | * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' }); 669 | * 670 | * Aliased as `res.header()`. 671 | */ 672 | set(field: any): Response; 673 | set(field: string, value?: string): Response; 674 | 675 | header(field: any): Response; 676 | header(field: string, value?: string): Response; 677 | 678 | // Property indicating if HTTP headers has been sent for the response. 679 | headersSent: boolean; 680 | 681 | /** 682 | * Get value for header `field`. 683 | * 684 | * @param field 685 | */ 686 | get(field: string): string; 687 | 688 | /** 689 | * Clear cookie `name`. 690 | * 691 | * @param name 692 | * @param options 693 | */ 694 | clearCookie(name: string, options?: any): Response; 695 | 696 | /** 697 | * Set cookie `name` to `val`, with the given `options`. 698 | * 699 | * Options: 700 | * 701 | * - `maxAge` max-age in milliseconds, converted to `expires` 702 | * - `signed` sign the cookie 703 | * - `path` defaults to "/" 704 | * 705 | * Examples: 706 | * 707 | * // "Remember Me" for 15 minutes 708 | * res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true }); 709 | * 710 | * // save as above 711 | * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true }) 712 | */ 713 | cookie(name: string, val: string, options: CookieOptions): Response; 714 | cookie(name: string, val: any, options: CookieOptions): Response; 715 | cookie(name: string, val: any): Response; 716 | 717 | /** 718 | * Set the location header to `url`. 719 | * 720 | * The given `url` can also be the name of a mapped url, for 721 | * example by default express supports "back" which redirects 722 | * to the _Referrer_ or _Referer_ headers or "/". 723 | * 724 | * Examples: 725 | * 726 | * res.location('/foo/bar').; 727 | * res.location('http://example.com'); 728 | * res.location('../login'); // /blog/post/1 -> /blog/login 729 | * 730 | * Mounting: 731 | * 732 | * When an application is mounted and `res.location()` 733 | * is given a path that does _not_ lead with "/" it becomes 734 | * relative to the mount-point. For example if the application 735 | * is mounted at "/blog", the following would become "/blog/login". 736 | * 737 | * res.location('login'); 738 | * 739 | * While the leading slash would result in a location of "/login": 740 | * 741 | * res.location('/login'); 742 | * 743 | * @param url 744 | */ 745 | location(url: string): Response; 746 | 747 | /** 748 | * Redirect to the given `url` with optional response `status` 749 | * defaulting to 302. 750 | * 751 | * The resulting `url` is determined by `res.location()`, so 752 | * it will play nicely with mounted apps, relative paths, 753 | * `"back"` etc. 754 | * 755 | * Examples: 756 | * 757 | * res.redirect('/foo/bar'); 758 | * res.redirect('http://example.com'); 759 | * res.redirect(301, 'http://example.com'); 760 | * res.redirect('http://example.com', 301); 761 | * res.redirect('../login'); // /blog/post/1 -> /blog/login 762 | */ 763 | redirect(url: string): void; 764 | redirect(status: number, url: string): void; 765 | redirect(url: string, status: number): void; 766 | 767 | /** 768 | * Render `view` with the given `options` and optional callback `fn`. 769 | * When a callback function is given a response will _not_ be made 770 | * automatically, otherwise a response of _200_ and _text/html_ is given. 771 | * 772 | * Options: 773 | * 774 | * - `cache` boolean hinting to the engine it should cache 775 | * - `filename` filename of the view being rendered 776 | */ 777 | render(view: string, options?: Object, callback?: (err: Error, html: string) => void): void; 778 | render(view: string, callback?: (err: Error, html: string) => void): void; 779 | 780 | locals: any; 781 | 782 | charset: string; 783 | } 784 | 785 | interface NextFunction { 786 | (err?: any): void; 787 | } 788 | 789 | interface ErrorRequestHandler { 790 | (err: any, req: Request, res: Response, next: NextFunction): any; 791 | } 792 | 793 | 794 | interface Handler extends RequestHandler { } 795 | 796 | interface RequestParamHandler { 797 | (req: Request, res: Response, next: NextFunction, param: any): any; 798 | } 799 | 800 | interface Application extends IRouter, Express.Application { 801 | /** 802 | * Initialize the server. 803 | * 804 | * - setup default configuration 805 | * - setup default middleware 806 | * - setup route reflection methods 807 | */ 808 | init(): void; 809 | 810 | /** 811 | * Initialize application configuration. 812 | */ 813 | defaultConfiguration(): void; 814 | 815 | /** 816 | * Register the given template engine callback `fn` 817 | * as `ext`. 818 | * 819 | * By default will `require()` the engine based on the 820 | * file extension. For example if you try to render 821 | * a "foo.jade" file Express will invoke the following internally: 822 | * 823 | * app.engine('jade', require('jade').__express); 824 | * 825 | * For engines that do not provide `.__express` out of the box, 826 | * or if you wish to "map" a different extension to the template engine 827 | * you may use this method. For example mapping the EJS template engine to 828 | * ".html" files: 829 | * 830 | * app.engine('html', require('ejs').renderFile); 831 | * 832 | * In this case EJS provides a `.renderFile()` method with 833 | * the same signature that Express expects: `(path, options, callback)`, 834 | * though note that it aliases this method as `ejs.__express` internally 835 | * so if you're using ".ejs" extensions you dont need to do anything. 836 | * 837 | * Some template engines do not follow this convention, the 838 | * [Consolidate.js](https://github.com/visionmedia/consolidate.js) 839 | * library was created to map all of node's popular template 840 | * engines to follow this convention, thus allowing them to 841 | * work seamlessly within Express. 842 | */ 843 | engine(ext: string, fn: Function): Application; 844 | 845 | /** 846 | * Assign `setting` to `val`, or return `setting`'s value. 847 | * 848 | * app.set('foo', 'bar'); 849 | * app.get('foo'); 850 | * // => "bar" 851 | * app.set('foo', ['bar', 'baz']); 852 | * app.get('foo'); 853 | * // => ["bar", "baz"] 854 | * 855 | * Mounted servers inherit their parent server's settings. 856 | * 857 | * @param setting 858 | * @param val 859 | */ 860 | set(setting: string, val: any): Application; 861 | get: { 862 | (name: string): any; // Getter 863 | (name: string | RegExp, ...handlers: RequestHandler[]): Application; 864 | }; 865 | 866 | /** 867 | * Return the app's absolute pathname 868 | * based on the parent(s) that have 869 | * mounted it. 870 | * 871 | * For example if the application was 872 | * mounted as "/admin", which itself 873 | * was mounted as "/blog" then the 874 | * return value would be "/blog/admin". 875 | */ 876 | path(): string; 877 | 878 | /** 879 | * Check if `setting` is enabled (truthy). 880 | * 881 | * app.enabled('foo') 882 | * // => false 883 | * 884 | * app.enable('foo') 885 | * app.enabled('foo') 886 | * // => true 887 | */ 888 | enabled(setting: string): boolean; 889 | 890 | /** 891 | * Check if `setting` is disabled. 892 | * 893 | * app.disabled('foo') 894 | * // => true 895 | * 896 | * app.enable('foo') 897 | * app.disabled('foo') 898 | * // => false 899 | * 900 | * @param setting 901 | */ 902 | disabled(setting: string): boolean; 903 | 904 | /** 905 | * Enable `setting`. 906 | * 907 | * @param setting 908 | */ 909 | enable(setting: string): Application; 910 | 911 | /** 912 | * Disable `setting`. 913 | * 914 | * @param setting 915 | */ 916 | disable(setting: string): Application; 917 | 918 | /** 919 | * Configure callback for zero or more envs, 920 | * when no `env` is specified that callback will 921 | * be invoked for all environments. Any combination 922 | * can be used multiple times, in any order desired. 923 | * 924 | * Examples: 925 | * 926 | * app.configure(function(){ 927 | * // executed for all envs 928 | * }); 929 | * 930 | * app.configure('stage', function(){ 931 | * // executed staging env 932 | * }); 933 | * 934 | * app.configure('stage', 'production', function(){ 935 | * // executed for stage and production 936 | * }); 937 | * 938 | * Note: 939 | * 940 | * These callbacks are invoked immediately, and 941 | * are effectively sugar for the following: 942 | * 943 | * var env = process.env.NODE_ENV || 'development'; 944 | * 945 | * switch (env) { 946 | * case 'development': 947 | * ... 948 | * break; 949 | * case 'stage': 950 | * ... 951 | * break; 952 | * case 'production': 953 | * ... 954 | * break; 955 | * } 956 | * 957 | * @param env 958 | * @param fn 959 | */ 960 | configure(fn: Function): Application; 961 | configure(env0: string, fn: Function): Application; 962 | configure(env0: string, env1: string, fn: Function): Application; 963 | configure(env0: string, env1: string, env2: string, fn: Function): Application; 964 | configure(env0: string, env1: string, env2: string, env3: string, fn: Function): Application; 965 | configure(env0: string, env1: string, env2: string, env3: string, env4: string, fn: Function): Application; 966 | 967 | /** 968 | * Render the given view `name` name with `options` 969 | * and a callback accepting an error and the 970 | * rendered template string. 971 | * 972 | * Example: 973 | * 974 | * app.render('email', { name: 'Tobi' }, function(err, html){ 975 | * // ... 976 | * }) 977 | * 978 | * @param name 979 | * @param options or fn 980 | * @param fn 981 | */ 982 | render(name: string, options?: Object, callback?: (err: Error, html: string) => void): void; 983 | render(name: string, callback: (err: Error, html: string) => void): void; 984 | 985 | 986 | /** 987 | * Listen for connections. 988 | * 989 | * A node `http.Server` is returned, with this 990 | * application (which is a `Function`) as its 991 | * callback. If you wish to create both an HTTP 992 | * and HTTPS server you may do so with the "http" 993 | * and "https" modules as shown here: 994 | * 995 | * var http = require('http') 996 | * , https = require('https') 997 | * , express = require('express') 998 | * , app = express(); 999 | * 1000 | * http.createServer(app).listen(80); 1001 | * https.createServer({ ... }, app).listen(443); 1002 | */ 1003 | listen(port: number, hostname: string, backlog: number, callback?: Function): http.Server; 1004 | listen(port: number, hostname: string, callback?: Function): http.Server; 1005 | listen(port: number, callback?: Function): http.Server; 1006 | listen(path: string, callback?: Function): http.Server; 1007 | listen(handle: any, listeningListener?: Function): http.Server; 1008 | 1009 | route(path: string): IRoute; 1010 | 1011 | router: string; 1012 | 1013 | settings: any; 1014 | 1015 | resource: any; 1016 | 1017 | map: any; 1018 | 1019 | locals: any; 1020 | 1021 | /** 1022 | * The app.routes object houses all of the routes defined mapped by the 1023 | * associated HTTP verb. This object may be used for introspection 1024 | * capabilities, for example Express uses this internally not only for 1025 | * routing but to provide default OPTIONS behaviour unless app.options() 1026 | * is used. Your application or framework may also remove routes by 1027 | * simply by removing them from this object. 1028 | */ 1029 | routes: any; 1030 | } 1031 | 1032 | interface Express extends Application { 1033 | /** 1034 | * Framework version. 1035 | */ 1036 | version: string; 1037 | 1038 | /** 1039 | * Expose mime. 1040 | */ 1041 | mime: string; 1042 | 1043 | (): Application; 1044 | 1045 | /** 1046 | * Create an express application. 1047 | */ 1048 | createApplication(): Application; 1049 | 1050 | createServer(): Application; 1051 | 1052 | application: any; 1053 | 1054 | request: Request; 1055 | 1056 | response: Response; 1057 | } 1058 | 1059 | interface RequestHandler { 1060 | (req: Request, res: Response, next: NextFunction): any; 1061 | } 1062 | } 1063 | -------------------------------------------------------------------------------- /typings/express-session/express-session.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for express-session 2 | // Project: https://www.npmjs.org/package/express-session 3 | // Definitions by: Hiroki Horiuchi 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | /// 8 | 9 | declare namespace Express { 10 | 11 | export interface Request { 12 | session?: Session; 13 | } 14 | 15 | export interface Session { 16 | [key: string]: any; 17 | 18 | regenerate: (callback: (err: any) => void) => void; 19 | destroy: (callback: (err: any) => void) => void; 20 | reload: (callback: (err: any) => void) => void; 21 | save: (callback: (err: any) => void) => void; 22 | touch: (callback: (err: any) => void) => void; 23 | 24 | cookie: SessionCookie; 25 | } 26 | export interface SessionCookie { 27 | originalMaxAge: number; 28 | path: string; 29 | maxAge: number; 30 | secure?: boolean; 31 | httpOnly: boolean; 32 | domain?: string; 33 | expires: Date; 34 | serialize: (name: string, value: string) => string; 35 | } 36 | } 37 | 38 | declare module "express-session" { 39 | import express = require('express'); 40 | import node = require('events'); 41 | 42 | function session(options?: session.SessionOptions): express.RequestHandler; 43 | 44 | namespace session { 45 | export interface SessionOptions { 46 | secret: string; 47 | name?: string; 48 | store?: Store | MemoryStore; 49 | cookie?: express.CookieOptions; 50 | genid?: (req: express.Request) => string; 51 | rolling?: boolean; 52 | resave?: boolean; 53 | proxy?: boolean; 54 | saveUninitialized?: boolean; 55 | unset?: string; 56 | } 57 | 58 | export interface BaseMemoryStore { 59 | get: (sid: string, callback: (err: any, session: Express.Session) => void) => void; 60 | set: (sid: string, session: Express.Session, callback: (err: any) => void) => void; 61 | destroy: (sid: string, callback: (err: any) => void) => void; 62 | length?: (callback: (err: any, length: number) => void) => void; 63 | clear?: (callback: (err: any) => void) => void; 64 | } 65 | 66 | export abstract class Store extends node.EventEmitter { 67 | constructor(config?: any); 68 | 69 | regenerate (req: express.Request, fn: (err: any) => any): void; 70 | load (sid: string, fn: (err: any, session: Express.Session) => any): void; 71 | createSession (req: express.Request, sess: Express.Session): void; 72 | 73 | get: (sid: string, callback: (err: any, session: Express.Session) => void) => void; 74 | set: (sid: string, session: Express.Session, callback: (err: any) => void) => void; 75 | destroy: (sid: string, callback: (err: any) => void) => void; 76 | all: (callback: (err: any, obj: { [sid: string]: Express.Session; }) => void) => void; 77 | length: (callback: (err: any, length: number) => void) => void; 78 | clear: (callback: (err: any) => void) => void; 79 | } 80 | 81 | export class MemoryStore implements BaseMemoryStore { 82 | get: (sid: string, callback: (err: any, session: Express.Session) => void) => void; 83 | set: (sid: string, session: Express.Session, callback: (err: any) => void) => void; 84 | destroy: (sid: string, callback: (err: any) => void) => void; 85 | all: (callback: (err: any, obj: { [sid: string]: Express.Session; }) => void) => void; 86 | length: (callback: (err: any, length: number) => void) => void; 87 | clear: (callback: (err: any) => void) => void; 88 | } 89 | } 90 | 91 | export = session; 92 | } 93 | 94 | -------------------------------------------------------------------------------- /typings/express/express.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Express 4.x 2 | // Project: http://expressjs.com 3 | // Definitions by: Boris Yankov 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /* =================== USAGE =================== 7 | 8 | import * as express from "express"; 9 | var app = express(); 10 | 11 | =============================================== */ 12 | 13 | /// 14 | /// 15 | 16 | declare module "express" { 17 | import * as serveStatic from "serve-static"; 18 | import * as core from "express-serve-static-core"; 19 | 20 | /** 21 | * Creates an Express application. The express() function is a top-level function exported by the express module. 22 | */ 23 | function e(): core.Express; 24 | 25 | namespace e { 26 | 27 | /** 28 | * This is the only built-in middleware function in Express. It serves static files and is based on serve-static. 29 | */ 30 | var static: typeof serveStatic; 31 | 32 | export function Router(options?: any): core.Router; 33 | 34 | interface Application extends core.Application { } 35 | interface CookieOptions extends core.CookieOptions { } 36 | interface Errback extends core.Errback { } 37 | interface ErrorRequestHandler extends core.ErrorRequestHandler { } 38 | interface Express extends core.Express { } 39 | interface Handler extends core.Handler { } 40 | interface IRoute extends core.IRoute { } 41 | interface IRouter extends core.IRouter { } 42 | interface IRouterMatcher extends core.IRouterMatcher { } 43 | interface MediaType extends core.MediaType { } 44 | interface NextFunction extends core.NextFunction { } 45 | interface Request extends core.Request { } 46 | interface RequestHandler extends core.RequestHandler { } 47 | interface RequestParamHandler extends core.RequestParamHandler { } 48 | export interface Response extends core.Response { } 49 | interface Router extends core.Router { } 50 | interface Send extends core.Send { } 51 | } 52 | 53 | export = e; 54 | } 55 | -------------------------------------------------------------------------------- /typings/form-data/form-data.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for form-data 2 | // Project: https://github.com/felixge/node-form-data 3 | // Definitions by: Carlos Ballesteros Velasco 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | // Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts 7 | 8 | declare module "form-data" { 9 | export class FormData { 10 | append(key: string, value: any, options?: any): FormData; 11 | getHeaders(): Object; 12 | // TODO expand pipe 13 | pipe(to: any): any; 14 | submit(params: string|Object, callback: (error: any, response: any) => void): any; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /typings/method-override/method-override.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for method-override 2 | // Project: https://github.com/expressjs/method-override 3 | // Definitions by: Santi Albo 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare namespace Express { 9 | export interface Request { 10 | originalMethod?: string; 11 | } 12 | } 13 | 14 | declare module "method-override" { 15 | import express = require('express'); 16 | 17 | namespace e { 18 | export interface MethodOverrideOptions { 19 | methods: string[]; 20 | } 21 | } 22 | 23 | function e(getter?: string, options?: e.MethodOverrideOptions): express.RequestHandler; 24 | function e(getter?: (req: express.Request, res: express.Response) => string, options?: e.MethodOverrideOptions): express.RequestHandler; 25 | 26 | export = e; 27 | } 28 | -------------------------------------------------------------------------------- /typings/mime/mime.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for mime 2 | // Project: https://github.com/broofa/node-mime 3 | // Definitions by: Jeff Goddard 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | // Imported from: https://github.com/soywiz/typescript-node-definitions/mime.d.ts 7 | 8 | declare module "mime" { 9 | export function lookup(path: string): string; 10 | export function extension(mime: string): string; 11 | export function load(filepath: string): void; 12 | export function define(mimes: Object): void; 13 | 14 | interface Charsets { 15 | lookup(mime: string): string; 16 | } 17 | 18 | export var charsets: Charsets; 19 | export var default_type: string; 20 | } 21 | -------------------------------------------------------------------------------- /typings/mocha/mocha.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for mocha 2.2.5 2 | // Project: http://mochajs.org/ 3 | // Definitions by: Kazi Manzur Rashid , otiai10 , jt000 , Vadim Macagon 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | interface MochaSetupOptions { 7 | //milliseconds to wait before considering a test slow 8 | slow?: number; 9 | 10 | // timeout in milliseconds 11 | timeout?: number; 12 | 13 | // ui name "bdd", "tdd", "exports" etc 14 | ui?: string; 15 | 16 | //array of accepted globals 17 | globals?: any[]; 18 | 19 | // reporter instance (function or string), defaults to `mocha.reporters.Spec` 20 | reporter?: any; 21 | 22 | // bail on the first test failure 23 | bail?: boolean; 24 | 25 | // ignore global leaks 26 | ignoreLeaks?: boolean; 27 | 28 | // grep string or regexp to filter tests with 29 | grep?: any; 30 | } 31 | 32 | interface MochaDone { 33 | (error?: Error): void; 34 | } 35 | 36 | declare var mocha: Mocha; 37 | declare var describe: Mocha.IContextDefinition; 38 | declare var xdescribe: Mocha.IContextDefinition; 39 | // alias for `describe` 40 | declare var context: Mocha.IContextDefinition; 41 | // alias for `describe` 42 | declare var suite: Mocha.IContextDefinition; 43 | declare var it: Mocha.ITestDefinition; 44 | declare var xit: Mocha.ITestDefinition; 45 | // alias for `it` 46 | declare var test: Mocha.ITestDefinition; 47 | 48 | declare function before(action: () => void): void; 49 | 50 | declare function before(action: (done: MochaDone) => void): void; 51 | 52 | declare function before(description: string, action: () => void): void; 53 | 54 | declare function before(description: string, action: (done: MochaDone) => void): void; 55 | 56 | declare function setup(action: () => void): void; 57 | 58 | declare function setup(action: (done: MochaDone) => void): void; 59 | 60 | declare function after(action: () => void): void; 61 | 62 | declare function after(action: (done: MochaDone) => void): void; 63 | 64 | declare function after(description: string, action: () => void): void; 65 | 66 | declare function after(description: string, action: (done: MochaDone) => void): void; 67 | 68 | declare function teardown(action: () => void): void; 69 | 70 | declare function teardown(action: (done: MochaDone) => void): void; 71 | 72 | declare function beforeEach(action: () => void): void; 73 | 74 | declare function beforeEach(action: (done: MochaDone) => void): void; 75 | 76 | declare function beforeEach(description: string, action: () => void): void; 77 | 78 | declare function beforeEach(description: string, action: (done: MochaDone) => void): void; 79 | 80 | declare function suiteSetup(action: () => void): void; 81 | 82 | declare function suiteSetup(action: (done: MochaDone) => void): void; 83 | 84 | declare function afterEach(action: () => void): void; 85 | 86 | declare function afterEach(action: (done: MochaDone) => void): void; 87 | 88 | declare function afterEach(description: string, action: () => void): void; 89 | 90 | declare function afterEach(description: string, action: (done: MochaDone) => void): void; 91 | 92 | declare function suiteTeardown(action: () => void): void; 93 | 94 | declare function suiteTeardown(action: (done: MochaDone) => void): void; 95 | 96 | declare class Mocha { 97 | constructor(options?: { 98 | grep?: RegExp; 99 | ui?: string; 100 | reporter?: string; 101 | timeout?: number; 102 | bail?: boolean; 103 | }); 104 | 105 | /** Setup mocha with the given options. */ 106 | setup(options: MochaSetupOptions): Mocha; 107 | bail(value?: boolean): Mocha; 108 | addFile(file: string): Mocha; 109 | /** Sets reporter by name, defaults to "spec". */ 110 | reporter(name: string): Mocha; 111 | /** Sets reporter constructor, defaults to mocha.reporters.Spec. */ 112 | reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha; 113 | ui(value: string): Mocha; 114 | grep(value: string): Mocha; 115 | grep(value: RegExp): Mocha; 116 | invert(): Mocha; 117 | ignoreLeaks(value: boolean): Mocha; 118 | checkLeaks(): Mocha; 119 | /** 120 | * Function to allow assertion libraries to throw errors directly into mocha. 121 | * This is useful when running tests in a browser because window.onerror will 122 | * only receive the 'message' attribute of the Error. 123 | */ 124 | throwError(error: Error): void; 125 | /** Enables growl support. */ 126 | growl(): Mocha; 127 | globals(value: string): Mocha; 128 | globals(values: string[]): Mocha; 129 | useColors(value: boolean): Mocha; 130 | useInlineDiffs(value: boolean): Mocha; 131 | timeout(value: number): Mocha; 132 | slow(value: number): Mocha; 133 | enableTimeouts(value: boolean): Mocha; 134 | asyncOnly(value: boolean): Mocha; 135 | noHighlighting(value: boolean): Mocha; 136 | /** Runs tests and invokes `onComplete()` when finished. */ 137 | run(onComplete?: (failures: number) => void): Mocha.IRunner; 138 | } 139 | 140 | // merge the Mocha class declaration with a module 141 | declare namespace Mocha { 142 | /** Partial interface for Mocha's `Runnable` class. */ 143 | interface IRunnable { 144 | title: string; 145 | fn: Function; 146 | async: boolean; 147 | sync: boolean; 148 | timedOut: boolean; 149 | } 150 | 151 | /** Partial interface for Mocha's `Suite` class. */ 152 | interface ISuite { 153 | parent: ISuite; 154 | title: string; 155 | 156 | fullTitle(): string; 157 | } 158 | 159 | /** Partial interface for Mocha's `Test` class. */ 160 | interface ITest extends IRunnable { 161 | parent: ISuite; 162 | pending: boolean; 163 | 164 | fullTitle(): string; 165 | } 166 | 167 | /** Partial interface for Mocha's `Runner` class. */ 168 | interface IRunner {} 169 | 170 | interface IContextDefinition { 171 | (description: string, spec: () => void): ISuite; 172 | only(description: string, spec: () => void): ISuite; 173 | skip(description: string, spec: () => void): void; 174 | timeout(ms: number): void; 175 | } 176 | 177 | interface ITestDefinition { 178 | (expectation: string, assertion?: () => void): ITest; 179 | (expectation: string, assertion?: (done: MochaDone) => void): ITest; 180 | only(expectation: string, assertion?: () => void): ITest; 181 | only(expectation: string, assertion?: (done: MochaDone) => void): ITest; 182 | skip(expectation: string, assertion?: () => void): void; 183 | skip(expectation: string, assertion?: (done: MochaDone) => void): void; 184 | timeout(ms: number): void; 185 | } 186 | 187 | export module reporters { 188 | export class Base { 189 | stats: { 190 | suites: number; 191 | tests: number; 192 | passes: number; 193 | pending: number; 194 | failures: number; 195 | }; 196 | 197 | constructor(runner: IRunner); 198 | } 199 | 200 | export class Doc extends Base {} 201 | export class Dot extends Base {} 202 | export class HTML extends Base {} 203 | export class HTMLCov extends Base {} 204 | export class JSON extends Base {} 205 | export class JSONCov extends Base {} 206 | export class JSONStream extends Base {} 207 | export class Landing extends Base {} 208 | export class List extends Base {} 209 | export class Markdown extends Base {} 210 | export class Min extends Base {} 211 | export class Nyan extends Base {} 212 | export class Progress extends Base { 213 | /** 214 | * @param options.open String used to indicate the start of the progress bar. 215 | * @param options.complete String used to indicate a complete test on the progress bar. 216 | * @param options.incomplete String used to indicate an incomplete test on the progress bar. 217 | * @param options.close String used to indicate the end of the progress bar. 218 | */ 219 | constructor(runner: IRunner, options?: { 220 | open?: string; 221 | complete?: string; 222 | incomplete?: string; 223 | close?: string; 224 | }); 225 | } 226 | export class Spec extends Base {} 227 | export class TAP extends Base {} 228 | export class XUnit extends Base { 229 | constructor(runner: IRunner, options?: any); 230 | } 231 | } 232 | } 233 | 234 | declare module "mocha" { 235 | export = Mocha; 236 | } 237 | -------------------------------------------------------------------------------- /typings/node-uuid/node-uuid-base.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for node-uuid.js 2 | // Project: https://github.com/broofa/node-uuid 3 | // Definitions by: Jeff May 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /** Common definitions for all environments */ 7 | declare namespace __NodeUUID { 8 | interface UUIDOptions { 9 | 10 | /** 11 | * Node id as Array of 6 bytes (per 4.1.6). 12 | * Default: Randomly generated ID. See note 1. 13 | */ 14 | node?: any[]; 15 | 16 | /** 17 | * (Number between 0 - 0x3fff) RFC clock sequence. 18 | * Default: An internally maintained clockseq is used. 19 | */ 20 | clockseq?: number; 21 | 22 | /** 23 | * (Number | Date) Time in milliseconds since unix Epoch. 24 | * Default: The current time is used. 25 | */ 26 | msecs?: number|Date; 27 | 28 | /** 29 | * (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if msecs is unspecified. 30 | * Default: internal uuid counter is used, as per 4.2.1.2. 31 | */ 32 | nsecs?: number; 33 | } 34 | 35 | interface UUID { 36 | v1(options?: UUIDOptions): string; 37 | v1(options?: UUIDOptions, buffer?: number[], offset?: number): number[]; 38 | 39 | v4(options?: UUIDOptions): string; 40 | v4(options?: UUIDOptions, buffer?: number[], offset?: number): number[]; 41 | 42 | parse(id: string, buffer?: number[], offset?: number): number[]; 43 | 44 | unparse(buffer: number[], offset?: number): string; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /typings/node-uuid/node-uuid-cjs.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for node-uuid.js 2 | // Project: https://github.com/broofa/node-uuid 3 | // Definitions by: Jeff May 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | 8 | /** 9 | * Expose as CommonJS module 10 | * For use in node environment or browser environment (using webpack or other module loaders) 11 | */ 12 | declare module "node-uuid" { 13 | var uuid: __NodeUUID.UUID; 14 | export = uuid; 15 | } -------------------------------------------------------------------------------- /typings/node-uuid/node-uuid.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for node-uuid.js 2 | // Project: https://github.com/broofa/node-uuid 3 | // Definitions by: Jeff May 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | /// 8 | /// 9 | 10 | /** 11 | * Definitions for use in node environment 12 | * 13 | * !! For browser enviroments, use node-uuid-global or node-uuid-cjs 14 | */ 15 | declare module __NodeUUID { 16 | /** 17 | * Overloads for node environment 18 | * We need to duplicate some declarations because 19 | * interface merging doesn't work with overloads 20 | */ 21 | interface UUID { 22 | v1(options?: UUIDOptions): string; 23 | v1(options?: UUIDOptions, buffer?: number[], offset?: number): number[]; 24 | v1(options?: UUIDOptions, buffer?: Buffer, offset?: number): Buffer; 25 | 26 | v4(options?: UUIDOptions): string; 27 | v4(options?: UUIDOptions, buffer?: number[], offset?: number): number[]; 28 | v4(options?: UUIDOptions, buffer?: Buffer, offset?: number): Buffer; 29 | 30 | parse(id: string, buffer?: number[], offset?: number): number[]; 31 | parse(id: string, buffer?: Buffer, offset?: number): Buffer; 32 | 33 | unparse(buffer: number[], offset?: number): string; 34 | unparse(buffer: Buffer, offset?: number): string; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /typings/passport-local/passport-local.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for passport-local 1.0.0 2 | // Project: https://github.com/jaredhanson/passport-local 3 | // Definitions by: Maxime LUCE 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare module 'passport-local' { 9 | 10 | import passport = require('passport'); 11 | import express = require('express'); 12 | 13 | interface IStrategyOptions { 14 | usernameField?: string; 15 | passwordField?: string; 16 | passReqToCallback?: boolean; 17 | } 18 | 19 | interface IStrategyOptionsWithRequest { 20 | usernameField?: string; 21 | passwordField?: string; 22 | passReqToCallback: boolean; 23 | } 24 | 25 | interface IVerifyOptions { 26 | message: string; 27 | } 28 | 29 | interface VerifyFunctionWithRequest { 30 | (req: express.Request, username: string, password: string, done: (error: any, user?: any, options?: IVerifyOptions) => void): void; 31 | } 32 | 33 | interface VerifyFunction { 34 | (username: string, password: string, done: (error: any, user?: any, options?: IVerifyOptions) => void): void; 35 | } 36 | 37 | class Strategy implements passport.Strategy { 38 | constructor(options: IStrategyOptionsWithRequest, verify: VerifyFunctionWithRequest); 39 | constructor(options: IStrategyOptions, verify: VerifyFunction); 40 | constructor(verify: VerifyFunction); 41 | 42 | name: string; 43 | authenticate: (req: express.Request, options?: Object) => void; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /typings/passport/passport.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Passport v0.2.0 2 | // Project: http://passportjs.org 3 | // Definitions by: Horiuchi_H 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare namespace Express { 9 | export interface Request { 10 | authInfo?: any; 11 | 12 | // These declarations are merged into express's Request type 13 | login(user: any, done: (err: any) => void): void; 14 | login(user: any, options: Object, done: (err: any) => void): void; 15 | logIn(user: any, done: (err: any) => void): void; 16 | logIn(user: any, options: Object, done: (err: any) => void): void; 17 | 18 | logout(): void; 19 | logOut(): void; 20 | 21 | isAuthenticated(): boolean; 22 | isUnauthenticated(): boolean; 23 | } 24 | } 25 | 26 | declare module 'passport' { 27 | import express = require('express'); 28 | 29 | function use(strategy: Strategy): Passport; 30 | function use(name: string, strategy: Strategy): Passport; 31 | function unuse(name: string): Passport; 32 | function framework(fw: string): Passport; 33 | function initialize(options?: { userProperty: string; }): express.Handler; 34 | function session(options?: { pauseStream: boolean; }): express.Handler; 35 | 36 | function authenticate(strategy: string, callback?: Function): express.Handler; 37 | function authenticate(strategy: string, options: Object, callback?: Function): express.Handler; 38 | function authenticate(strategies: string[], callback?: Function): express.Handler; 39 | function authenticate(strategies: string[], options: Object, callback?: Function): express.Handler; 40 | function authorize(strategy: string, callback?: Function): express.Handler; 41 | function authorize(strategy: string, options: Object, callback?: Function): express.Handler; 42 | function authorize(strategies: string[], callback?: Function): express.Handler; 43 | function authorize(strategies: string[], options: Object, callback?: Function): express.Handler; 44 | function serializeUser(fn: (user: any, done: (err: any, id: any) => void) => void): void; 45 | function deserializeUser(fn: (id: any, done: (err: any, user: any) => void) => void): void; 46 | function transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void; 47 | 48 | interface Passport { 49 | use(strategy: Strategy): Passport; 50 | use(name: string, strategy: Strategy): Passport; 51 | unuse(name: string): Passport; 52 | framework(fw: string): Passport; 53 | initialize(options?: { userProperty: string; }): express.Handler; 54 | session(options?: { pauseStream: boolean; }): express.Handler; 55 | 56 | authenticate(strategy: string, callback?: Function): express.Handler; 57 | authenticate(strategy: string, options: Object, callback?: Function): express.Handler; 58 | authenticate(strategies: string[], callback?: Function): express.Handler; 59 | authenticate(strategies: string[], options: Object, callback?: Function): express.Handler; 60 | authorize(strategy: string, callback?: Function): express.Handler; 61 | authorize(strategy: string, options: Object, callback?: Function): express.Handler; 62 | authorize(strategies: string[], callback?: Function): express.Handler; 63 | authorize(strategies: string[], options: Object, callback?: Function): express.Handler; 64 | serializeUser(fn: (user: any, done: (err: any, id: any) => void) => void): void; 65 | deserializeUser(fn: (id: any, done: (err: any, user: any) => void) => void): void; 66 | transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void; 67 | } 68 | 69 | interface Strategy { 70 | name?: string; 71 | authenticate(req: express.Request, options?: Object): void; 72 | } 73 | 74 | interface Profile { 75 | provider: string; 76 | id: string; 77 | displayName: string; 78 | name? : { 79 | familyName: string; 80 | givenName: string; 81 | middleName?: string; 82 | }; 83 | emails?: { 84 | value: string; 85 | type?: string; 86 | }[]; 87 | photos?: { 88 | value: string; 89 | }[]; 90 | } 91 | } 92 | 93 | -------------------------------------------------------------------------------- /typings/request-promise/request-promise.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for request-promise v0.4.2 2 | // Project: https://www.npmjs.com/package/request-promise 3 | // Definitions by: Christopher Glantschnig , Joe Skeen 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | // Change [0]: 2015/08/20 - Aya Morisawa 7 | 8 | /// 9 | /// 10 | 11 | declare module 'request-promise' { 12 | import request = require('request'); 13 | import http = require('http'); 14 | 15 | interface RequestPromise extends request.Request { 16 | then(onfulfilled?: (value: any) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 17 | then(onfulfilled?: (value: any) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 18 | catch(onrejected?: (reason: any) => any | PromiseLike): Promise; 19 | catch(onrejected?: (reason: any) => void): Promise; 20 | finally(handler: () => PromiseLike): Promise; 21 | finally(handler: () => TResult): Promise; 22 | promise(): Promise; 23 | } 24 | 25 | interface RequestPromiseOptions extends request.CoreOptions { 26 | simple?: boolean; 27 | transform?: (body: any, response: http.IncomingMessage) => any; 28 | resolveWithFullResponse?: boolean; 29 | } 30 | 31 | var requestPromise: request.RequestAPI; 32 | export = requestPromise; 33 | } 34 | -------------------------------------------------------------------------------- /typings/request/request.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for request 2 | // Project: https://github.com/mikeal/request 3 | // Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor , Joe Skeen , Christopher Currens 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | // Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts 7 | 8 | /// 9 | /// 10 | 11 | declare module 'request' { 12 | import stream = require('stream'); 13 | import http = require('http'); 14 | import https = require('https'); 15 | import FormData = require('form-data'); 16 | import url = require('url'); 17 | import fs = require('fs'); 18 | 19 | namespace request { 20 | export interface RequestAPI { 23 | 24 | defaults(options: TOptions): RequestAPI; 25 | defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi; 26 | 27 | (uri: string, options?: TOptions, callback?: RequestCallback): TRequest; 28 | (uri: string, callback?: RequestCallback): TRequest; 29 | (options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; 30 | 31 | get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; 32 | get(uri: string, callback?: RequestCallback): TRequest; 33 | get(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; 34 | 35 | post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; 36 | post(uri: string, callback?: RequestCallback): TRequest; 37 | post(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; 38 | 39 | put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; 40 | put(uri: string, callback?: RequestCallback): TRequest; 41 | put(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; 42 | 43 | head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; 44 | head(uri: string, callback?: RequestCallback): TRequest; 45 | head(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; 46 | 47 | patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; 48 | patch(uri: string, callback?: RequestCallback): TRequest; 49 | patch(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; 50 | 51 | del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; 52 | del(uri: string, callback?: RequestCallback): TRequest; 53 | del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; 54 | 55 | forever(agentOptions: any, optionsArg: any): TRequest; 56 | jar(): CookieJar; 57 | cookie(str: string): Cookie; 58 | 59 | initParams: any; 60 | debug: boolean; 61 | } 62 | 63 | interface DefaultUriUrlRequestApi extends RequestAPI { 66 | 67 | defaults(options: TOptions): DefaultUriUrlRequestApi; 68 | (): TRequest; 69 | get(): TRequest; 70 | post(): TRequest; 71 | put(): TRequest; 72 | head(): TRequest; 73 | patch(): TRequest; 74 | del(): TRequest; 75 | } 76 | 77 | interface CoreOptions { 78 | baseUrl?: string; 79 | callback?: (error: any, response: http.IncomingMessage, body: any) => void; 80 | jar?: any; // CookieJar 81 | formData?: any; // Object 82 | form?: any; // Object or string 83 | auth?: AuthOptions; 84 | oauth?: OAuthOptions; 85 | aws?: AWSOptions; 86 | hawk?: HawkOptions; 87 | qs?: any; 88 | json?: any; 89 | multipart?: RequestPart[] | Multipart; 90 | agent?: http.Agent | https.Agent; 91 | agentOptions?: any; 92 | agentClass?: any; 93 | forever?: any; 94 | host?: string; 95 | port?: number; 96 | method?: string; 97 | headers?: Headers; 98 | body?: any; 99 | followRedirect?: boolean | ((response: http.IncomingMessage) => boolean); 100 | followAllRedirects?: boolean; 101 | maxRedirects?: number; 102 | encoding?: string; 103 | pool?: any; 104 | timeout?: number; 105 | proxy?: any; 106 | strictSSL?: boolean; 107 | gzip?: boolean; 108 | preambleCRLF?: boolean; 109 | postambleCRLF?: boolean; 110 | key?: Buffer; 111 | cert?: Buffer; 112 | passphrase?: string; 113 | ca?: Buffer; 114 | har?: HttpArchiveRequest; 115 | useQuerystring?: boolean; 116 | } 117 | 118 | interface UriOptions { 119 | uri: string; 120 | } 121 | interface UrlOptions { 122 | url: string; 123 | } 124 | export type RequiredUriUrl = UriOptions | UrlOptions; 125 | 126 | interface OptionalUriUrl { 127 | uri?: string; 128 | url?: string; 129 | } 130 | 131 | export type OptionsWithUri = UriOptions & CoreOptions; 132 | export type OptionsWithUrl = UrlOptions & CoreOptions; 133 | export type Options = OptionsWithUri | OptionsWithUrl; 134 | 135 | export interface RequestCallback { 136 | (error: any, response: http.IncomingMessage, body: any): void; 137 | } 138 | 139 | export interface HttpArchiveRequest { 140 | url?: string; 141 | method?: string; 142 | headers?: NameValuePair[]; 143 | postData?: { 144 | mimeType?: string; 145 | params?: NameValuePair[]; 146 | } 147 | } 148 | 149 | export interface NameValuePair { 150 | name: string; 151 | value: string; 152 | } 153 | 154 | export interface Multipart { 155 | chunked?: boolean; 156 | data?: { 157 | 'content-type'?: string, 158 | body: string 159 | }[]; 160 | } 161 | 162 | export interface RequestPart { 163 | headers?: Headers; 164 | body: any; 165 | } 166 | 167 | export interface Request extends stream.Stream { 168 | readable: boolean; 169 | writable: boolean; 170 | 171 | getAgent(): http.Agent; 172 | //start(): void; 173 | //abort(): void; 174 | pipeDest(dest: any): void; 175 | setHeader(name: string, value: string, clobber?: boolean): Request; 176 | setHeaders(headers: Headers): Request; 177 | qs(q: Object, clobber?: boolean): Request; 178 | form(): FormData.FormData; 179 | form(form: any): Request; 180 | multipart(multipart: RequestPart[]): Request; 181 | json(val: any): Request; 182 | aws(opts: AWSOptions, now?: boolean): Request; 183 | auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request; 184 | oauth(oauth: OAuthOptions): Request; 185 | jar(jar: CookieJar): Request; 186 | 187 | on(event: string, listener: Function): this; 188 | on(event: 'request', listener: (req: http.ClientRequest) => void): this; 189 | on(event: 'response', listener: (resp: http.IncomingMessage) => void): this; 190 | on(event: 'data', listener: (data: Buffer | string) => void): this; 191 | on(event: 'error', listener: (e: Error) => void): this; 192 | on(event: 'complete', listener: (resp: http.IncomingMessage, body?: string | Buffer) => void): this; 193 | 194 | write(buffer: Buffer, cb?: Function): boolean; 195 | write(str: string, cb?: Function): boolean; 196 | write(str: string, encoding: string, cb?: Function): boolean; 197 | write(str: string, encoding?: string, fd?: string): boolean; 198 | end(): void; 199 | end(chunk: Buffer, cb?: Function): void; 200 | end(chunk: string, cb?: Function): void; 201 | end(chunk: string, encoding: string, cb?: Function): void; 202 | pause(): void; 203 | resume(): void; 204 | abort(): void; 205 | destroy(): void; 206 | toJSON(): Object; 207 | } 208 | 209 | export interface Headers { 210 | [key: string]: any; 211 | } 212 | 213 | export interface AuthOptions { 214 | user?: string; 215 | username?: string; 216 | pass?: string; 217 | password?: string; 218 | sendImmediately?: boolean; 219 | bearer?: string; 220 | } 221 | 222 | export interface OAuthOptions { 223 | callback?: string; 224 | consumer_key?: string; 225 | consumer_secret?: string; 226 | token?: string; 227 | token_secret?: string; 228 | verifier?: string; 229 | } 230 | 231 | export interface HawkOptions { 232 | credentials: any; 233 | } 234 | 235 | export interface AWSOptions { 236 | secret: string; 237 | bucket?: string; 238 | } 239 | 240 | export interface CookieJar { 241 | setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void 242 | getCookieString(uri: string | url.Url): string 243 | getCookies(uri: string | url.Url): Cookie[] 244 | } 245 | 246 | export interface CookieValue { 247 | name: string; 248 | value: any; 249 | httpOnly: boolean; 250 | } 251 | 252 | export interface Cookie extends Array { 253 | constructor(name: string, req: Request): void; 254 | str: string; 255 | expires: Date; 256 | path: string; 257 | toString(): string; 258 | } 259 | } 260 | var request: request.RequestAPI; 261 | export = request; 262 | } 263 | -------------------------------------------------------------------------------- /typings/serve-static/serve-static.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for serve-static 1.7.1 2 | // Project: https://github.com/expressjs/serve-static 3 | // Definitions by: Uros Smolnik 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /* =================== USAGE =================== 7 | 8 | import * as serveStatic from "serve-static"; 9 | app.use(serveStatic("public/ftp", {"index": ["default.html", "default.htm"]})) 10 | 11 | =============================================== */ 12 | 13 | /// 14 | /// 15 | 16 | declare module "serve-static" { 17 | import * as express from "express-serve-static-core"; 18 | 19 | /** 20 | * Create a new middleware function to serve files from within a given root directory. 21 | * The file to serve will be determined by combining req.url with the provided root directory. 22 | * When a file is not found, instead of sending a 404 response, this module will instead call next() to move on to the next middleware, allowing for stacking and fall-backs. 23 | */ 24 | function serveStatic(root: string, options?: { 25 | /** 26 | * Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot ("."). 27 | * Note this check is done on the path itself without checking if the path actually exists on the disk. 28 | * If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny"). 29 | * The default value is 'ignore'. 30 | * 'allow' No special treatment for dotfiles 31 | * 'deny' Send a 403 for any request for a dotfile 32 | * 'ignore' Pretend like the dotfile does not exist and call next() 33 | */ 34 | dotfiles?: string; 35 | 36 | /** 37 | * Enable or disable etag generation, defaults to true. 38 | */ 39 | etag?: boolean; 40 | 41 | /** 42 | * Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for. 43 | * The first that exists will be served. Example: ['html', 'htm']. 44 | * The default value is false. 45 | */ 46 | extensions?: string[]; 47 | 48 | /** 49 | * By default this module will send "index.html" files in response to a request on a directory. 50 | * To disable this set false or to supply a new index pass a string or an array in preferred order. 51 | */ 52 | index?: boolean|string|string[]; 53 | 54 | /** 55 | * Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value. 56 | */ 57 | lastModified?: boolean; 58 | 59 | /** 60 | * Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module. 61 | */ 62 | maxAge?: number|string; 63 | 64 | /** 65 | * Redirect to trailing "/" when the pathname is a dir. Defaults to true. 66 | */ 67 | redirect?: boolean; 68 | 69 | /** 70 | * Function to set custom headers on response. Alterations to the headers need to occur synchronously. 71 | * The function is called as fn(res, path, stat), where the arguments are: 72 | * res the response object 73 | * path the file path that is being sent 74 | * stat the stat object of the file that is being sent 75 | */ 76 | setHeaders?: (res: express.Response, path: string, stat: any) => any; 77 | }): express.Handler; 78 | 79 | import * as m from "mime"; 80 | 81 | namespace serveStatic { 82 | var mime: typeof m; 83 | } 84 | 85 | export = serveStatic; 86 | } 87 | -------------------------------------------------------------------------------- /typings/validator/validator.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for validator.js v4.5.1 2 | // Project: https://github.com/chriso/validator.js 3 | // Definitions by: tgfjt , Ilya Mochalov 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | declare namespace ValidatorJS { 7 | interface ValidatorStatic { 8 | 9 | /************** 10 | * Validators * 11 | **************/ 12 | 13 | // check if the string contains the seed. 14 | contains(str: string, elem: any): boolean; 15 | 16 | // check if the string matches the comparison. 17 | equals(str: string, comparison: any): boolean; 18 | 19 | // check if the string is a date that's after the specified date (defaults to now). 20 | isAfter(str: string, date?: Date): boolean; 21 | 22 | // check if the string contains only letters (a-zA-Z). 23 | isAlpha(str: string): boolean; 24 | 25 | // check if the string contains only letters and numbers. 26 | isAlphanumeric(str: string): boolean; 27 | 28 | // check if the string contains ASCII chars only. 29 | isAscii(str: string): boolean; 30 | 31 | // check if a string is base64 encoded. 32 | isBase64(str: string): boolean; 33 | 34 | // check if the string is a date that's before the specified date. 35 | isBefore(str: string, date?: Date): boolean; 36 | 37 | // check if a string is a boolean. 38 | isBoolean(str: string): boolean; 39 | 40 | // check if the string's length (in bytes) falls in a range. 41 | isByteLength(str: string, options: IsByteLengthOptions): boolean; 42 | isByteLength(str: string, min: number, max?: number): boolean; 43 | 44 | // check if the string is a credit card. 45 | isCreditCard(str: string): boolean; 46 | 47 | // check if the string is a valid currency amount. 48 | isCurrency(str: string, options?: IsCurrencyOptions): boolean; 49 | 50 | // check if the string is a date. 51 | isDate(str: string): boolean; 52 | 53 | // check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc. 54 | isDecimal(str: string): boolean; 55 | 56 | // check if the string is a number that's divisible by another. 57 | isDivisibleBy(str: string, number: number): boolean; 58 | 59 | // check if the string is an email. 60 | isEmail(str: string, options?: IsEmailOptions): boolean; 61 | 62 | // check if the string is a fully qualified domain name (e.g. domain.com). 63 | isFQDN(str: string, options?: IsFQDNOptions): boolean; 64 | 65 | // check if the string is a float. 66 | isFloat(str: string, options?: IsFloatOptions): boolean; 67 | 68 | // check if the string contains any full-width chars. 69 | isFullWidth(str: string): boolean; 70 | 71 | // check if the string contains any half-width chars. 72 | isHalfWidth(str: string): boolean; 73 | 74 | // check if the string is a hexadecimal color. 75 | isHexColor(str: string): boolean; 76 | 77 | // check if the string is a hexadecimal number. 78 | isHexadecimal(str: string): boolean; 79 | 80 | // check if the string is an IP (version 4 or 6). 81 | isIP(str: string, version?: number): boolean; 82 | 83 | // check if the string is an ISBN (version 10 or 13). 84 | isISBN(str: string, version?: number): boolean; 85 | 86 | // check if the string is an ISIN (https://en.wikipedia.org/wiki/International_Securities_Identification_Number) 87 | // (stock/security identifier). 88 | isISIN(str: string): boolean; 89 | 90 | // check if the string is a valid ISO 8601 (https://en.wikipedia.org/wiki/ISO_8601) date. 91 | isISO8601(str: string): boolean; 92 | 93 | // check if the string is in a array of allowed values. 94 | isIn(str: string, values: any[]): boolean; 95 | 96 | // check if the string is an integer. 97 | isInt(str: string, options?: IsIntOptions): boolean; 98 | 99 | // check if the string is valid JSON (note: uses JSON.parse). 100 | isJSON(str: string): boolean; 101 | 102 | // check if the string's length falls in a range. 103 | // Note: this function takes into account surrogate pairs. 104 | isLength(str: string, options: IsLengthOptions): boolean; 105 | isLength(str: string, min: number, max?: number): boolean; 106 | 107 | // check if the string is lowercase. 108 | isLowercase(str: string): boolean; 109 | 110 | // check if the string is a MAC address. 111 | isMACAddress(str: string): boolean; 112 | 113 | // check if the string is a mobile phone number, (locale is one of ['zh-CN', 'zh-TW', 'en-ZA', 'en-AU', 'en-HK', 114 | // 'pt-PT', 'fr-FR', 'el-GR', 'en-GB', 'en-US', 'en-ZM', 'ru-RU', 'nb-NO', 'nn-NO', 'vi-VN', 'en-NZ', 'en-IN']). 115 | isMobilePhone(str: string, locale: string): boolean; 116 | 117 | // check if the string is a valid hex-encoded representation of a MongoDB ObjectId 118 | // (http://docs.mongodb.org/manual/reference/object-id/). 119 | isMongoId(str: string): boolean; 120 | 121 | // check if the string contains one or more multibyte chars. 122 | isMultibyte(str: string): boolean; 123 | 124 | // check if the string is null. 125 | isNull(str: string): boolean; 126 | 127 | // check if the string contains only numbers. 128 | isNumeric(str: string): boolean; 129 | 130 | // check if the string contains any surrogate pairs chars. 131 | isSurrogatePair(str: string): boolean; 132 | 133 | // check if the string is an URL. 134 | isURL(str: string, options?: IsURLOptions): boolean; 135 | 136 | // check if the string is a UUID (version 3, 4 or 5). 137 | isUUID(str: string, version?: number): boolean; 138 | 139 | // check if the string is uppercase. 140 | isUppercase(str: string): boolean; 141 | 142 | // check if the string contains a mixture of full and half-width chars. 143 | isVariableWidth(str: string): boolean; 144 | 145 | // checks characters if they appear in the whitelist. 146 | isWhitelisted(str: string, chars: string|string[]): boolean; 147 | 148 | // check if string matches the pattern. 149 | matches(str: string, pattern: any, modifiers?: string): boolean; 150 | 151 | /************** 152 | * Sanitizers * 153 | **************/ 154 | 155 | // remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need 156 | // to escape some chars, e.g. blacklist(input, '\\[\\]'). 157 | blacklist(input: string, chars: string): string; 158 | 159 | // replace <, >, &, ', " and / with HTML entities. 160 | escape(input: string): string; 161 | 162 | // trim characters from the left-side of the input. 163 | ltrim(input: any, chars?: string): string; 164 | 165 | // canonicalize an email address. 166 | normalizeEmail(email: string, options?: NormalizeEmailOptions): string; 167 | 168 | // trim characters from the right-side of the input. 169 | rtrim(input: any, chars?: string): string; 170 | 171 | // remove characters with a numerical value < 32 and 127, mostly control characters. If keep_new_lines is true, 172 | // newline characters are preserved (\n and \r, hex 0xA and 0xD). Unicode-safe in JavaScript. 173 | stripLow(input: string, keep_new_lines?: boolean): string; 174 | 175 | // convert the input to a boolean. Everything except for '0', 'false' and '' returns true. In strict mode only '1' 176 | // and 'true' return true. 177 | toBoolean(input: any, strict?: boolean): boolean; 178 | 179 | // convert the input to a date, or null if the input is not a date. 180 | toDate(input: any): Date; // Date or null 181 | 182 | // convert the input to a float, or NaN if the input is not a float. 183 | toFloat(input: any): number; // number or NaN 184 | 185 | // convert the input to an integer, or NaN if the input is not an integer. 186 | toInt(input: any, radix?: number): number; // number or NaN 187 | 188 | // convert the input to a string. 189 | toString(input: any): string; 190 | 191 | // trim characters (whitespace by default) from both sides of the input. 192 | trim(input: any, chars?: string): string; 193 | 194 | // remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will 195 | // need to escape some chars, e.g. whitelist(input, '\\[\\]'). 196 | whitelist(input: string, chars: string): string; 197 | 198 | /************** 199 | * Extensions * 200 | **************/ 201 | 202 | // add your own validators. 203 | // Note: that the first argument will be automatically coerced to a string. 204 | extend(name: string, fn: T): void; 205 | } 206 | 207 | // options for IsByteLength 208 | interface IsByteLengthOptions { 209 | min?: number; 210 | max?: number; 211 | } 212 | 213 | // options for IsCurrency 214 | interface IsCurrencyOptions { 215 | symbol?: string; 216 | require_symbol?: boolean; 217 | allow_space_after_symbol?: boolean; 218 | symbol_after_digits?: boolean; 219 | allow_negatives?: boolean; 220 | parens_for_negatives?: boolean; 221 | negative_sign_before_digits?: boolean; 222 | negative_sign_after_digits?: boolean; 223 | allow_negative_sign_placeholder?: boolean; 224 | thousands_separator?: string; 225 | decimal_separator?: string; 226 | allow_space_after_digits?: boolean; 227 | } 228 | 229 | // options for isEmail 230 | interface IsEmailOptions { 231 | allow_display_name?: boolean; 232 | allow_utf8_local_part?: boolean; 233 | require_tld?: boolean; 234 | } 235 | 236 | // options for isFQDN 237 | interface IsFQDNOptions { 238 | require_tld?: boolean; 239 | allow_underscores?: boolean; 240 | allow_trailing_dot?: boolean; 241 | } 242 | 243 | // options for IsFloat 244 | interface IsFloatOptions { 245 | min?: number; 246 | max?: number; 247 | } 248 | 249 | // options for IsInt 250 | interface IsIntOptions { 251 | min?: number; 252 | max?: number; 253 | } 254 | 255 | // options for IsLength 256 | interface IsLengthOptions { 257 | min?: number; 258 | max?: number; 259 | } 260 | 261 | // options for isURL 262 | interface IsURLOptions { 263 | protocols?: string[]; 264 | require_tld?: boolean; 265 | require_protocol?: boolean; 266 | require_valid_protocol?: boolean; 267 | allow_underscores?: boolean; 268 | host_whitelist?: boolean; 269 | host_blacklist?: boolean; 270 | allow_trailing_dot?: boolean; 271 | allow_protocol_relative_urls?: boolean; 272 | } 273 | 274 | // options for normalizeEmail 275 | interface NormalizeEmailOptions { 276 | lowercase?: boolean; 277 | remove_dots?: boolean; 278 | remove_extension?: boolean; 279 | } 280 | } 281 | 282 | declare module "validator" { 283 | let validator: ValidatorJS.ValidatorStatic; 284 | namespace validator {} 285 | export = validator; 286 | } 287 | 288 | // deprecated interfaces for backward compatibility, please use ValidatorJS.* instead the ones 289 | interface IValidatorStatic extends ValidatorJS.ValidatorStatic {} 290 | interface IURLoptions extends ValidatorJS.IsURLOptions {} 291 | interface IFQDNoptions extends ValidatorJS.IsFQDNOptions {} 292 | interface IEmailoptions extends ValidatorJS.NormalizeEmailOptions {} 293 | -------------------------------------------------------------------------------- /views/index.dust: -------------------------------------------------------------------------------- 1 | {>"partials/header"/} 2 | {>"partials/loggedin"/} 3 |
4 |
5 |

Welcome

6 |

This is an example TypeScript express application using sequelize and postgres.

7 |
8 |
9 |
10 |
11 | 12 | 13 |
14 |
15 | 16 | 17 |
18 | 19 |
20 |

Register

21 |
22 |
23 |
24 |
25 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In in porttitor dolor, pellentesque facilisis enim. Cras sed porttitor mauris. Nam malesuada dui non rutrum mollis. Integer euismod diam magna, non pulvinar neque vulputate sit amet. Proin magna urna, tempus vel consectetur ut, venenatis vel nisl. Duis non suscipit arcu, nec dapibus libero. Sed nec arcu nunc. Aliquam hendrerit, nisi sit amet sollicitudin convallis, enim purus tempus nulla, at porttitor est sem nec dolor. Integer quis tortor non nisi blandit tempor ac quis elit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

26 |

Nulla dictum augue sem, ut dapibus turpis condimentum at. Nullam aliquet mauris magna. Maecenas tristique facilisis diam sed elementum. Mauris dapibus malesuada bibendum. Vivamus pulvinar aliquet quam in dignissim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque ex velit, pulvinar vel nisl ut, laoreet fermentum arcu.

27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 | 35 | 36 |
37 |
38 | 39 | 40 |
41 |
42 | 43 | 44 |
45 | 46 |
47 |
48 |
49 | {>"partials/footer"/} -------------------------------------------------------------------------------- /views/partials/footer.dust: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /views/partials/header.dust: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {+title}Home{/title} 12 | 13 | 14 | {+http_header/} 15 | 16 | 17 | 18 |
19 | {#errors} 20 | 24 | {/errors} 25 | {#messages} 26 | 30 | {/messages} 31 | 32 | -------------------------------------------------------------------------------- /views/partials/loggedin.dust: -------------------------------------------------------------------------------- 1 | {?account} 2 | 5 | {/account} -------------------------------------------------------------------------------- /views/settings.dust: -------------------------------------------------------------------------------- 1 | {>"partials/header"/} 2 |
3 |
4 |

Account Settings

5 |

This area is only accessible when you are logged in.

6 |
7 |
8 |
9 |
10 | 11 | {#addresses} 12 | 13 | 14 | 15 | 16 | 17 | 18 | {/addresses} 19 |
{street}{city}{state}{zip}
20 |
21 |
22 |
23 |
24 | 25 |
26 |
27 | 28 | 29 |
30 |
31 | 32 | 33 |
34 |
35 | 36 | 37 |
38 |
39 | 40 | 41 |
42 | 43 |
44 |
45 |
46 | {>"partials/footer"/} --------------------------------------------------------------------------------