Comparing version 1.0.30 to 1.0.31
{ | ||
"name": "server", | ||
"version": "1.0.30", | ||
"version": "1.0.31", | ||
"description": "A modern and powerful server for Node.js", | ||
@@ -8,3 +8,5 @@ "homepage": "https://serverjs.io/", | ||
"bugs": "https://github.com/franciscop/server/issues", | ||
"funding": "https://www.paypal.me/franciscopresencia/19", | ||
"funding": { | ||
"url": "https://www.paypal.me/franciscopresencia/19" | ||
}, | ||
"author": "Francisco Presencia <public@francisco.io> (https://francisco.io/)", | ||
@@ -11,0 +13,0 @@ "license": "MIT", |
const express = require('express'); | ||
const hbs = require('hbs'); | ||
const path = require('path'); | ||
@@ -31,3 +33,3 @@ module.exports = { | ||
}, | ||
init: ctx => { | ||
init: async ctx => { | ||
ctx.express = express; | ||
@@ -44,4 +46,17 @@ ctx.app = ctx.express(); | ||
// Add the views into the core | ||
if (path.resolve(ctx.options.views) === path.resolve(process.cwd())) { | ||
throw new Error( | ||
'The "views" option should point to a subfolder of the project and not the root of it' | ||
); | ||
} | ||
await new Promise(function(resolve, reject) { | ||
hbs.registerPartials(ctx.options.views, function(err) { | ||
if (err) reject(err); | ||
resolve(); | ||
}); | ||
}); | ||
// Accept HTML as a render extension | ||
ctx.app.engine('html', require('hbs').__express); | ||
ctx.app.engine('html', hbs.__express); | ||
@@ -48,0 +63,0 @@ if (ctx.options.engine) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3981
784898
161