Skip to content

Commit

Permalink
destructors (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlaziuk authored Aug 19, 2017
1 parent ac1cd47 commit e8ca550
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
21 changes: 7 additions & 14 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@ export function mithrilExpressMiddleware(
opt: Partial<IOptions> = {},
): RequestHandler {
return async (
{
path,
cookies,
body,
query,
},
{
send,
},
req,
res,
next,
) => {
const {
Expand All @@ -44,16 +37,16 @@ export function mithrilExpressMiddleware(
html = (partial: Promise<string>) => partial,
} = opt;
try {
send(
res.send(
await html(
routeRender(
routes,
path,
req.path,
defaultRoute,
{
...(attrsCookies && cookies ? cookies : {}),
...(attrsBody && body ? body : {}),
...(attrsQuery && query ? query : {}),
...(attrsCookies && req.cookies ? req.cookies : {}),
...(attrsBody && req.body ? req.body : {}),
...(attrsQuery && req.query ? req.query : {}),
...attrs,
},
),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mithril-express-middleware",
"version": "1.1.8",
"version": "1.1.9",
"description": "express middleware for mithril.js projects",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit e8ca550

Please sign in to comment.