Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tinyhttp/app

Package Overview
Dependencies
Maintainers
1
Versions
305
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/app - npm Package Compare versions

Comparing version 2.0.29 to 2.0.31

8

dist/app.d.ts

@@ -10,3 +10,3 @@ /// <reference types="node" />

*/
export declare type AppSettings = Partial<{
export type AppSettings = Partial<{
networkExtensions: boolean;

@@ -22,4 +22,4 @@ subdomainOffset: number;

*/
export declare type TemplateFunc<O> = (path: string, locals: Record<string, any>, opts: TemplateEngineOptions<O>, cb: (err: Error, html: unknown) => void) => void;
export declare type TemplateEngineOptions<O> = Partial<{
export type TemplateFunc<O> = (path: string, locals: Record<string, any>, opts: TemplateEngineOptions<O>, cb: (err: Error | null, html: unknown) => void) => void;
export type TemplateEngineOptions<O> = Partial<{
cache: boolean;

@@ -55,3 +55,3 @@ ext: string;

middleware: Middleware<Req, Res>[];
locals: Record<string, string>;
locals: Record<string, unknown>;
noMatchHandler: Handler;

@@ -58,0 +58,0 @@ onError: ErrorHandler;

@@ -11,5 +11,5 @@ export { App } from './app.js';

import type { NextFunction, Handler as RHandler, AsyncHandler as RAsyncHandler, SyncHandler as RSyncHandler, Middleware } from '@tinyhttp/router';
export declare type Handler = RHandler<Request, Response>;
export declare type AsyncHandler = RAsyncHandler<Request, Response>;
export declare type SyncHandler = RSyncHandler<Request, Response>;
export type Handler = RHandler<Request, Response>;
export type AsyncHandler = RAsyncHandler<Request, Response>;
export type SyncHandler = RSyncHandler<Request, Response>;
export type { NextFunction, Middleware, Request, Response };

@@ -135,18 +135,18 @@ import { STATUS_CODES, createServer } from "http";

class App extends Router {
middleware = [];
locals = {};
noMatchHandler;
onError;
settings;
engines = {};
applyExtensions;
attach;
constructor(options = {}) {
super();
this.middleware = [];
this.locals = {};
this.engines = {};
this.onError = (options == null ? void 0 : options.onError) || onErrorHandler;
this.noMatchHandler = (options == null ? void 0 : options.noMatchHandler) || this.onError.bind(this, { code: 404 });
this.settings = options.settings || { xPoweredBy: true, views: process.cwd() };
this.settings = options.settings || { xPoweredBy: true, views: `${process.cwd()}/views` };
this.applyExtensions = options == null ? void 0 : options.applyExtensions;
this.attach = (req, res) => setImmediate(this.handler.bind(this, req, res, void 0), req, res);
}
/**
* Set app setting
* @param setting setting name
* @param value setting value
*/
set(setting, value) {

@@ -156,2 +156,6 @@ this.settings[setting] = value;

}
/**
* Enable app setting
* @param setting Setting name
*/
enable(setting) {

@@ -161,2 +165,6 @@ this.settings[setting] = true;

}
/**
* Disable app setting
* @param setting
*/
disable(setting) {

@@ -166,2 +174,9 @@ this.settings[setting] = false;

}
/**
* Render a template
* @param file What to render
* @param data data that is passed to a template
* @param options Template engine options
* @param cb Callback that consumes error and html
*/
render(file, data = {}, cb, options = {}) {

@@ -224,2 +239,5 @@ options.viewsFolder = options.viewsFolder || this.settings.views || `${process.cwd()}/views`;

}
/**
* Register a template engine with extension
*/
engine(ext, fn) {

@@ -242,2 +260,7 @@ this.engines[ext] = fn;

}
/**
* Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware
* @param req Req object
* @param res Res object
*/
handler(req, res, next) {

@@ -300,2 +323,8 @@ const { xPoweredBy } = this.settings;

}
/**
* Creates HTTP server and dispatches middleware
* @param port server listening port
* @param Server callback after server starts listening
* @param host server listening host
*/
listen(port, cb, host = "0.0.0.0") {

@@ -302,0 +331,0 @@ return createServer().on("request", this.attach).listen(port, host, cb);

@@ -5,3 +5,3 @@ import type { NextFunction } from '@tinyhttp/router';

import type { App } from './app.js';
export declare type ErrorHandler = (this: App, err: any, req: Request, res: Response, next?: NextFunction) => void;
export type ErrorHandler = (this: App, err: any, req: Request, res: Response, next?: NextFunction) => void;
export declare const onErrorHandler: ErrorHandler;

@@ -21,8 +21,8 @@ /// <reference types="node" />

export declare const getSubdomains: (req: Request, subdomainOffset?: number) => string[];
export declare type Connection = IncomingMessage['socket'] & {
export type Connection = IncomingMessage['socket'] & {
encrypted: boolean;
};
export declare type Protocol = 'http' | 'https' | string;
export type Protocol = 'http' | 'https' | string;
export type { URLParams };
declare type AcceptsReturns = string | boolean | string[];
type AcceptsReturns = string | boolean | string[];
export interface Request extends IncomingMessage {

@@ -29,0 +29,0 @@ originalUrl: string;

{
"name": "@tinyhttp/app",
"version": "2.0.29",
"version": "2.0.31",
"description": "0-legacy, tiny & fast web framework as a replacement of Express",

@@ -35,9 +35,9 @@ "type": "module",

"dependencies": {
"header-range-parser": "1.1.3",
"regexparam": "^2.0.1",
"@tinyhttp/cookie": "2.0.6",
"@tinyhttp/proxy-addr": "2.0.6",
"@tinyhttp/proxy-addr": "2.0.7",
"@tinyhttp/req": "2.0.16",
"@tinyhttp/res": "2.0.22",
"@tinyhttp/router": "2.0.7",
"header-range-parser": "1.1.3",
"regexparam": "^2.0.1"
"@tinyhttp/res": "2.0.23",
"@tinyhttp/router": "2.0.7"
},

@@ -44,0 +44,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc