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

h3

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h3 - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

./dist/index.cjs

31

dist/index.d.ts

@@ -0,9 +1,36 @@

import { SealOptions } from 'iron-webcrypto';
import { CookieSerializeOptions } from 'cookie-es';
import { IncomingMessage, ServerResponse, OutgoingMessage } from 'node:http';
export { IncomingMessage as NodeIncomingMessage, ServerResponse as NodeServerResponse } from 'node:http';
import { CookieSerializeOptions } from 'cookie-es';
import * as ufo from 'ufo';
type SessionDataT = Record<string, string | number | boolean>;
type SessionData<T extends SessionDataT = SessionDataT> = T;
interface Session<T extends SessionDataT = SessionDataT> {
id: string;
data: SessionData<T>;
}
interface SessionConfig {
password: string;
name?: string;
cookie?: CookieSerializeOptions;
seal?: SealOptions;
crypto?: Crypto;
}
declare function useSession<T extends SessionDataT = SessionDataT>(event: H3Event, config: SessionConfig): Promise<{
readonly id: string | undefined;
readonly data: SessionDataT;
update: (update: SessionUpdate<T>) => Promise<any>;
clear: () => Promise<any>;
}>;
declare function getSession<T extends SessionDataT = SessionDataT>(event: H3Event, config: SessionConfig): Promise<Session<T>>;
type SessionUpdate<T extends SessionDataT = SessionDataT> = Partial<SessionData<T>> | ((oldData: SessionData<T>) => Partial<SessionData<T>> | undefined);
declare function updateSession<T extends SessionDataT = SessionDataT>(event: H3Event, config: SessionConfig, update?: SessionUpdate<T>): Promise<Session<T>>;
declare function clearSession(event: H3Event, config: SessionConfig): Promise<void>;
type HTTPMethod = "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE";
type Encoding = false | "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
interface H3EventContext extends Record<string, any> {
params?: Record<string, string>;
sessions?: Record<string, Session>;
}

@@ -325,2 +352,2 @@ type EventHandlerResponse<T = any> = T | Promise<T>;

export { AddRouteShortcuts, App, AppOptions, AppUse, CacheConditions, CreateRouterOptions, DynamicEventHandler, Encoding, EventHandler, EventHandlerResponse, H3Error, H3Event, H3EventContext, H3Headers, H3Response, HTTPMethod, InputLayer, InputStack, Layer, LazyEventHandler, MIMES, Matcher, NodeEventContext, NodeListener, NodeMiddleware, NodePromisifiedHandler, ProxyOptions, RequestHeaders, Router, RouterMethod, RouterUse, Stack, appendHeader, appendHeaders, appendResponseHeader, appendResponseHeaders, assertMethod, callNodeListener, createApp, createAppEventHandler, createError, createEvent, createRouter, defaultContentType, defineEventHandler, defineLazyEventHandler, defineNodeListener, defineNodeMiddleware, deleteCookie, dynamicEventHandler, eventHandler, fromNodeMiddleware, getCookie, getHeader, getHeaders, getMethod, getQuery, getRequestHeader, getRequestHeaders, getResponseHeader, getResponseHeaders, getResponseStatus, getResponseStatusText, getRouterParam, getRouterParams, handleCacheHeaders, isError, isEvent, isEventHandler, isMethod, isStream, lazyEventHandler, parseCookies, promisifyNodeListener, proxyRequest, readBody, readMultipartFormData, readRawBody, send, sendError, sendNoContent, sendProxy, sendRedirect, sendStream, setCookie, setHeader, setHeaders, setResponseHeader, setResponseHeaders, setResponseStatus, toEventHandler, toNodeListener, use, useBase, writeEarlyHints };
export { AddRouteShortcuts, App, AppOptions, AppUse, CacheConditions, CreateRouterOptions, DynamicEventHandler, Encoding, EventHandler, EventHandlerResponse, H3Error, H3Event, H3EventContext, H3Headers, H3Response, HTTPMethod, InputLayer, InputStack, Layer, LazyEventHandler, MIMES, Matcher, NodeEventContext, NodeListener, NodeMiddleware, NodePromisifiedHandler, ProxyOptions, RequestHeaders, Router, RouterMethod, RouterUse, Session, SessionConfig, SessionData, Stack, appendHeader, appendHeaders, appendResponseHeader, appendResponseHeaders, assertMethod, callNodeListener, clearSession, createApp, createAppEventHandler, createError, createEvent, createRouter, defaultContentType, defineEventHandler, defineLazyEventHandler, defineNodeListener, defineNodeMiddleware, deleteCookie, dynamicEventHandler, eventHandler, fromNodeMiddleware, getCookie, getHeader, getHeaders, getMethod, getQuery, getRequestHeader, getRequestHeaders, getResponseHeader, getResponseHeaders, getResponseStatus, getResponseStatusText, getRouterParam, getRouterParams, getSession, handleCacheHeaders, isError, isEvent, isEventHandler, isMethod, isStream, lazyEventHandler, parseCookies, promisifyNodeListener, proxyRequest, readBody, readMultipartFormData, readRawBody, send, sendError, sendNoContent, sendProxy, sendRedirect, sendStream, setCookie, setHeader, setHeaders, setResponseHeader, setResponseHeaders, setResponseStatus, toEventHandler, toNodeListener, updateSession, use, useBase, useSession, writeEarlyHints };

16

package.json
{
"name": "h3",
"version": "1.1.0",
"version": "1.2.0",
"description": "Tiny JavaScript Server",

@@ -25,4 +25,6 @@ "repository": "unjs/h3",

"destr": "^1.2.2",
"iron-webcrypto": "^0.2.7",
"radix3": "^1.0.0",
"ufo": "^1.0.1"
"ufo": "^1.0.1",
"uncrypto": "^0.1.2"
},

@@ -34,7 +36,7 @@ "devDependencies": {

"@types/supertest": "^2.0.12",
"@vitest/coverage-c8": "^0.28.2",
"@vitest/coverage-c8": "^0.28.3",
"autocannon": "^7.10.0",
"changelogen": "^0.4.1",
"connect": "^3.7.0",
"eslint": "^8.32.0",
"eslint": "^8.33.0",
"eslint-config-unjs": "^0.1.0",

@@ -48,7 +50,7 @@ "express": "^4.18.2",

"supertest": "^6.3.3",
"typescript": "^4.9.4",
"typescript": "^4.9.5",
"unbuild": "^1.1.1",
"vitest": "^0.28.2"
"vitest": "^0.28.3"
},
"packageManager": "pnpm@7.26.0",
"packageManager": "pnpm@7.26.3",
"scripts": {

@@ -55,0 +57,0 @@ "build": "unbuild",

@@ -93,3 +93,3 @@ [![npm downloads](https://img.shields.io/npm/dm/h3.svg?style=flat-square)](https://npmjs.com/package/h3)

**Tip:** We can register same route more than once with different methods.
**Tip:** We can register the same route more than once with different methods.

@@ -123,3 +123,3 @@ Routes are internally stored in a [Radix Tree](https://en.wikipedia.org/wiki/Radix_tree) and matched using [unjs/radix3](https://github.com/unjs/radix3).

H3 has concept of compasable utilities that accept `event` (from `eventHandler((event) => {})`) as their first argument. This has several performance benefits over injecting them to `event` or `app` instances and global middleware commonly used in Node.js frameworks such as Express, which Only required code is evaluated and bundled and rest of utils can be tree-shaken when not used.
H3 has a concept of composable utilities that accept `event` (from `eventHandler((event) => {})`) as their first argument. This has several performance benefits over injecting them to `event` or `app` instances in global middleware commonly used in Node.js frameworks, such as Express. This concept means only required code is evaluated and bundled, and the rest of the utilities can be tree-shaken when not used.

@@ -158,2 +158,6 @@ ### Built-in

- `readMultipartFormData(event)`
- `useSession(event, { password, name?, cookie?, seal?, crypto? })`
- `getSession(event, { password, name?, cookie?, seal?, crypto? })`
- `updateSession(event, { password, name?, cookie?, seal?, crypto? }), update)`
- `clearSession(event, { password, name?, cookie?, seal?, crypto? }))`

@@ -164,3 +168,3 @@ 👉 You can learn more about usage in [JSDocs Documentation](https://www.jsdocs.io/package/h3#package-functions).

You can use more h3 event utilities made by the community.
You can use more H3 event utilities made by the community.

@@ -167,0 +171,0 @@ Please check their READMEs for more details.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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