@tinyhttp/app 2.0.21 → 2.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare type AppSettings = Partial<{
13
13
  bindAppToReqRes: boolean;
14
14
  xPoweredBy: string | boolean;
15
15
  enableReqRoute: boolean;
16
+ views: string;
16
17
  }>;
17
18
  /**
18
19
  * Function that processes the template
package/dist/index.js CHANGED
@@ -169,7 +169,7 @@ class App extends Router {
169
169
  this.engines = {};
170
170
  this.onError = (options === null || options === void 0 ? void 0 : options.onError) || onErrorHandler;
171
171
  this.noMatchHandler = (options === null || options === void 0 ? void 0 : options.noMatchHandler) || this.onError.bind(null, { code: 404 });
172
- this.settings = options.settings || { xPoweredBy: true };
172
+ this.settings = options.settings || { xPoweredBy: true, views: process.cwd() };
173
173
  this.applyExtensions = options === null || options === void 0 ? void 0 : options.applyExtensions;
174
174
  this.attach = (req, res) => setImmediate(this.handler.bind(this, req, res, undefined), req, res);
175
175
  }
@@ -206,7 +206,7 @@ class App extends Router {
206
206
  * @param cb Callback that consumes error and html
207
207
  */
208
208
  render(file, data = {}, cb, options = {}) {
209
- options.viewsFolder = options.viewsFolder || `${process.cwd()}/views`;
209
+ options.viewsFolder = options.viewsFolder || this.settings.views || `${process.cwd()}/views`;
210
210
  options.ext = options.ext || file.slice(file.lastIndexOf('.') + 1) || 'ejs';
211
211
  options._locals = options._locals || {};
212
212
  options.cache = options.cache || process.env.NODE_ENV === 'production';
package/dist/request.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
2
5
  import { IncomingMessage } from 'http';
3
6
  import { ParsedUrlQuery } from 'querystring';
4
7
  import { Options, Ranges } from 'header-range-parser';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinyhttp/app",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
4
4
  "description": "0-legacy, tiny & fast web framework as a replacement of Express",
5
5
  "type": "module",
6
6
  "homepage": "https://tinyhttp.v1rtl.site",
@@ -35,7 +35,7 @@
35
35
  "@tinyhttp/cookie": "2.0.4",
36
36
  "@tinyhttp/proxy-addr": "2.0.4",
37
37
  "@tinyhttp/req": "2.0.13",
38
- "@tinyhttp/res": "2.0.16",
38
+ "@tinyhttp/res": "2.0.17",
39
39
  "@tinyhttp/router": "2.0.5",
40
40
  "header-range-parser": "1.1.3",
41
41
  "regexparam": "^2.0.0"