mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
Add definition for "email-templates".
Update definition for "helmet".
This commit is contained in:
26
email-templates/email-templates-tests.ts
Normal file
26
email-templates/email-templates-tests.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
///<reference path="email-templates.d.ts"/>
|
||||
|
||||
import EmailTemplates = require('email-templates');
|
||||
|
||||
var EmailTemplate = EmailTemplates.EmailTemplate;
|
||||
var template = new EmailTemplate("./");
|
||||
var users = [
|
||||
{
|
||||
email: 'pappa.pizza@spaghetti.com',
|
||||
name: {
|
||||
first: 'Pappa',
|
||||
last: 'Pizza'
|
||||
}
|
||||
},
|
||||
{
|
||||
email: 'mister.geppetto@spaghetti.com',
|
||||
name: {
|
||||
first: 'Mister',
|
||||
last: 'Geppetto'
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
var templates = users.map(function(user) {
|
||||
return template.render(user);
|
||||
})
|
||||
54
email-templates/email-templates.d.ts
vendored
Normal file
54
email-templates/email-templates.d.ts
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Type definitions for node-email-templates
|
||||
// Project: https://github.com/niftylettuce/node-email-templates
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* @summary Interface for result of email template.
|
||||
* @interface
|
||||
*/
|
||||
interface EmailTemplateResults {
|
||||
/**
|
||||
* @summary HTML result.
|
||||
* @type {string}
|
||||
*/
|
||||
html: string;
|
||||
|
||||
/**
|
||||
* @summary Text result.
|
||||
* @type {string}
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Interface for callback of email callback.
|
||||
* @interface
|
||||
*/
|
||||
interface EmailTemplateCallback {
|
||||
/**
|
||||
* @summary Callback signature.
|
||||
*/
|
||||
(err: Object, results: EmailTemplateResults): void;
|
||||
}
|
||||
|
||||
declare module "email-templates" {
|
||||
/**
|
||||
* @summary Email template class.
|
||||
* @class
|
||||
*/
|
||||
export class EmailTemplate {
|
||||
/**
|
||||
* @summary Constructor.
|
||||
* @param {string} templateDir The template directory.
|
||||
*/
|
||||
constructor(templateDir: string);
|
||||
|
||||
/**
|
||||
* @summary Render a single template.
|
||||
* @param {EmailTemplateCallback|Object} locals The variables or callback function.
|
||||
* @param {EmailTemplateCallback} callback The callback function.
|
||||
*/
|
||||
render(locals: EmailTemplateCallback|Object, callback?: EmailTemplateCallback): void;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +1,62 @@
|
||||
/// <reference path="helmet.d.ts" />
|
||||
|
||||
import express = require("express")
|
||||
import helmet = require("helmet");
|
||||
|
||||
var app = express();
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet}.
|
||||
*/
|
||||
function helmetTest() {
|
||||
helmet();
|
||||
app.use(helmet());
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#xssFilter} function.
|
||||
*/
|
||||
function contentSecurityPolicyTest() {
|
||||
helmet.xssFilter();
|
||||
helmet.xssFilter({ setOnOldIE: true });
|
||||
app.use(helmet.xssFilter());
|
||||
app.use(helmet.xssFilter({ setOnOldIE: true }));
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#frameguard} function.
|
||||
*/
|
||||
function frameguardTest() {
|
||||
helmet.frameguard();
|
||||
helmet.frameguard("sameorigin");
|
||||
app.use(helmet.frameguard());
|
||||
app.use(helmet.frameguard("sameorigin"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#hsts} function.
|
||||
*/
|
||||
function hstsTest() {
|
||||
helmet.hsts();
|
||||
helmet.hsts({ maxAge: 7776000000 });
|
||||
app.use(helmet.hsts());
|
||||
app.use(helmet.hsts({ maxAge: 7776000000 }));
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#ieNoOpen} function.
|
||||
*/
|
||||
function ieNoOpenTest() {
|
||||
helmet.ieNoOpen();
|
||||
app.use(helmet.ieNoOpen());
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#noSniff} function.
|
||||
*/
|
||||
function noSniffTest() {
|
||||
helmet.noSniff();
|
||||
app.use(helmet.noSniff());
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#publicKeyPins} function.
|
||||
*/
|
||||
function publicKeyPinsTest() {
|
||||
helmet.publicKeyPins({
|
||||
app.use(helmet.publicKeyPins({
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
includeSubdomains: true,
|
||||
reportUri: "http://example.com"
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
114
helmet/helmet.d.ts
vendored
114
helmet/helmet.d.ts
vendored
@@ -3,55 +3,75 @@
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface Helmet {
|
||||
(): void;
|
||||
|
||||
/**
|
||||
* @summary Prevent clickjacking.
|
||||
* @param {string} header The header.
|
||||
*/
|
||||
frameguard(header ?: string): void;
|
||||
|
||||
/**
|
||||
* @summary Hide "X-Powered-By" header.
|
||||
* @param {Object} options The options.
|
||||
*/
|
||||
hidePoweredBy(options ?: Object): void;
|
||||
|
||||
/**
|
||||
* @summary Adds the "Strict-Transport-Security" header.
|
||||
* @param {Object} options The options.
|
||||
*/
|
||||
hsts(options ?: Object): void;
|
||||
|
||||
/**
|
||||
* @summary Add the "X-Download-Options" header.
|
||||
*/
|
||||
ieNoOpen(): void;
|
||||
|
||||
/**
|
||||
* @summary Add the "Cache-Control" and "Pragma" headers to stop caching.
|
||||
*/
|
||||
nocache(options ?: Object): void;
|
||||
|
||||
/**
|
||||
* @summary Adds the "X-Content-Type-Options" header.
|
||||
*/
|
||||
noSniff(): void;
|
||||
|
||||
/**
|
||||
* @summary Adds the "Public-Key-Pins" header.
|
||||
*/
|
||||
publicKeyPins(options ?: Object): void;
|
||||
|
||||
/**
|
||||
* @summary Prevent Cross-site scripting attacks.
|
||||
* @param {Object} options The options.
|
||||
*/
|
||||
xssFilter(options ?: Object): void;
|
||||
}
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
declare module "helmet" {
|
||||
import express = require("express");
|
||||
|
||||
/**
|
||||
* @summary Interface for helmet class.
|
||||
* @interface
|
||||
*/
|
||||
interface Helmet {
|
||||
/**
|
||||
* @summary Constructor.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
():express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Prevent clickjacking.
|
||||
* @param {string} header The header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
frameguard(header ?: string):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Hide "X-Powered-By" header.
|
||||
* @param {Object} options The options.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
hidePoweredBy(options ?: Object):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Adds the "Strict-Transport-Security" header.
|
||||
* @param {Object} options The options.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
hsts(options ?: Object):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Add the "X-Download-Options" header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
ieNoOpen():express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Add the "Cache-Control" and "Pragma" headers to stop caching.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
noCache(options ?: Object):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Adds the "X-Content-Type-Options" header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
noSniff():express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Adds the "Public-Key-Pins" header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
publicKeyPins(options ?: Object):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Prevent Cross-site scripting attacks.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
* @param {Object} options The options.
|
||||
*/
|
||||
xssFilter(options ?: Object):express.RequestHandler;
|
||||
}
|
||||
|
||||
var helmet: Helmet;
|
||||
export = helmet;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user