Fix linter
This commit is contained in:
parent
eb3a2553ba
commit
a54d3528a8
5 changed files with 23 additions and 20 deletions
|
@ -1,11 +1,11 @@
|
||||||
|
import * as staticFile from 'connect-static-file';
|
||||||
import { Request, Response } from 'express';
|
import { Request, Response } from 'express';
|
||||||
import * as staticFile from 'connect-static-file'
|
|
||||||
import * as path from 'path';
|
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'));
|
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;
|
response.statusCode = 404;
|
||||||
return handle404Middleware(request, response, next);
|
return handle404Middleware(request, response, next);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import * as basicAuth from 'express-basic-auth';
|
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({
|
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
|
challenge: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import * as winston from 'winston';
|
|
||||||
import * as expressWinston from 'express-winston';
|
import * as expressWinston from 'express-winston';
|
||||||
|
import * as winston from 'winston';
|
||||||
|
|
||||||
export default expressWinston.logger({
|
export default expressWinston.logger({
|
||||||
transports: [
|
colorize: true,
|
||||||
new winston.transports.Console({
|
|
||||||
colorize: true
|
|
||||||
})
|
|
||||||
],
|
|
||||||
meta: false,
|
meta: false,
|
||||||
msg: '{{ req.url }} '
|
msg: '{{ req.url }} '
|
||||||
.concat('status:{{ res.statusCode }} ')
|
.concat('status:{{ res.statusCode }} ')
|
||||||
.concat('useragent:{{ req.headers["user-agent"] }} ')
|
.concat('useragent:{{ req.headers["user-agent"] }} ')
|
||||||
.concat('time:{{ res.responseTime }}ms'),
|
.concat('time:{{ res.responseTime }}ms'),
|
||||||
colorize: true,
|
statusLevels: true,
|
||||||
statusLevels: true
|
transports: [
|
||||||
|
new winston.transports.Console({
|
||||||
|
colorize: true
|
||||||
|
})
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import * as serveIndex from 'serve-index';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as serveIndex from 'serve-index';
|
||||||
|
|
||||||
function isDirectory(url : string) : boolean {
|
function isDirectory(url: string): boolean {
|
||||||
return /\/$/.test(url);
|
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)) {
|
if (isDirectory(request.url)) {
|
||||||
request.url = path.join(request.url, 'index.html');
|
request.url = path.join(request.url, 'index.html');
|
||||||
}
|
}
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function staticFileHandle(serveDir : string) {
|
export function staticFileHandle(serveDir: string) {
|
||||||
return express.static(serveDir, {
|
return express.static(serveDir, {
|
||||||
dotfiles: 'ignore',
|
dotfiles: 'ignore',
|
||||||
index: false,
|
index: false,
|
||||||
|
@ -21,7 +21,7 @@ export function staticFileHandle(serveDir : string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function serveIndexHandle(serveDir : string) {
|
export function serveIndexHandle(serveDir: string) {
|
||||||
return serveIndex(serveDir, {
|
return serveIndex(serveDir, {
|
||||||
icons: true
|
icons: true
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
"extends": "tslint:recommended",
|
"extends": "tslint:recommended",
|
||||||
"rules": {
|
"rules": {
|
||||||
"quotemark": [true, "single"],
|
"quotemark": [true, "single"],
|
||||||
"trailing-comma": [false]
|
"trailing-comma": false,
|
||||||
|
"only-arrow-functions": false,
|
||||||
|
"interface-name": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue