add express-sslify types (#36482)

This commit is contained in:
Ben Grynhaus 2019-06-29 03:58:15 +03:00 committed by Ben Lichtman
parent e59b55d75c
commit 3fee2364df
4 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import { Application } from 'express';
import { HTTPS } from 'express-sslify';
declare const express: Application;
declare const booleanFlag: boolean;
express.use(HTTPS());
express.use(HTTPS({}));
express.use(HTTPS({ trustAzureHeader: booleanFlag }));
express.use(HTTPS({ trustProtoHeader: booleanFlag }));
express.use(HTTPS({ trustXForwardedHostHeader: booleanFlag }));
express.use(
HTTPS({
trustXForwardedHostHeader: booleanFlag,
trustAzureHeader: booleanFlag,
trustProtoHeader: booleanFlag,
})
);

32
types/express-sslify/index.d.ts vendored Normal file
View File

@ -0,0 +1,32 @@
// Type definitions for express-sslify 1.2
// Project: https://github.com/florianheinemann/express-sslify
// Definitions by: Ben Grynhaus <https://github.com/bengry>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { RequestHandler } from 'express';
export interface Options {
/**
* Heroku, nodejitsu and other hosters often use reverse proxies which offer SSL endpoints but then forward unencrypted HTTP traffic to the website.
* This makes it difficult to detect if the original request was indeed via HTTPS.
* Luckily, most reverse proxies set the x-forwarded-proto header flag with the original request scheme.
* @default false
*/
trustProtoHeader?: boolean;
/**
* Azure has a slightly different way of signaling encrypted connections.
* To tell express-sslify to look out for Azure's x-arr-ssl header.
* @default false
*/
trustAzureHeader?: boolean;
/**
* If your reverse proxy sends the original host using the X-Forwarded-Host header and you need to use that instead of the Host header for the redirect.
* @default false
*/
trustXForwardedHostHeader?: boolean;
}
export function HTTPS(options?: Options): RequestHandler;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"express-sslify-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }