Comparing version 1.1.0 to 1.2.0
@@ -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 }; |
{ | ||
"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
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
125676
7
3781
184
6
+ Addediron-webcrypto@^0.2.7
+ Addeduncrypto@^0.1.2
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addediron-webcrypto@0.2.8(transitive)
+ Addeduncrypto@0.1.3(transitive)