@kaliber/build 0.0.154 → 0.0.156

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/lib/serve.js +10 -3
  2. package/package.json +1 -1
package/lib/serve.js CHANGED
@@ -69,7 +69,7 @@ app.use((err, req, res, next) => {
69
69
  return res.status(err.status).send()
70
70
 
71
71
  reportServerError(err, req)
72
- serveInternalServerError(err, { req, res, next })
72
+ serveInternalServerError(err, req, res, next)
73
73
  })
74
74
 
75
75
  app.listen(port, () => console.log(`Server listening at port ${port}`))
@@ -88,7 +88,9 @@ async function resolveFile(req, res, next) {
88
88
  for (const dir of dirs) {
89
89
  for (const [file, handler] of combinations) {
90
90
  const filePath = resolve(dir, file)
91
- if (await fileExists(filePath)) return handler(filePath)
91
+ if (await fileExists(filePath)) {
92
+ return handler(filePath)
93
+ }
92
94
  }
93
95
  }
94
96
 
@@ -135,9 +137,14 @@ function possibleDirectories(path) {
135
137
 
136
138
  function serveIndexWithRouting(file, req, res, next) {
137
139
  const routeTemplate = envRequire(file)
138
-
139
140
  const location = parsePath(req.url)
140
141
 
142
+ if (routeTemplate.handleRequest)
143
+ return routeTemplate.handleRequest(location, req, res).catch(error => {
144
+ reportServerError(error, req)
145
+ serveInternalServerError(error, req, res, next)
146
+ })
147
+
141
148
  const [dataOrPromise, template] = getDataAndRouteTemplate(routeTemplate, location, req)
142
149
 
143
150
  if (dataOrPromise.then)
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.154",
2
+ "version": "0.0.156",
3
3
  "name": "@kaliber/build",
4
4
  "description": "Zero configuration, opinionated webpack / react build setup",
5
5
  "scripts": {