express-result-types
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -5,3 +5,3 @@ { | ||
"typings": "./target/index.d.ts", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "lint": "tslint --project tsconfig.json --type-check", |
/// <reference types="express" /> | ||
import * as express from 'express'; | ||
import { Result } from './result'; | ||
export declare const applyResultToExpress: ({req, res, result}: { | ||
req: express.Request; | ||
res: express.Response; | ||
result: Result; | ||
}) => void; | ||
export declare const wrap: (fn: (req: express.Request) => Result) => express.RequestHandler; | ||
export declare const wrapAsync: (fn: (req: express.Request) => Promise<Result>) => express.RequestHandler; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const MapHelpers = require("./helpers/map"); | ||
const applyResultToExpress = ({ req, res, result, }) => { | ||
exports.applyResultToExpress = ({ req, res, result, }) => { | ||
const headersStringDictionary = MapHelpers.toStringDictionary(result.header.headers); | ||
const sessionStringDictionary = result.newSession !== undefined ? MapHelpers.toStringDictionary(result.newSession) : {}; | ||
req.session.data = sessionStringDictionary; | ||
const maybeSessionStringDictionary = result.newSession !== undefined | ||
? MapHelpers.toStringDictionary(result.newSession) | ||
: undefined; | ||
if (maybeSessionStringDictionary !== undefined) { | ||
const sessionStringDictionary = maybeSessionStringDictionary; | ||
req.session.data = sessionStringDictionary; | ||
} | ||
res | ||
@@ -18,3 +23,3 @@ .status(result.header.status) | ||
const result = fn(req); | ||
applyResultToExpress({ req, res, result }); | ||
exports.applyResultToExpress({ req, res, result }); | ||
}; | ||
@@ -25,5 +30,5 @@ const wrapAsyncRequestHandler = promiseFn => (req, res, next) => promiseFn(req, res).catch(next); | ||
return resultPromise.then(result => { | ||
applyResultToExpress({ req, res, result }); | ||
exports.applyResultToExpress({ req, res, result }); | ||
}); | ||
}); | ||
//# sourceMappingURL=wrap.js.map |
Sorry, the diff of this file is not supported yet
15137
172