Fix linter

This commit is contained in:
Jake Howard 2017-04-18 13:52:56 +01:00
parent eb3a2553ba
commit a54d3528a8
5 changed files with 23 additions and 20 deletions

View file

@ -1,11 +1,11 @@
import * as staticFile from 'connect-static-file';
import { Request, Response } from 'express';
import * as staticFile from 'connect-static-file'
import * as path from 'path';
export default function handle404(serveDir : string) {
export default function handle404(serveDir: string) {
const handle404Middleware = staticFile(path.join(serveDir, '.404.html'));
return function (request : Request, response : Response, next : Function) {
return function (request: Request, response: Response, next: Function) {
response.statusCode = 404;
return handle404Middleware(request, response, next);
}
};
}

View file

@ -1,8 +1,9 @@
import * as basicAuth from 'express-basic-auth';
export default function basicAuthHandler(username : string, password : string) {
export default function basicAuthHandler(username: string, password: string) {
return basicAuth({
authorizer: (req_username : string, req_password : string) => req_username === username && req_password === password,
authorizer:
(reqUsername: string, reqPassword: string) => reqUsername === username && reqPassword === password,
challenge: true
});
}

View file

@ -1,17 +1,17 @@
import * as winston from 'winston';
import * as expressWinston from 'express-winston';
import * as winston from 'winston';
export default expressWinston.logger({
transports: [
new winston.transports.Console({
colorize: true
})
],
colorize: true,
meta: false,
msg: '{{ req.url }} '
.concat('status:{{ res.statusCode }} ')
.concat('useragent:{{ req.headers["user-agent"] }} ')
.concat('time:{{ res.responseTime }}ms'),
colorize: true,
statusLevels: true
statusLevels: true,
transports: [
new winston.transports.Console({
colorize: true
})
],
});

View file

@ -1,19 +1,19 @@
import * as express from 'express';
import * as serveIndex from 'serve-index';
import * as path from 'path';
import * as serveIndex from 'serve-index';
function isDirectory(url : string) : boolean {
function isDirectory(url: string): boolean {
return /\/$/.test(url);
}
export function indexHandle(request : express.Request, response : express.Response, next : Function) {
export function indexHandle(request: express.Request, response: express.Response, next: Function) {
if (isDirectory(request.url)) {
request.url = path.join(request.url, 'index.html');
}
return next();
}
export function staticFileHandle(serveDir : string) {
export function staticFileHandle(serveDir: string) {
return express.static(serveDir, {
dotfiles: 'ignore',
index: false,
@ -21,7 +21,7 @@ export function staticFileHandle(serveDir : string) {
});
}
export function serveIndexHandle(serveDir : string) {
export function serveIndexHandle(serveDir: string) {
return serveIndex(serveDir, {
icons: true
});

View file

@ -2,6 +2,8 @@
"extends": "tslint:recommended",
"rules": {
"quotemark": [true, "single"],
"trailing-comma": [false]
"trailing-comma": false,
"only-arrow-functions": false,
"interface-name": false
}
}