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

elysia

Package Overview
Dependencies
Maintainers
1
Versions
451
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.6.8 to 0.6.9

8

dist/cjs/dynamic-handle.js

@@ -125,3 +125,9 @@ "use strict";

const operation = hooks.transform[i](context);
if (operation instanceof Promise)
if (hooks.transform[i].$elysia === 'derive') {
if (operation instanceof Promise)
Object.assign(context, await operation);
else
Object.assign(context, operation);
}
else if (operation instanceof Promise)
await operation;

@@ -128,0 +134,0 @@ }

2

dist/dynamic-handle.js

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

import{NotFoundError as e,ValidationError as t,ERROR_CODE as a}from"./error";import{mapEarlyResponse as r,mapResponse as s}from"./handler";import{parse as n}from"fast-querystring";export const createDynamicHandler=o=>async a=>{let i;let l={status:200,headers:{}};o.decorators?((i=o.decorators).request=a,i.set=l,i.store=o.store):i={set:l,store:o.store,request:a};let f=a.url,c=f.indexOf("/",12),d=f.indexOf("?",c+1),w=-1===d?f.substring(c):f.substring(c,d);try{let c;for(let e=0;e<o.event.request.length;e++){let t=o.event.request[e],a=t(i);if(a instanceof Promise&&(a=await a),a=r(a,l))return a}let h=o.dynamicRouter.find(a.method,w)??o.dynamicRouter.find("ALL",w);if(!h)throw new e;let{handle:m,hooks:p,validator:u,content:y}=h.store;if("GET"!==a.method){if(y)switch(y){case"application/json":c=await a.json();break;case"text/plain":c=await a.text();break;case"application/x-www-form-urlencoded":c=n(await a.text());break;case"application/octet-stream":c=await a.arrayBuffer();break;case"multipart/form-data":c={};let e=await a.formData();for(let t of e.keys()){if(c[t])continue;let a=e.getAll(t);1===a.length?c[t]=a[0]:c[t]=a}}else{let e=a.headers.get("content-type");if(e){let t=e.indexOf(";");-1!==t&&(e=e.slice(0,t));for(let t=0;t<o.event.parse.length;t++){let a=o.event.parse[t](i,e);if(a instanceof Promise&&(a=await a),a){c=a;break}}if(void 0===c)switch(e){case"application/json":c=await a.json();break;case"text/plain":c=await a.text();break;case"application/x-www-form-urlencoded":c=n(await a.text());break;case"application/octet-stream":c=await a.arrayBuffer();break;case"multipart/form-data":c={};let r=await a.formData();for(let e of r.keys()){if(c[e])continue;let t=r.getAll(e);1===t.length?c[e]=t[0]:c[e]=t}}}}}i.body=c,i.params=h?.params||{},i.query=n(f.substring(d+1));for(let e=0;e<p.transform.length;e++){let t=p.transform[e](i);t instanceof Promise&&await t}if(u){if(u.headers){let e={};for(let t in a.headers)e[t]=a.headers.get(t);if(!1===u.headers.Check(e))throw new t("header",u.headers,e)}if(u.params?.Check(i.params)===!1)throw new t("params",u.params,i.params);if(u.query?.Check(i.query)===!1)throw new t("query",u.query,i.query);if(u.body?.Check(c)===!1)throw new t("body",u.body,c)}for(let e=0;e<p.beforeHandle.length;e++){let t=p.beforeHandle[e](i);if(t instanceof Promise&&(t=await t),void 0!==t){for(let e=0;e<p.afterHandle.length;e++){let a=p.afterHandle[e](i,t);a instanceof Promise&&(a=await a),a&&(t=a)}let e=r(t,i.set);if(e)return e}}let g=m(i);if(g instanceof Promise&&(g=await g),p.afterHandle.length)for(let e=0;e<p.afterHandle.length;e++){let a=p.afterHandle[e](i,g);a instanceof Promise&&(a=await a);let s=r(a,i.set);if(void 0!==s){let e=u?.response?.[g.status];if(e?.Check(s)===!1)throw new t("response",e,s);return s}}else{let e=u?.response?.[g.status];if(e?.Check(g)===!1)throw new t("response",e,g)}return s(g,i.set)}catch(e){return o.handleError(a,e,l)}finally{for(let e of o.event.onResponse)await e(i)}};export const createDynamicErrorHandler=o=>async(e,t,r={headers:{}})=>{for(let n=0;n<o.event.error.length;n++){let i=o.event.error[n]({request:e,code:t.code??t[a]??"UNKNOWN",error:t,set:r});if(i instanceof Promise&&(i=await i),null!=i)return s(i,r)}return new Response("string"==typeof t.cause?t.cause:t.message,{headers:r.headers,status:t.status??500})};
import{NotFoundError as e,ValidationError as t,ERROR_CODE as a}from"./error";import{mapEarlyResponse as r,mapResponse as s}from"./handler";import{parse as n}from"fast-querystring";export const createDynamicHandler=o=>async a=>{let i;let l={status:200,headers:{}};o.decorators?((i=o.decorators).request=a,i.set=l,i.store=o.store):i={set:l,store:o.store,request:a};let f=a.url,c=f.indexOf("/",12),d=f.indexOf("?",c+1),w=-1===d?f.substring(c):f.substring(c,d);try{let c;for(let e=0;e<o.event.request.length;e++){let t=o.event.request[e],a=t(i);if(a instanceof Promise&&(a=await a),a=r(a,l))return a}let m=o.dynamicRouter.find(a.method,w)??o.dynamicRouter.find("ALL",w);if(!m)throw new e;let{handle:h,hooks:p,validator:u,content:y}=m.store;if("GET"!==a.method){if(y)switch(y){case"application/json":c=await a.json();break;case"text/plain":c=await a.text();break;case"application/x-www-form-urlencoded":c=n(await a.text());break;case"application/octet-stream":c=await a.arrayBuffer();break;case"multipart/form-data":c={};let e=await a.formData();for(let t of e.keys()){if(c[t])continue;let a=e.getAll(t);1===a.length?c[t]=a[0]:c[t]=a}}else{let e=a.headers.get("content-type");if(e){let t=e.indexOf(";");-1!==t&&(e=e.slice(0,t));for(let t=0;t<o.event.parse.length;t++){let a=o.event.parse[t](i,e);if(a instanceof Promise&&(a=await a),a){c=a;break}}if(void 0===c)switch(e){case"application/json":c=await a.json();break;case"text/plain":c=await a.text();break;case"application/x-www-form-urlencoded":c=n(await a.text());break;case"application/octet-stream":c=await a.arrayBuffer();break;case"multipart/form-data":c={};let r=await a.formData();for(let e of r.keys()){if(c[e])continue;let t=r.getAll(e);1===t.length?c[e]=t[0]:c[e]=t}}}}}i.body=c,i.params=m?.params||{},i.query=n(f.substring(d+1));for(let e=0;e<p.transform.length;e++){let t=p.transform[e](i);"derive"===p.transform[e].$elysia?t instanceof Promise?Object.assign(i,await t):Object.assign(i,t):t instanceof Promise&&await t}if(u){if(u.headers){let e={};for(let t in a.headers)e[t]=a.headers.get(t);if(!1===u.headers.Check(e))throw new t("header",u.headers,e)}if(u.params?.Check(i.params)===!1)throw new t("params",u.params,i.params);if(u.query?.Check(i.query)===!1)throw new t("query",u.query,i.query);if(u.body?.Check(c)===!1)throw new t("body",u.body,c)}for(let e=0;e<p.beforeHandle.length;e++){let t=p.beforeHandle[e](i);if(t instanceof Promise&&(t=await t),void 0!==t){for(let e=0;e<p.afterHandle.length;e++){let a=p.afterHandle[e](i,t);a instanceof Promise&&(a=await a),a&&(t=a)}let e=r(t,i.set);if(e)return e}}let g=h(i);if(g instanceof Promise&&(g=await g),p.afterHandle.length)for(let e=0;e<p.afterHandle.length;e++){let a=p.afterHandle[e](i,g);a instanceof Promise&&(a=await a);let s=r(a,i.set);if(void 0!==s){let e=u?.response?.[g.status];if(e?.Check(s)===!1)throw new t("response",e,s);return s}}else{let e=u?.response?.[g.status];if(e?.Check(g)===!1)throw new t("response",e,g)}return s(g,i.set)}catch(e){return o.handleError(a,e,l)}finally{for(let e of o.event.onResponse)await e(i)}};export const createDynamicErrorHandler=o=>async(e,t,r={headers:{}})=>{for(let n=0;n<o.event.error.length;n++){let i=o.event.error[n]({request:e,code:t.code??t[a]??"UNKNOWN",error:t,set:r});if(i instanceof Promise&&(i=await i),null!=i)return s(i,r)}return new Response("string"==typeof t.cause?t.cause:t.message,{headers:r.headers,status:t.status??500})};
{
"name": "elysia",
"description": "Fast, and friendly Bun web framework",
"version": "0.6.8",
"version": "0.6.9",
"author": {

@@ -6,0 +6,0 @@ "name": "saltyAom",

Sorry, the diff of this file is too big to display

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