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

elysia

Package Overview
Dependencies
Maintainers
1
Versions
442
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elysia - npm Package Compare versions

Comparing version 0.3.0-exp-230222.2210 to 0.3.0-exp-230226.2331

dist/custom-types.d.ts

7

dist/context.d.ts
/// <reference types="bun-types" />
import { Elysia } from '.';
import type { TypedRoute } from './types';
import type { Elysia, TypedRoute, DEFS, SCHEMA, TypedSchema } from '.';
export interface Context<Route extends TypedRoute = TypedRoute, Store extends Elysia['store'] = Elysia['store']> {

@@ -10,2 +9,6 @@ request: Request;

store: Store;
[SCHEMA]: TypedSchema;
[DEFS]: {
[index: string]: Record<string, unknown>;
};
set: {

@@ -12,0 +15,0 @@ headers: Record<string, string>;

@@ -1,1 +0,1 @@

export const isNotEmpty=e=>{for(let s in e)return!0;return!1};let e=(e,s)=>{if(Array.isArray(s)){e.delete("Set-Cookie");for(let r=0;r<s.length;r++){let t=s[r].indexOf("=");e.append("Set-Cookie",`${s[r].slice(0,t)}=${s[r].slice(t+1)}`)}}return e};export const mapEarlyResponse=(s,r)=>{if(r.headers?.["Set-Cookie"]&&(r.headers=e(new Headers(r.headers),r.headers["Set-Cookie"])),r.redirect)return Response.redirect(r.redirect,{headers:r.headers});if(isNotEmpty(r.headers)||200!==r.status)switch(typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":if(s instanceof Error)return errorToResponse(s,r.headers);if(s instanceof Response){for(let e in r.headers)s.headers.append(e,r.headers[e]);return s}if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers});case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers})}else switch(typeof s){case"string":return new Response(s);case"object":if(s instanceof Response)return s;if(s instanceof Error)return errorToResponse(s,r.headers);if(s instanceof Blob)return new Response(s);return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case"function":if(s instanceof Blob)return new Response(s);return s;case"number":case"boolean":return new Response(s.toString())}};export const mapResponse=(s,r)=>{if(r.headers?.["Set-Cookie"]){if(r.headers=e(new Headers(r.headers),r.headers["Set-Cookie"]),r.redirect)return Response.redirect(r.redirect,{headers:r.headers});switch(typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":switch(s.constructor){case Error:return errorToResponse(s,r.headers);case Response:for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case Blob:return new Response(s,{status:r.status,headers:r.headers});default:return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers})}case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});return s();case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers});case"undefined":return new Response("",{status:r.status,headers:r.headers});default:return new Response(s,{status:r.status,headers:r.headers})}}if(r.redirect)return Response.redirect(r.redirect,{headers:r.headers});if(Object.keys(r.headers).length||200!==r.status)switch(typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":switch(s?.constructor){case Error:return errorToResponse(s,r.headers);case Response:for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case Blob:return new Response(s,{status:r.status,headers:r.headers});default:return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers})}case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});return s();case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers});case"undefined":return new Response("",{status:r.status,headers:r.headers});default:return new Response(s,{status:r.status,headers:r.headers})}else switch(typeof s){case"string":default:return new Response(s);case"object":if(s instanceof Response)return s;if(s instanceof Error)return errorToResponse(s,r.headers);if(s instanceof Blob)return new Response(s);return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case"function":if(s instanceof Blob)return new Response(s);return s();case"number":case"boolean":return new Response(s.toString());case"undefined":return new Response("")}};export const errorToResponse=(e,s)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:500,headers:s});
export const isNotEmpty=e=>{for(let s in e)return!0;return!1};let e=(e,s)=>{if(Array.isArray(s)){e.delete("Set-Cookie");for(let r=0;r<s.length;r++){let t=s[r].indexOf("=");e.append("Set-Cookie",`${s[r].slice(0,t)}=${s[r].slice(t+1)}`)}}return e};export const mapEarlyResponse=(s,r)=>{if(r.redirect&&(r.headers.Location=r.redirect,r.status=302),r.headers["Set-Cookie"]&&(r.headers=e(new Headers(r.headers),r.headers["Set-Cookie"])),isNotEmpty(r.headers)||200!==r.status)switch(typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":if(s instanceof Error)return errorToResponse(s,r.headers);if(s instanceof Response){for(let e in r.headers)s.headers.append(e,r.headers[e]);return s}if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers});case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers})}else switch(typeof s){case"string":return new Response(s);case"object":if(s instanceof Response)return s;if(s instanceof Error)return errorToResponse(s,r.headers);if(s instanceof Blob)return new Response(s);return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case"function":if(s instanceof Blob)return new Response(s);return s;case"number":case"boolean":return new Response(s.toString())}};export const mapResponse=(s,r)=>{if(r.redirect&&(r.headers.Location=r.redirect,r.status=302),r.headers?.["Set-Cookie"])switch(r.headers=e(new Headers(r.headers),r.headers["Set-Cookie"]),typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":switch(s.constructor){case Error:return errorToResponse(s,r.headers);case Response:for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case Blob:return new Response(s,{status:r.status,headers:r.headers});default:return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers})}case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});return s();case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers});case"undefined":return new Response("",{status:r.status,headers:r.headers});default:return new Response(s,{status:r.status,headers:r.headers})}if(r.redirect)return Response.redirect(r.redirect,{headers:r.headers});if(Object.keys(r.headers).length||200!==r.status)switch(typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":switch(s?.constructor){case Error:return errorToResponse(s,r.headers);case Response:for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case Blob:return new Response(s,{status:r.status,headers:r.headers});default:return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers})}case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});return s();case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers});case"undefined":return new Response("",{status:r.status,headers:r.headers});default:return new Response(s,{status:r.status,headers:r.headers})}else switch(typeof s){case"string":default:return new Response(s);case"object":if(s instanceof Response)return s;if(s instanceof Error)return errorToResponse(s,r.headers);if(s instanceof Blob)return new Response(s);return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case"function":if(s instanceof Blob)return new Response(s);return s();case"number":case"boolean":return new Response(s.toString());case"undefined":return new Response("")}};export const errorToResponse=(e,s)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:500,headers:s});
/// <reference types="bun-types" />
import type { Serve, Server } from 'bun';
import { SCHEMA, EXPOSED, DEFS, exposePermission } from './utils';
import { permission, type Permission } from './fn';
import { SCHEMA, EXPOSED, DEFS } from './utils';
import type { Context } from './context';
import type { Handler, BeforeRequestHandler, TypedRoute, ElysiaInstance, ElysiaConfig, HTTPMethod, InternalRoute, BodyParser, ErrorHandler, TypedSchema, LocalHook, LocalHandler, LifeCycle, LifeCycleEvent, LifeCycleStore, VoidLifeCycle, AfterRequestHandler, MergeIfNotNull, IsAny, OverwritableTypeRoute, MergeSchema, ListenCallback, NoReturnHandler, ElysiaRoute, MaybePromise, IsNever } from './types';
import type { Handler, BeforeRequestHandler, TypedRoute, ElysiaInstance, ElysiaConfig, HTTPMethod, InternalRoute, BodyParser, ErrorHandler, TypedSchema, LocalHook, LocalHandler, LifeCycle, LifeCycleEvent, LifeCycleStore, VoidLifeCycle, AfterRequestHandler, IsAny, OverwritableTypeRoute, MergeSchema, ListenCallback, NoReturnHandler, ElysiaRoute, MaybePromise, IsNever } from './types';
import { type TSchema } from '@sinclair/typebox';

@@ -10,2 +11,3 @@ export default class Elysia<Instance extends ElysiaInstance = ElysiaInstance> {

store: Instance['store'];
meta: Instance['meta'];
protected decorators: ElysiaInstance['request'];

@@ -33,15 +35,18 @@ event: LifeCycleStore<Instance>;

schema: Instance['schema'];
meta: Omit<Instance['meta'], typeof SCHEMA> & ElysiaInstance['meta'];
}>) => NewElysia): NewElysia extends Elysia<infer NewInstance> ? Elysia<{
request: Instance['request'] & NewInstance['request'];
schema: Instance['schema'] & NewInstance['schema'];
store: Instance['store'] & (Omit<NewInstance['store'], typeof SCHEMA> & {
store: Instance['store'] & NewInstance['store'];
meta: Instance['meta'] & (Omit<NewInstance['meta'], typeof SCHEMA> & {
[key in typeof SCHEMA]: {
[key in keyof NewInstance['store'][typeof SCHEMA] as key extends `${infer Rest}` ? `${Prefix}${Rest}` : key]: NewInstance['store'][typeof SCHEMA][key];
[key in keyof NewInstance['meta'][typeof SCHEMA] as key extends `${infer Rest}` ? `${Prefix}${Rest}` : key]: NewInstance['meta'][typeof SCHEMA][key];
};
});
}> : this;
guard<Schema extends TypedSchema = {}, NewElysia extends Elysia<any> = Elysia<any>>(hook: LocalHook<Schema, Instance>, run: (group: Elysia<{
guard<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, NewElysia extends Elysia<any> = Elysia<any>>(hook: LocalHook<Schema, Instance>, run: (group: Elysia<{
request: Instance['request'];
store: Instance['store'];
schema: Omit<MergeIfNotNull<Schema, Instance['schema']>, typeof SCHEMA>;
schema: Schema & Instance['schema'];
meta: Instance['meta'];
}>) => NewElysia): NewElysia extends Elysia<infer NewInstance> ? Elysia<NewInstance & Instance> : this;

@@ -51,13 +56,13 @@ use<NewElysia extends MaybePromise<Elysia<any>> = Elysia<any>, Params extends Elysia = Elysia<any>, LazyLoadElysia extends never | ElysiaInstance = never>(plugin: MaybePromise<(app: Params extends Elysia<infer ParamsInstance> ? IsAny<ParamsInstance> extends true ? this : Params : Params) => MaybePromise<NewElysia>> | Promise<{

}>): IsNever<LazyLoadElysia> extends false ? Elysia<LazyLoadElysia & Instance> : NewElysia extends Elysia<infer NewInstance> ? IsNever<NewInstance> extends true ? Elysia<Instance> : Elysia<NewInstance & Instance> : NewElysia extends Promise<Elysia<infer NewInstance>> ? Elysia<NewInstance & Instance> : this;
get<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'GET', Schema, Instance, Path, Response>;
post<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'POST', Schema, Instance, Path, Response>;
put<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'PUT', Schema, Instance, Path, Response>;
patch<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'PATCH', Schema, Instance, Path, Response>;
delete<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'DELETE', Schema, Instance, Path, Response>;
options<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'OPTIONS', Schema, Instance, Path, Response>;
all<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'ALL', Schema, Instance, Path, Response>;
head<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'HEAD', Schema, Instance, Path, Response>;
trace<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'TRACE', Schema, Instance, Path, Response>;
connect<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'CONNECT', Schema, Instance, Path, Response>;
route<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, Method extends HTTPMethod = HTTPMethod, Path extends string = string, Response = unknown>(method: Method, path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<Method, Schema, Instance, Path, Response>;
get<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'GET', Schema, Instance, Path, Response>;
post<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'POST', Schema, Instance, Path, Response>;
put<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'PUT', Schema, Instance, Path, Response>;
patch<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'PATCH', Schema, Instance, Path, Response>;
delete<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'DELETE', Schema, Instance, Path, Response>;
options<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'OPTIONS', Schema, Instance, Path, Response>;
all<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'ALL', Schema, Instance, Path, Response>;
head<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'HEAD', Schema, Instance, Path, Response>;
trace<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'TRACE', Schema, Instance, Path, Response>;
connect<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Path extends string = string, Response = unknown>(path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<'CONNECT', Schema, Instance, Path, Response>;
route<Schema extends TypedSchema<Exclude<keyof Instance['meta'][typeof DEFS], number | symbol>> = {}, Method extends HTTPMethod = HTTPMethod, Path extends string = string, Response = unknown>(method: Method, path: Path, handler: LocalHandler<Schema, Instance, Path, Response>, hook?: LocalHook<Schema, Instance, Path>): ElysiaRoute<Method, Schema, Instance, Path, Response>;
state<Key extends string | number | symbol = keyof Instance['store'], Value = Instance['store'][keyof Instance['store']], NewInstance = Elysia<{

@@ -69,2 +74,3 @@ store: Instance['store'] & {

schema: Instance['schema'];
meta: Instance['meta'];
}>>(name: Key, value: Value): NewInstance;

@@ -77,2 +83,3 @@ decorate<Name extends string, Value = any, NewInstance = Elysia<{

schema: Instance['schema'];
meta: Instance['meta'];
}>>(name: Name, value: Value): NewInstance;

@@ -85,15 +92,15 @@ inject<Returned extends Object = Object>(transform: (context: Context<{}, Instance['store']> & Instance['request']) => Returned extends {

schema: Instance['schema'];
meta: Instance['meta'];
}>;
fn<T extends Record<string, unknown> | ((app: Instance['request'] & {
store: Instance['store'];
permission: typeof exposePermission;
permission: Permission;
}) => Record<string, unknown>) = Record<string, unknown> | ((app: Instance['request'] & {
store: Instance['store'];
permission: typeof exposePermission;
permission: Permission;
}) => Record<string, unknown>)>(value: T): Elysia<{
store: Instance['store'] & {
[EXPOSED]: T extends (store: any) => infer Returned ? Returned : T;
};
store: Instance['store'];
request: Instance['request'];
schema: Instance['schema'];
meta: Instance['meta'] & Record<typeof EXPOSED, T extends (store: any) => infer Returned ? Returned : T>;
}>;

@@ -104,2 +111,3 @@ schema<Schema extends TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>> = TypedSchema<Exclude<keyof Instance['store'][typeof DEFS], number | symbol>>, NewInstance = Elysia<{

schema: MergeSchema<Schema, Instance['schema']>;
meta: Instance['meta'];
}>>(schema: Schema): NewInstance;

@@ -112,13 +120,12 @@ handle: (request: Request) => Promise<Response>;

setModel<Recorder extends Record<string, TSchema>>(record: Recorder): Elysia<{
store: Instance['store'] & {
[Defs in typeof DEFS]: Recorder;
};
store: Instance['store'];
request: Instance['request'];
schema: Instance['schema'];
meta: Instance['meta'] & Record<typeof DEFS, Recorder>;
}>;
}
export { Elysia };
export { Type as t } from '@sinclair/typebox';
export { Elysia, permission };
export { t } from './custom-types';
export { SCHEMA, DEFS, EXPOSED, createValidationError, getSchemaValidator, mergeDeep, mergeHook, mergeObjectArray, mapPathnameAndQueryRegEx, mapQuery } from './utils';
export type { Context, PreContext } from './context';
export type { Handler, RegisteredHook, BeforeRequestHandler, TypedRoute, OverwritableTypeRoute, ElysiaInstance, ElysiaConfig, HTTPMethod, ComposedHandler, InternalRoute, BodyParser, ErrorHandler, ErrorCode, TypedSchema, LocalHook, LocalHandler, LifeCycle, LifeCycleEvent, AfterRequestHandler, HookHandler, TypedSchemaToRoute, UnwrapSchema, LifeCycleStore, VoidLifeCycle, SchemaValidator, ElysiaRoute, ExtractPath, IsPathParameter, IsAny, IsNever, UnknownFallback, WithArray, ObjectValues, PickInOrder, MaybePromise, MergeIfNotNull } from './types';

@@ -1,1 +0,1 @@

import{Raikiri as e}from"raikiri";import{mapResponse as t,mapEarlyResponse as r}from"./handler";import{SCHEMA as s,EXPOSED as a,DEFS as n,mapQuery as i,clone as o,mergeHook as h,mergeDeep as l,createValidationError as u,getSchemaValidator as d,getResponseSchemaValidator as f,mapPathnameAndQueryRegEx as p,exposePermission as c}from"./utils";import{registerSchemaPath as m}from"./schema";import{mapErrorCode as v,mapErrorStatus as g}from"./error";import{serialize as y,deserialize as b}from"superjson";export default class H{store={[s]:{},[n]:{},[a]:{}};decorators={query:{},set:{status:200,headers:{}},store:this.store};event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],error:[],stop:[]};server=null;$schema=null;router=new e;routes=[];lazyLoadModules=[];constructor(e){this.config={fn:"/~fn",...e}}_addHandler(e,t,r,a){t=t.startsWith("/")?t:`/${t}`,this.routes.push({method:e,path:t,handler:r,hooks:h(o(this.event),a)});let i=this.store[n],l=d(a?.schema?.body??this.$schema?.body,i),u=d(a?.schema?.headers??this.$schema?.headers,i,!0),p=d(a?.schema?.params??this.$schema?.params,i),c=d(a?.schema?.query??this.$schema?.query,i),v=f(a?.schema?.response??this.$schema?.response,i);m({schema:this.store[s],hook:a,method:e,path:t,models:this.store[n]});let g=h(o(this.event),a);g.schema||g.transform.length||g.beforeHandle.length||g.error.length||g.afterHandle.length||(g=void 0);let y={handle:r,hooks:g,validator:l||u||p||c||v?{body:l,header:u,params:p,query:c,response:v}:void 0};this.router.add(e,t,y)}onStart(e){return this.event.start.push(e),this}onRequest(e){return this.event.request.push(e),this}onParse(e){return this.event.parse.splice(this.event.parse.length-1,0,e),this}onTransform(e){return this.event.transform.push(e),this}onBeforeHandle(e){return this.event.beforeHandle.push(e),this}onAfterHandle(e){return this.event.afterHandle.push(e),this}onError(e){return this.event.error.push(e),this}onStop(e){return this.event.stop.push(e),this}on(e,t){switch(e){case"start":this.event.start.push(t);break;case"request":this.event.request.push(t);break;case"parse":this.event.parse.push(t);break;case"transform":this.event.transform.push(t);break;case"beforeHandle":this.event.beforeHandle.push(t);break;case"afterHandle":this.event.afterHandle.push(t);break;case"error":this.event.error.push(t);break;case"stop":this.event.stop.push(t)}return this}group(e,t){let r=new H;r.store=this.store;let s=t(r);return s.event.request.length&&(this.event.request=[...this.event.request,...s.event.request]),Object.values(r.routes).forEach(({method:t,path:r,handler:a,hooks:n})=>{"/"===r?this._addHandler(t,e,a,h(n,{error:s.event.error})):this._addHandler(t,`${e}${r}`,a,h(n,{error:s.event.error}))}),this}guard(e,t){let r=new H;r.store=this.store;let s=t(r);return s.event.request.length&&(this.event.request=[...this.event.request,...s.event.request]),Object.values(r.routes).forEach(({method:t,path:r,handler:s,hooks:a})=>{this._addHandler(t,r,s,h(e,a))}),this}use(e){if(e instanceof Promise)return this.lazyLoadModules.push(e.then(e=>"function"==typeof e?e(this):e.default(this))),this;let t=e(this);return t instanceof Promise?(this.lazyLoadModules.push(t),this):t}get(e,t,r){return this._addHandler("GET",e,t,r),this}post(e,t,r){return this._addHandler("POST",e,t,r),this}put(e,t,r){return this._addHandler("PUT",e,t,r),this}patch(e,t,r){return this._addHandler("PATCH",e,t,r),this}delete(e,t,r){return this._addHandler("DELETE",e,t,r),this}options(e,t,r){return this._addHandler("OPTIONS",e,t,r),this}all(e,t,r){return this._addHandler("ALL",e,t,r),this}head(e,t,r){return this._addHandler("HEAD",e,t,r),this}trace(e,t,r){return this._addHandler("TRACE",e,t,r),this}connect(e,t,r){return this._addHandler("CONNECT",e,t,r),this}route(e,t,r,s){return this._addHandler(e,t,r,s),this}state(e,t){return e in this.store||(this.store[e]=t),this}decorate(e,t){return e in this.decorators||(this.decorators[e]=t),this}inject(e){return this.onTransform(t=>{Object.assign(t,e(t))})}fn(e){return 0===Object.keys(this.store[a]).length&&this.post(this.config.fn??"/~fn",e=>{let t=this.store[a],r=[],s=e.body;e:for(let n=0;n<s.length;n++){let i=s[n],o=t;if(!Array.isArray(i.n)){r.push(Error("Invalid procedure"));continue e}for(let t=0;t<i.n.length;t++){if(!(o=o[i.n[t]])){r.push(Error("Invalid procedure"));continue e}if(a in o){if(!1==o.allow){r.push(Error("Forbidden"));continue e}if(!0!==o.allow){try{let s=o.allow({...e,key:i.n.slice(t+1).join("."),params:i.p??null});if(s instanceof Error){r.push(s);continue e}}catch(e){r.push(e);continue e}o=o.value}}}"function"==typeof o?void 0!==i.p?Array.isArray(i.p)&&1===i.p.length?r.push(o(i.p[0])):r.push(o(...i.p)):r.push(o()):r.push(Error("Invalid procedure"))}return Promise.all(r).then(y)}),this.store[a]=l(this.store[a],"function"==typeof e?e({...this.decorators,store:this.store,permission:c}):e),this}schema(e){let t=this.store[n];return this.$schema={body:d(e.body,t),headers:d(e?.headers,t,!0),params:d(e?.params,t),query:d(e?.query,t),response:d(e?.response,t)},this}handle=async e=>{let s;let a=o(this.decorators);a.request=e;try{let n;if(this.event.request.length)for(let e=0;e<this.event.request.length;e++){let t=this.event.request[e](a);if(t instanceof Promise&&(t=await t),t=r(t,a.set))return t}let o=e.url.match(p);if(!o)throw Error("NOT_FOUND");let h=this.router.match(e.method,o[1])??this.router.match("ALL",o[1]);if(!h)throw Error("NOT_FOUND");let l=h.store;if("GET"!==e.method){let t=e.headers.get("content-type");if(t){let r=t.indexOf(";");if(-1!==r&&(t=t.slice(0,r)),this.event.parse.length)for(let e=0;e<this.event.parse.length;e++){let r=this.event.parse[e](a,t);if(r instanceof Promise&&(r=await r),void 0!==r){n=r;break}}if(void 0===n)switch(t){case"application/json":n=await e.json();break;case"text/plain":n=await e.text();break;case"application/x-www-form-urlencoded":n=i(await e.text());break;case"elysia/fn":n=b(await e.json())}}}a.body=n,a.params=h.params,o[2]&&(a.query=i(o[2]));let d=l.hooks;if(d?.error&&(s=d?.error),d?.transform.length)for(let e=0;e<d.transform.length;e++){let t=d.transform[e](a);t instanceof Promise&&await t}if(l.validator){let t=l.validator;if(d?.error&&(s=d?.error),t.headers){let r={};for(let t in e.headers)r[t]=e.headers.get(t);if(!1===t.headers.Check(r))throw u("header",t.headers,r)}if(!1===t.params?.Check(a.params))throw u("params",t.params,a.params);if(!1===t.query?.Check(a.query))throw u("query",t.query,a.query);if(!1===t.body?.Check(n))throw u("body",t.body,n)}if(d?.beforeHandle.length)for(let e=0;e<d.beforeHandle.length;e++){let t=d.beforeHandle[e](a);if(t instanceof Promise&&(t=await t),null!=t){for(let e=0;e<d.afterHandle.length;e++){let r=d.afterHandle[e](a,t);r instanceof Promise&&(r=await r),r&&(t=r)}let e=r(t,a.set);if(e)return e}}let f=l.handle(a);if(f instanceof Promise&&(f=await f),!1===l.validator?.response?.Check(f))throw d?.error&&(s=d?.error),u("response",l.validator.response,f);if(d?.afterHandle.length)for(let e=0;e<d.afterHandle.length;e++){let t=d.afterHandle[e](a,f);t instanceof Promise&&(t=await t);let s=r(t,a.set);if(s)return s}return t(f,a.set)}catch(n){let t=a.set;if((!t.status||t.status<300)&&(t.status=500),s){let a=v(n.message);for(let i=0;i<s.length;i++){let o=s[i]({request:e,error:n,set:t,code:a});o instanceof Promise&&(o=await o);let h=r(o,t);if(h)return h}}return this.handleError(e,n,t)}};async handleError(e,r,s={headers:{}}){for(let a=0;a<this.event.error.length;a++){let n=this.event.error[a]({request:e,code:v(r.message),error:r,set:s});if(n instanceof Promise&&(n=await n),null!=n)return t(n,s)}return new Response("string"==typeof r.cause?r.cause:r.message,{headers:s.headers,status:g(v(r.message))})}listen=(e,t)=>{if(!Bun)throw Error("Bun to run");if("string"==typeof e&&Number.isNaN(e=+e))throw Error("Port must be a numeric value");let r=this.handle,s="object"==typeof e?{...this.config.serve,...e,fetch:r}:{...this.config.serve,port:e,fetch:r},a=`$$Elysia:${s.port}`;globalThis[a]?(this.server=globalThis[a],this.server.reload(s)):globalThis[a]=this.server=Bun.serve(s);for(let e=0;e<this.event.start.length;e++)this.event.start[e](this);return t&&t(this.server),Promise.all(this.lazyLoadModules).then(()=>{this.server.pendingRequests||Bun.gc(!0)}),this};stop=async()=>{if(!this.server)throw Error("Elysia isn't running. Call `app.listen` to start the server.");this.server.stop();for(let e=0;e<this.event.stop.length;e++)await this.event.stop[e](this)};get modules(){return Promise.all(this.lazyLoadModules)}setModel(e){return Object.entries(e).forEach(([e,t])=>{e in this.store[n]||(this.store[n][e]=t)}),this}}export{Type as t}from"@sinclair/typebox";export{SCHEMA,DEFS,EXPOSED,createValidationError,getSchemaValidator,mergeDeep,mergeHook,mergeObjectArray,mapPathnameAndQueryRegEx,mapQuery}from"./utils";export{H as Elysia};
import{Raikiri as e}from"raikiri";import{mapResponse as t,mapEarlyResponse as r}from"./handler";import{permission as s}from"./fn";import{SCHEMA as a,EXPOSED as n,DEFS as i,mapQuery as o,clone as h,mergeHook as l,mergeDeep as u,createValidationError as d,getSchemaValidator as f,getResponseSchemaValidator as c,mapPathnameAndQueryRegEx as m}from"./utils";import{registerSchemaPath as p}from"./schema";import{mapErrorCode as v,mapErrorStatus as g}from"./error";import{runFn as y}from"./fn";import{deserialize as b}from"superjson";export default class H{store={};meta={[a]:Object.create(null),[i]:Object.create(null),[n]:Object.create(null)};decorators={query:{},set:{status:200,headers:{}},store:this.store,[a]:this.meta[a],[i]:this.meta[i]};event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],error:[],stop:[]};server=null;$schema=null;router=new e;routes=[];lazyLoadModules=[];constructor(e){this.config={fn:"/~fn",...e}}_addHandler(e,t,r,s){t=t.startsWith("/")?t:`/${t}`,this.routes.push({method:e,path:t,handler:r,hooks:l(h(this.event),s)});let n=this.meta[i],o=f(s?.schema?.body??this.$schema?.body,n),u=f(s?.schema?.headers??this.$schema?.headers,n,!0),d=f(s?.schema?.params??this.$schema?.params,n),m=f(s?.schema?.query??this.$schema?.query,n),v=c(s?.schema?.response??this.$schema?.response,n);p({schema:this.meta[a],contentType:s?.schema?.contentType,hook:s,method:e,path:t,models:this.meta[i]});let g=l(h(this.event),s);g.schema||g.transform.length||g.beforeHandle.length||g.error.length||g.afterHandle.length||(g=void 0);let y={handle:r,hooks:g,validator:o||u||d||m||v?{body:o,header:u,params:d,query:m,response:v}:void 0};this.router.add(e,t,y)}onStart(e){return this.event.start.push(e),this}onRequest(e){return this.event.request.push(e),this}onParse(e){return this.event.parse.splice(this.event.parse.length-1,0,e),this}onTransform(e){return this.event.transform.push(e),this}onBeforeHandle(e){return this.event.beforeHandle.push(e),this}onAfterHandle(e){return this.event.afterHandle.push(e),this}onError(e){return this.event.error.push(e),this}onStop(e){return this.event.stop.push(e),this}on(e,t){switch(e){case"start":this.event.start.push(t);break;case"request":this.event.request.push(t);break;case"parse":this.event.parse.push(t);break;case"transform":this.event.transform.push(t);break;case"beforeHandle":this.event.beforeHandle.push(t);break;case"afterHandle":this.event.afterHandle.push(t);break;case"error":this.event.error.push(t);break;case"stop":this.event.stop.push(t)}return this}group(e,t){let r=new H;r.store=this.store;let s=t(r);return s.event.request.length&&(this.event.request=[...this.event.request,...s.event.request]),Object.values(r.routes).forEach(({method:t,path:r,handler:a,hooks:n})=>{"/"===r?this._addHandler(t,e,a,l(n,{error:s.event.error})):this._addHandler(t,`${e}${r}`,a,l(n,{error:s.event.error}))}),this}guard(e,t){let r=new H;r.store=this.store;let s=t(r);return s.event.request.length&&(this.event.request=[...this.event.request,...s.event.request]),Object.values(r.routes).forEach(({method:t,path:r,handler:s,hooks:a})=>{this._addHandler(t,r,s,l(e,a))}),this}use(e){if(e instanceof Promise)return this.lazyLoadModules.push(e.then(e=>"function"==typeof e?e(this):e.default(this))),this;let t=e(this);return t instanceof Promise?(this.lazyLoadModules.push(t),this):t}get(e,t,r){return this._addHandler("GET",e,t,r),this}post(e,t,r){return this._addHandler("POST",e,t,r),this}put(e,t,r){return this._addHandler("PUT",e,t,r),this}patch(e,t,r){return this._addHandler("PATCH",e,t,r),this}delete(e,t,r){return this._addHandler("DELETE",e,t,r),this}options(e,t,r){return this._addHandler("OPTIONS",e,t,r),this}all(e,t,r){return this._addHandler("ALL",e,t,r),this}head(e,t,r){return this._addHandler("HEAD",e,t,r),this}trace(e,t,r){return this._addHandler("TRACE",e,t,r),this}connect(e,t,r){return this._addHandler("CONNECT",e,t,r),this}route(e,t,r,s){return this._addHandler(e,t,r,s),this}state(e,t){return e in this.store||(this.store[e]=t),this}decorate(e,t){return e in this.decorators||(this.decorators[e]=t),this}inject(e){return this.onTransform(t=>{Object.assign(t,e(t))})}fn(e){return 0===Object.keys(this.meta[n]).length&&this.post(this.config.fn??"/~fn",e=>y(e,this.meta[n])),this.meta[n]=u(this.meta[n],"function"==typeof e?e({...this.decorators,store:this.store,permission:s}):e),this}schema(e){let t=this.meta[i];return this.$schema={body:f(e.body,t),headers:f(e?.headers,t,!0),params:f(e?.params,t),query:f(e?.query,t),response:f(e?.response,t)},this}handle=async e=>{let s;let a=h(this.decorators);a.request=e;try{let n;if(this.event.request.length)for(let e=0;e<this.event.request.length;e++){let t=this.event.request[e](a);if(t instanceof Promise&&(t=await t),t=r(t,a.set))return t}let i=e.url.match(m);if(!i)throw Error("NOT_FOUND");let h=this.router.match(e.method,i[1])??this.router.match("ALL",i[1]);if(!h)throw Error("NOT_FOUND");let l=h.store,u=l.hooks;if(u?.error&&(s=u?.error),"GET"!==e.method){let t=e.headers.get("content-type");if(t){let r=t.indexOf(";");if(-1!==r&&(t=t.slice(0,r)),this.event.parse.length)for(let e=0;e<this.event.parse.length;e++){let r=this.event.parse[e](a,t);if(r instanceof Promise&&(r=await r),void 0!==r){n=r;break}}if(void 0===n)switch(t){case"application/json":n=await e.json();break;case"text/plain":n=await e.text();break;case"application/x-www-form-urlencoded":n=o(await e.text());break;case"multipart/form-data":n={},await e.formData().then(e=>{for(let t of e.keys()){if(t in n)continue;let r=e.getAll(t);1===r.length?n[t]=r[0]:n[t]=r}});break;case"elysia/fn":n=b(await e.json())}}}if(a.body=n,a.params=h.params,i[2]&&(a.query=o(i[2])),u?.transform.length)for(let e=0;e<u.transform.length;e++){let t=u.transform[e](a);t instanceof Promise&&await t}if(l.validator){let t=l.validator;if(u?.error&&(s=u?.error),t.headers){let r={};for(let t in e.headers)r[t]=e.headers.get(t);if(!1===t.headers.Check(r))throw d("header",t.headers,r)}if(!1===t.params?.Check(a.params))throw d("params",t.params,a.params);if(!1===t.query?.Check(a.query))throw d("query",t.query,a.query);if(!1===t.body?.Check(n))throw d("body",t.body,n)}if(u?.beforeHandle.length)for(let e=0;e<u.beforeHandle.length;e++){let t=u.beforeHandle[e](a);if(t instanceof Promise&&(t=await t),null!=t){for(let e=0;e<u.afterHandle.length;e++){let r=u.afterHandle[e](a,t);r instanceof Promise&&(r=await r),r&&(t=r)}let e=r(t,a.set);if(e)return e}}let f=l.handle(a);if(f instanceof Promise&&(f=await f),!1===l.validator?.response?.Check(f))throw u?.error&&(s=u?.error),d("response",l.validator.response,f);if(u?.afterHandle.length)for(let e=0;e<u.afterHandle.length;e++){let t=u.afterHandle[e](a,f);t instanceof Promise&&(t=await t);let s=r(t,a.set);if(s)return s}return t(f,a.set)}catch(n){let t=a.set;if((!t.status||t.status<300)&&(t.status=500),s){let a=v(n.message);for(let i=0;i<s.length;i++){let o=s[i]({request:e,error:n,set:t,code:a});o instanceof Promise&&(o=await o);let h=r(o,t);if(h)return h}}return this.handleError(e,n,t)}};async handleError(e,r,s={headers:{}}){for(let a=0;a<this.event.error.length;a++){let n=this.event.error[a]({request:e,code:v(r.message),error:r,set:s});if(n instanceof Promise&&(n=await n),null!=n)return t(n,s)}return new Response("string"==typeof r.cause?r.cause:r.message,{headers:s.headers,status:g(v(r.message))})}listen=(e,t)=>{if(!Bun)throw Error("Bun to run");if("string"==typeof e&&Number.isNaN(e=+e))throw Error("Port must be a numeric value");let r=this.handle,s="object"==typeof e?{...this.config.serve,...e,fetch:r}:{...this.config.serve,port:e,fetch:r},a=`$$Elysia:${s.port}`;globalThis[a]?(this.server=globalThis[a],this.server.reload(s)):globalThis[a]=this.server=Bun.serve(s);for(let e=0;e<this.event.start.length;e++)this.event.start[e](this);return t&&t(this.server),Promise.all(this.lazyLoadModules).then(()=>{this.server.pendingRequests||Bun.gc(!0)}),this};stop=async()=>{if(!this.server)throw Error("Elysia isn't running. Call `app.listen` to start the server.");this.server.stop();for(let e=0;e<this.event.stop.length;e++)await this.event.stop[e](this)};get modules(){return Promise.all(this.lazyLoadModules)}setModel(e){return Object.entries(e).forEach(([e,t])=>{e in this.meta[i]||(this.meta[i][e]=t)}),this}}export{t}from"./custom-types";export{SCHEMA,DEFS,EXPOSED,createValidationError,getSchemaValidator,mergeDeep,mergeHook,mergeObjectArray,mapPathnameAndQueryRegEx,mapQuery}from"./utils";export{H as Elysia,s as permission};

@@ -1,16 +0,18 @@

import { TSchema } from '@sinclair/typebox';
import type { OpenAPIV2 } from 'openapi-types';
import { type TSchema } from '@sinclair/typebox';
import type { OpenAPIV3 } from 'openapi-types';
import type { HTTPMethod, LocalHook } from './types';
export declare const toOpenAPIPath: (path: string) => string;
export declare const mapProperties: (name: string, schema: TSchema | string | undefined, models: Record<string, TSchema>) => any[];
export declare const registerSchemaPath: ({ schema, path, method, hook, models }: {
schema: OpenAPIV2.PathsObject;
export declare const registerSchemaPath: ({ schema, contentType, path, method, hook, models }: {
schema: Partial<OpenAPIV3.PathsObject>;
contentType?: string | string[] | undefined;
path: string;
method: HTTPMethod;
hook?: LocalHook<import("./types").TypedSchema<string>, import("./types").ElysiaInstance<{
store: Record<any, any> & Record<typeof import("./utils").SCHEMA, {}> & Record<typeof import("./utils").DEFS, {}> & Record<typeof import("./utils").EXPOSED, {}>;
store: Record<any, any>;
request: {};
schema: {};
}>, string, import("./types").MergeSchema<import("./types").TypedSchema<string>, {}>> | undefined;
meta: Record<typeof import("./utils").SCHEMA, {}> & Record<typeof import("./utils").DEFS, {}> & Record<typeof import("./utils").EXPOSED, {}>;
}>, string, import("./types").MergeSchema<import("./types").TypedSchema<string>, {}>, import("./types").TypedSchema<string>> | undefined;
models: Record<string, TSchema>;
}) => void;

@@ -1,1 +0,1 @@

import{Kind as e}from"@sinclair/typebox";export const toOpenAPIPath=e=>e.split("/").map(e=>e.startsWith(":")?`{${e.slice(1,e.length)}}`:e).join("/");export const mapProperties=(e,t,r)=>{if(void 0===t)return[];if("string"==typeof t){if(t in r)t=r[t];else throw Error(`Can't find model ${t}`)}return Object.entries(t?.properties??[]).map(([r,s])=>({...s,in:e,name:r,type:s?.type,required:t.required?.includes(r)??!1}))};export const registerSchemaPath=({schema:t,path:r,method:s,hook:i,models:o})=>{r=toOpenAPIPath(r);let a=i?.schema?.body,n=i?.schema?.params,p=i?.schema?.headers,m=i?.schema?.query,h=i?.schema?.response;if("object"==typeof h){if(e in h){let{type:e,properties:t,required:r,...s}=h;h={200:{...s,schema:{type:e,properties:t,required:r}}}}else Object.entries(h).forEach(([e,t])=>{if("string"==typeof t){let{type:r,properties:s,required:i,...a}=o[t];h[e]={...a,schema:{$ref:`#/definitions/${t}`}}}else{let{type:r,properties:s,required:i,...o}=t;h[e]={...o,schema:{type:r,properties:s,required:i}}}})}else if("string"==typeof h){let{type:e,properties:t,required:r,...s}=o[h];h={200:{...s,schema:{$ref:`#/definitions/${h}`}}}}let c=[...mapProperties("header",p,o),...mapProperties("path",n,o),...mapProperties("query",m,o)];a&&c.push({in:"body",name:"body",required:!0,schema:"string"==typeof a?{$ref:`#/definitions/${a}`}:a}),t[r]={...t[r]?t[r]:{},[s.toLowerCase()]:{...p||n||m||a?{parameters:c}:{},...h?{responses:h}:{},...i?.schema?.detail}}};
import{Kind as e}from"@sinclair/typebox";export const toOpenAPIPath=e=>e.split("/").map(e=>e.startsWith(":")?`{${e.slice(1,e.length)}}`:e).join("/");export const mapProperties=(e,t,r)=>{if(void 0===t)return[];if("string"==typeof t){if(t in r)t=r[t];else throw Error(`Can't find model ${t}`)}return Object.entries(t?.properties??[]).map(([r,o])=>({...o,in:e,name:r,type:o?.type,required:t.required?.includes(r)??!1}))};let t=(e,t)=>{let r={};for(let o of e)r[o]={schema:"string"==typeof t?{$ref:`#/components/schemas/${t}`}:{...t}};return r};export const registerSchemaPath=({schema:r,contentType:o=["application/json","multipart/form-data","text/plain"],path:s,method:i,hook:n,models:p})=>{s=toOpenAPIPath(s);let a="string"==typeof o?[o]:o??["application/json"],c=n?.schema?.body,l=n?.schema?.params,m=n?.schema?.headers,f=n?.schema?.query,h=n?.schema?.response;if("object"==typeof h){if(e in h){let{type:e,properties:r,required:o,...s}=h;h={200:{...s,description:s.description,content:t(a,"object"===e||"array"===e?{type:e,properties:r,required:o}:h)}}}else Object.entries(h).forEach(([e,r])=>{if("string"==typeof r){let{type:o,properties:s,required:i,...n}=p[r];h[e]={...n,description:n.description,content:t(a,r)}}else{let{type:o,properties:s,required:i,...n}=r;h[e]={...n,description:n.description,content:t(a,{type:o,properties:s,required:i})}}})}else if("string"==typeof h){let{type:e,properties:r,required:o,...s}=p[h];h={200:{...s,content:t(a,h)}}}let d=[...mapProperties("header",m,p),...mapProperties("path",l,p),...mapProperties("query",f,p)];r[s]={...r[s]?r[s]:{},[i.toLowerCase()]:{...m||l||f||c?{parameters:d}:{},...h?{responses:h}:{},...n?.schema?.detail,...c?{requestBody:{content:t(a,"string"==typeof c?{$ref:`#/components/schemas/${c}`}:c)}}:null}}};

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

import type { SCHEMA, DEFS, EXPOSED } from './utils';
import type { OpenAPIV2 } from 'openapi-types';
import type { OpenAPIV3 } from 'openapi-types';
export type WithArray<T> = T | T[];
export type ObjectValues<T extends object> = T[keyof T];
export interface ElysiaInstance<Instance extends {
store?: Record<any, any> & Record<typeof SCHEMA, Partial<OpenAPIV2.PathsObject>> & Record<typeof DEFS, {
export type ElysiaInstance<Instance extends {
store?: Record<any, any>;
request?: Record<any, any>;
schema?: TypedSchema;
meta?: Record<typeof SCHEMA, Partial<OpenAPIV3.PathsObject>> & Record<typeof DEFS, {
[x in string]: TSchema;
}> & Record<typeof EXPOSED, Record<string, Record<string, unknown>>>;
request?: Record<any, any>;
schema?: TypedSchema;
} = {
store: Record<any, any> & Record<typeof SCHEMA, {}> & Record<typeof DEFS, {}> & Record<typeof EXPOSED, {}>;
store: Record<any, any>;
request: {};
schema: {};
}> {
request: Instance['request'] extends undefined ? Record<typeof SCHEMA, {}> : Instance['request'];
meta: Record<typeof SCHEMA, {}> & Record<typeof DEFS, {}> & Record<typeof EXPOSED, {}>;
}> = {
request: Instance['request'];
store: Instance['store'] extends undefined ? {} : Instance['store'];
schema: Instance['schema'] extends undefined ? TypedSchema : Instance['schema'];
}
export type Handler<Route extends TypedRoute = TypedRoute, Instance extends ElysiaInstance = ElysiaInstance, CatchResponse = Route['response']> = (context: Context<Route, Instance['store']> & Instance['request']) => Route['response'] extends (models: Record<string, TSchema>) => TSchema ? undefined extends ReturnType<Route['response']> ? MaybePromise<CatchResponse> | Response : MaybePromise<ReturnType<Route['response']>> | Response : undefined extends Route['response'] ? MaybePromise<CatchResponse> | Response : MaybePromise<Route['response']> | Response;
meta: Instance['meta'];
};
export type Handler<Route extends TypedRoute = TypedRoute, Instance extends ElysiaInstance = ElysiaInstance, CatchResponse = Route['response']> = (context: Context<Route, Instance['store']> & Instance['request'] & {
a: Instance;
r: Route;
merged: MergeSchema<Instance['schema'], Route>;
}) => Route['response'] extends (models: Record<string, TSchema>) => TSchema ? undefined extends ReturnType<Route['response']> ? MaybePromise<CatchResponse> | Response : MaybePromise<ReturnType<Route['response']>> | Response : undefined extends Route['response'] ? MaybePromise<CatchResponse> | Response : MaybePromise<Route['response']> | Response;
export type NoReturnHandler<Route extends TypedRoute = TypedRoute, Instance extends ElysiaInstance = ElysiaInstance> = (context: Context<Route, Instance['store']> & Instance['request']) => void | Promise<void>;

@@ -69,13 +76,13 @@ export type LifeCycleEvent = 'start' | 'request' | 'parse' | 'transform' | 'beforeHandle' | 'afterHandle' | 'error' | 'stop';

}
export type UnwrapSchema<Schema extends TSchema | undefined | string, Instance extends ElysiaInstance = ElysiaInstance, Fallback = unknown> = Schema extends string ? Instance['store'][typeof DEFS] extends {
export type UnwrapSchema<Schema extends TSchema | undefined | string, Definitions extends ElysiaInstance['meta'][typeof DEFS] = {}, Fallback = unknown> = Schema extends string ? Definitions extends {
[name in Schema]: infer NamedSchema extends TSchema;
} ? Static<NamedSchema> : Fallback : Schema extends TSchema ? Static<NonNullable<Schema>> : Fallback;
export type TypedSchemaToRoute<Schema extends TypedSchema, Instance extends ElysiaInstance> = {
body: UnwrapSchema<Schema['body'], Instance>;
headers: UnwrapSchema<Schema['headers'], Instance> extends infer Result extends Record<string, any> ? Result : undefined;
query: UnwrapSchema<Schema['query'], Instance> extends infer Result extends Record<string, any> ? Result : undefined;
params: UnwrapSchema<Schema['params'], Instance> extends infer Result extends Record<string, any> ? Result : undefined;
response: Schema['response'] extends TSchema | string ? UnwrapSchema<Schema['response'], Instance> : Schema['response'] extends {
export type TypedSchemaToRoute<Schema extends TypedSchema<any>, Definitions extends ElysiaInstance['meta'][typeof DEFS]> = {
body: UnwrapSchema<Schema['body'], Definitions>;
headers: UnwrapSchema<Schema['headers'], Definitions> extends infer Result extends Record<string, any> ? Result : undefined;
query: UnwrapSchema<Schema['query'], Definitions> extends infer Result extends Record<string, any> ? Result : undefined;
params: UnwrapSchema<Schema['params'], Definitions> extends infer Result extends Record<string, any> ? Result : undefined;
response: Schema['response'] extends TSchema | string ? UnwrapSchema<Schema['response'], Definitions> : Schema['response'] extends {
[k in string]: TSchema | string;
} ? UnwrapSchema<ObjectValues<Schema['response']>, Instance> : unknown;
} ? UnwrapSchema<ObjectValues<Schema['response']>, Definitions> : unknown;
};

@@ -96,3 +103,3 @@ export type AnyTypedSchema = {

};
export type HookHandler<Schema extends TypedSchema = TypedSchema, Instance extends ElysiaInstance = ElysiaInstance, Path extends string = string, Typed extends AnyTypedSchema = TypedSchemaToRoute<Schema, Instance>> = Handler<Typed['params'] extends {} ? Omit<Typed, 'response'> & {
export type HookHandler<Schema extends TypedSchema = TypedSchema, Instance extends ElysiaInstance = ElysiaInstance, Path extends string = string, Typed extends AnyTypedSchema = TypedSchemaToRoute<Schema, Instance['meta'][typeof DEFS]>> = Handler<Typed['params'] extends {} ? Omit<Typed, 'response'> & {
response: void | Typed['response'];

@@ -107,3 +114,3 @@ } : Omit<Omit<Typed, 'response'> & {

export type PickInOrder<A, B> = A extends NonNullable<A> ? A : B;
export type MergeSchema<A extends TypedSchema, B extends TypedSchema> = {
export type MergeSchema<A extends TypedSchema<any>, B extends TypedSchema<any>> = {
body: PickInOrder<PickInOrder<A['body'], B['body']>, undefined>;

@@ -115,5 +122,9 @@ headers: PickInOrder<PickInOrder<A['headers'], B['headers']>, undefined>;

};
export interface LocalHook<Schema extends TypedSchema = TypedSchema, Instance extends ElysiaInstance<any> = ElysiaInstance, Path extends string = string, FinalSchema extends MergeSchema<Schema, Instance['schema']> = MergeSchema<Schema, Instance['schema']>> {
schema?: Schema & {
detail?: Partial<OpenAPIV2.OperationObject>;
type MaybeArray<T> = T | T[];
type ExtractModelName<Type> = Type extends TypedSchema<infer X> ? X : never;
type ContentType = MaybeArray<(string & {}) | 'text/plain' | 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded'>;
export interface LocalHook<Schema extends TypedSchema = TypedSchema, Instance extends ElysiaInstance<any> = ElysiaInstance, Path extends string = string, FinalSchema extends MergeSchema<Schema, Instance['schema']> = MergeSchema<Schema, Instance['schema']>, Models extends TypedSchema = TypedSchema<ExtractModelName<Schema>>> {
schema?: (Models extends Schema ? Models : Models) & {
contentType?: ContentType;
detail?: Partial<OpenAPIV3.OperationObject>;
};

@@ -125,3 +136,3 @@ transform?: WithArray<HookHandler<FinalSchema, Instance, Path>>;

}
export type RouteToSchema<Schema extends TypedSchema = TypedSchema, Instance extends ElysiaInstance<any> = ElysiaInstance, Path extends string = string, FinalSchema extends MergeSchema<Schema, Instance['schema']> = MergeSchema<Schema, Instance['schema']>> = FinalSchema['params'] extends NonNullable<Schema['params']> ? TypedSchemaToRoute<FinalSchema, Instance> : Omit<TypedSchemaToRoute<FinalSchema, Instance>, 'params'> & {
export type RouteToSchema<Schema extends TypedSchema, InstanceSchema extends ElysiaInstance['schema'], Definitions extends ElysiaInstance['meta'][typeof DEFS], Path extends string = string, FinalSchema extends MergeSchema<Schema, InstanceSchema> = MergeSchema<Schema, InstanceSchema>> = FinalSchema['params'] extends NonNullable<Schema['params']> ? TypedSchemaToRoute<FinalSchema, Definitions> : Omit<TypedSchemaToRoute<FinalSchema, Definitions>, 'params'> & {
params: Record<ExtractPath<Path>, string>;

@@ -131,32 +142,31 @@ };

request: Instance['request'];
store: Instance['store'] & {
[SCHEMA]: {
[path in Path]: {
[method in Method]: TypedRouteToEden<Schema, Instance, Path> extends infer FinalSchema extends AnyTypedSchema ? Omit<FinalSchema, 'response'> & {
response: undefined extends FinalSchema['response'] ? {
'200': CatchResponse;
} : FinalSchema['response'];
} : never;
};
store: Instance['store'];
schema: Instance['schema'];
meta: Instance['meta'] & Record<typeof SCHEMA, {
[path in Path]: {
[method in Method]: TypedRouteToEden<Schema, Instance['meta'][typeof DEFS], Path> extends infer FinalSchema extends AnyTypedSchema ? Omit<FinalSchema, 'response'> & {
response: undefined extends FinalSchema['response'] ? {
'200': CatchResponse;
} : FinalSchema['response'];
} : never;
};
};
schema: Instance['schema'];
}>;
}>;
export type TypedRouteToEden<Schema extends TypedSchema = TypedSchema, Instance extends ElysiaInstance<any> = ElysiaInstance, Path extends string = string, FinalSchema extends MergeSchema<Schema, Instance['schema']> = MergeSchema<Schema, Instance['schema']>> = FinalSchema['params'] extends NonNullable<Schema['params']> ? TypedSchemaToEden<FinalSchema, Instance> : Omit<TypedSchemaToEden<FinalSchema, Instance>, 'params'> & {
export type TypedRouteToEden<Schema extends TypedSchema = TypedSchema, Definitions extends TypedSchema<string> = ElysiaInstance['meta'][typeof DEFS], Path extends string = string, FinalSchema extends MergeSchema<Schema, Definitions> = MergeSchema<Schema, Definitions>> = FinalSchema['params'] extends NonNullable<Schema['params']> ? TypedSchemaToEden<FinalSchema, Definitions> : Omit<TypedSchemaToEden<FinalSchema, Definitions>, 'params'> & {
params: Record<ExtractPath<Path>, string>;
};
export type TypedSchemaToEden<Schema extends TypedSchema, Instance extends ElysiaInstance> = {
body: UnwrapSchema<Schema['body'], Instance>;
headers: UnwrapSchema<Schema['headers'], Instance> extends infer Result extends Record<string, any> ? Result : undefined;
query: UnwrapSchema<Schema['query'], Instance> extends infer Result extends Record<string, any> ? Result : undefined;
params: UnwrapSchema<Schema['params'], Instance> extends infer Result extends Record<string, any> ? Result : undefined;
export type TypedSchemaToEden<Schema extends TypedSchema, Definitions extends ElysiaInstance['meta'][typeof DEFS]> = {
body: UnwrapSchema<Schema['body'], Definitions>;
headers: UnwrapSchema<Schema['headers'], Definitions> extends infer Result extends Record<string, any> ? Result : undefined;
query: UnwrapSchema<Schema['query'], Definitions> extends infer Result extends Record<string, any> ? Result : undefined;
params: UnwrapSchema<Schema['params'], Definitions> extends infer Result extends Record<string, any> ? Result : undefined;
response: Schema['response'] extends TSchema | string ? {
'200': UnwrapSchema<Schema['response'], Instance>;
'200': UnwrapSchema<Schema['response'], Definitions>;
} : Schema['response'] extends {
[x in string]: TSchema | string;
} ? {
[key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Instance>;
[key in keyof Schema['response']]: UnwrapSchema<Schema['response'][key], Definitions>;
} : unknown;
};
export type LocalHandler<Schema extends TypedSchema = TypedSchema, Instance extends ElysiaInstance = ElysiaInstance, Path extends string = string, CatchResponse = unknown> = Handler<RouteToSchema<Schema, Instance, Path>, Instance, CatchResponse>;
export type LocalHandler<Schema extends TypedSchema, Instance extends ElysiaInstance, Path extends string = string, CatchResponse = unknown> = Handler<RouteToSchema<Schema, Instance['schema'], Instance['meta'][typeof DEFS], Path>, Instance, CatchResponse>;
export interface TypedRoute {

@@ -230,8 +240,9 @@ body?: unknown;

export type IsNever<T> = [T] extends [never] ? true : false;
export type FunctionalKeys<T, Prefix extends string = ''> = {
[K in keyof T]-?: T[K] extends Function ? `${Prefix}${K}` : never;
}[keyof T] | {
[K in keyof T]-?: T[K] extends object ? FunctionalKeys<T[K], `${Prefix}${K}.`> : never;
export type FunctionProperties<T> = {
[K in keyof T as T[K] extends Record<any, any> | ((...args: any[]) => any) ? IsAny<T[K]> extends true ? never : K : never]: T[K] extends (...args: any[]) => any ? T[K] : T[K] extends Record<string, any> ? FunctionProperties<T[K]> : never;
};
export type JoinKeys<T, Prefix extends string = ''> = {
[K in keyof T]-?: T[K] extends string | Function ? '' extends Prefix ? K : K extends string ? `${Prefix}.${K}` : never : K extends string ? JoinKeys<T[K], '' extends Prefix ? K : `${Prefix}.${K}`> : never;
}[keyof T];
export type ConnectedKeysType<T, K extends string> = K extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? ConnectedKeysType<T[Key], Rest> : never : K extends keyof T ? T[K] extends (...args: any) => any ? ReturnType<T[K]> : never : never;
export type ConnectedKeysType<T, K extends string> = K extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? ConnectedKeysType<T[Key], Rest> : never : K extends keyof T ? T[K] extends (...args: infer A) => any ? A : never : never;
export type Prettify<T> = {

@@ -238,0 +249,0 @@ [K in keyof T]: T[K];

@@ -1,5 +0,4 @@

/// <reference types="bun-types" />
import { TSchema } from '@sinclair/typebox';
import { TypeCheck } from '@sinclair/typebox/compiler';
import type { DeepMergeTwoTypes, LifeCycleStore, LocalHook, TypedSchema, RegisteredHook, ConnectedKeysType, FunctionalKeys } from './types';
import type { DeepMergeTwoTypes, LifeCycleStore, LocalHook, TypedSchema, RegisteredHook } from './types';
export declare const SCHEMA: unique symbol;

@@ -17,17 +16,1 @@ export declare const DEFS: unique symbol;

export declare const getResponseSchemaValidator: (s: TypedSchema['response'] | undefined, models: Record<string, TSchema>, additionalProperties?: boolean) => TypeCheck<TSchema> | undefined;
export declare const exposePermission: <T, Key = T extends Record<any, any> ? FunctionalKeys<T, ""> : never>({ value, allow }: {
value: T;
allow?: boolean | ((context: {
request: Request;
key: Key;
params: Key extends string ? ConnectedKeysType<T, Key> : unknown;
}) => unknown) | undefined;
}) => {
value: T;
allow?: boolean | ((context: {
request: Request;
key: Key;
params: Key extends string ? ConnectedKeysType<T, Key> : unknown;
}) => unknown) | undefined;
[EXPOSED]: true;
};

@@ -1,1 +0,1 @@

import{Kind as e,Type as r}from"@sinclair/typebox";import{TypeCompiler as t}from"@sinclair/typebox/compiler";export const SCHEMA=Symbol("schema");export const DEFS=Symbol("definitions");export const EXPOSED=Symbol("exposed");export const mergeObjectArray=(e,r)=>[...Array.isArray(e)?e:[e],...Array.isArray(r)?r:[r]];export const mergeHook=(e,r)=>{let t="schema"in e?e.schema:null,o=r&&"schema"in r?r.schema:null;return{schema:t||o?{body:o?.body??t?.body,header:o?.headers??t?.headers,params:o?.params??t?.params,query:o?.query??t?.query,response:o?.response??t?.response}:void 0,transform:mergeObjectArray(e.transform??[],r?.transform??[]),beforeHandle:mergeObjectArray(e.beforeHandle??[],r?.beforeHandle??[]),afterHandle:mergeObjectArray(e.afterHandle??[],r?.afterHandle??[]),error:mergeObjectArray(e.error??[],r?.error??[])}};export const clone=e=>e;export const mapPathnameAndQueryRegEx=/:\/\/[^/]+([^#?]+)(?:\?([^#]+))?/;export const mapQuery=e=>{let r={},t=e.split("&");for(let e=0;e<t.length;e++){let o=t[e],n=o.indexOf("="),a=o.slice(n+1);a.includes("%")&&(a=decodeURIComponent(a)),r[o.slice(0,n)]=a}return r};let o=e=>e&&"object"==typeof e&&!Array.isArray(e);export const mergeDeep=(e,r)=>{let t=Object.assign({},e);return o(e)&&o(r)&&Object.keys(r).forEach(n=>{o(r[n])&&n in e?t[n]=mergeDeep(e[n],r[n]):Object.assign(t,{[n]:r[n]})}),t};export const createValidationError=(e,r,t)=>{let o=r.Errors(t).next().value;return Error("VALIDATION",{cause:`Invalid ${e}: '${o?.path?.slice(1)||"root"}'. ${o.message}`})};export const getSchemaValidator=(e,r,o=!1)=>{if(!e||"string"==typeof e&&!(e in r))return;let n="string"==typeof e?r[e]:e;return"object"===n.type&&"additionalProperties"in n==!1&&(n.additionalProperties=o),t.Compile(n)};export const getResponseSchemaValidator=(o,n,a=!1)=>{if(!o||"string"==typeof o&&!(o in n))return;let s="string"==typeof o?n[o]:o,i=e in s?s:r.Union(Object.keys(s).map(e=>{let r=s[e];if("string"==typeof r){if(r in n){let e=n[r];return e}return}return r}).filter(e=>e));return"object"===i.type&&"additionalProperties"in i==!1&&(i.additionalProperties=a),t.Compile(i)};export const exposePermission=({value:e,allow:r=!0})=>({[EXPOSED]:!0,value:e,allow:r});
import{Kind as e,Type as r}from"@sinclair/typebox";import{TypeCompiler as t}from"@sinclair/typebox/compiler";export const SCHEMA=Symbol("schema");export const DEFS=Symbol("definitions");export const EXPOSED=Symbol("exposed");export const mergeObjectArray=(e,r)=>[...Array.isArray(e)?e:[e],...Array.isArray(r)?r:[r]];export const mergeHook=(e,r)=>{let t="schema"in e?e.schema:null,o=r&&"schema"in r?r.schema:null;return{schema:t||o?{body:o?.body??t?.body,header:o?.headers??t?.headers,params:o?.params??t?.params,query:o?.query??t?.query,response:o?.response??t?.response}:void 0,transform:mergeObjectArray(e.transform??[],r?.transform??[]),beforeHandle:mergeObjectArray(e.beforeHandle??[],r?.beforeHandle??[]),afterHandle:mergeObjectArray(e.afterHandle??[],r?.afterHandle??[]),error:mergeObjectArray(e.error??[],r?.error??[])}};export const clone=e=>e;export const mapPathnameAndQueryRegEx=/:\/\/[^/]+([^#?]+)(?:\?([^#]+))?/;export const mapQuery=e=>{let r={},t=e.split("&");for(let e=0;e<t.length;e++){let o=t[e],n=o.indexOf("="),a=o.slice(n+1);a.includes("%")&&(a=decodeURIComponent(a)),r[o.slice(0,n)]=a}return r};let o=e=>e&&"object"==typeof e&&!Array.isArray(e);export const mergeDeep=(e,r)=>{let t=Object.assign({},e);return o(e)&&o(r)&&Object.keys(r).forEach(n=>{o(r[n])&&n in e?t[n]=mergeDeep(e[n],r[n]):Object.assign(t,{[n]:r[n]})}),t};export const createValidationError=(e,r,t)=>{let o=r.Errors(t).next().value;return Error("VALIDATION",{cause:`Invalid ${e}: '${o?.path?.slice(1)||"root"}'. ${o.message}`})};export const getSchemaValidator=(e,r,o=!1)=>{if(!e||"string"==typeof e&&!(e in r))return;let n="string"==typeof e?r[e]:e;return"object"===n.type&&"additionalProperties"in n==!1&&(n.additionalProperties=o),t.Compile(n)};export const getResponseSchemaValidator=(o,n,a=!1)=>{if(!o||"string"==typeof o&&!(o in n))return;let s="string"==typeof o?n[o]:o,i=e in s?s:r.Union(Object.keys(s).map(e=>{let r=s[e];if("string"==typeof r){if(r in n){let e=n[r];return e}return}return r}).filter(e=>e));return"object"===i.type&&"additionalProperties"in i==!1&&(i.additionalProperties=a),t.Compile(i)};
{
"name": "elysia",
"description": "Fast, and friendly Bun web framework",
"version": "0.3.0-exp-230222.2210",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
"email": "saltyaom@gmail.com"
},
"main": "./dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/index.js",
"node": "./dist/index.js",
"default": "./dist/index.js"
},
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/elysiajs/elysia"
},
"bugs": "https://github.com/elysiajs/elysia/issues",
"homepage": "https://github.com/elysiajs/elysia",
"keywords": [
"bun",
"http",
"web",
"server"
],
"license": "MIT",
"scripts": {
"test": "bun wiptest",
"dev": "bun run --hot example/http.ts",
"build": "rimraf dist && swc src -d dist && tsc --project tsconfig.esm.json",
"release": "npm run build && npm run test && npm publish"
},
"dependencies": {
"@sinclair/typebox": "^0.25.21",
"openapi-types": "^12.1.0",
"raikiri": "^0.0.0-beta.5",
"superjson": "^1.12.2"
},
"devDependencies": {
"@swc/cli": "^0.1.60",
"@swc/core": "^1.3.32",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"bun-types": "^0.5.0",
"eslint": "^8.32.0",
"rimraf": "^3.0.2",
"typescript": "^4.9.4"
}
"name": "elysia",
"description": "Fast, and friendly Bun web framework",
"version": "0.3.0-exp-230226.2331",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
"email": "saltyaom@gmail.com"
},
"main": "./dist/index.js",
"exports": {
"import": "./dist/index.js",
"default": "./dist/index.js",
"node": "./dist/index.js"
},
"types": "./src/index.ts",
"repository": {
"type": "git",
"url": "https://github.com/elysiajs/elysia"
},
"bugs": "https://github.com/elysiajs/elysia/issues",
"homepage": "https://github.com/elysiajs/elysia",
"keywords": [
"bun",
"http",
"web",
"server"
],
"license": "MIT",
"scripts": {
"test": "bun test",
"dev": "bun run --hot example/http.ts",
"build": "rimraf dist && swc src -d dist && tsc --project tsconfig.esm.json",
"release": "npm run build && npm run test && npm publish"
},
"dependencies": {
"@sinclair/typebox": "^0.25.21",
"openapi-types": "^12.1.0",
"raikiri": "^0.0.0-beta.8",
"superjson": "^1.12.2"
},
"devDependencies": {
"@swc/cli": "^0.1.60",
"@swc/core": "^1.3.32",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"bun-types": "^0.5.7",
"eslint": "^8.32.0",
"rimraf": "^3.0.2",
"typescript": "^4.9.4"
},
"peerDependencies": {
"@sinclair/typebox": ">= 0.25.21",
"openapi-types": ">= 12.0.0"
},
"peerDependenciesMeta": {
"@sinclair/typebox": {
"optional": true
},
"openapi-types": {
"optional": true
}
}
}
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