basic-auth: Make auth return value optional

This commit is contained in:
Michael Zugelder
2017-05-18 14:36:55 +02:00
parent 6b64c4f2a1
commit 0249359fe1
3 changed files with 8 additions and 4 deletions

View File

@@ -1,4 +1,7 @@
import {IncomingMessage} from 'http';
import auth = require('basic-auth');
auth(null);
const loginData = auth(undefined! as IncomingMessage);
if (loginData) {
const {name, pass} = loginData;
}

View File

@@ -7,7 +7,8 @@
import * as http from 'http';
declare function auth(req: http.IncomingMessage): auth.BasicAuthResult;
// See https://github.com/jshttp/basic-auth/blob/v1.1.0/index.js#L49
declare function auth(req: http.IncomingMessage): auth.BasicAuthResult | undefined;
declare namespace auth {
interface BasicAuthResult {

View File

@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"