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 1.1.2 to 1.1.3

17

dist/cjs/handler.js

@@ -970,7 +970,13 @@ "use strict";

};
var handleStream = (generator, set, request) => {
let end = false;
var handleStream = async (generator, set, request) => {
let init = generator.next();
if (init instanceof Promise) init = await init;
if (init.done) {
if (set) return mapResponse(init.value, set, request);
return mapCompactResponse(init.value, request);
}
return new Response(
new ReadableStream({
async start(controller) {
let end = false;
request?.signal.addEventListener("abort", () => {

@@ -983,5 +989,7 @@ end = true;

});
if (init.value !== void 0 && init.value !== null)
controller.enqueue(Buffer.from(init.value.toString()));
for await (const chunk of generator) {
if (end) break;
if (!chunk) continue;
if (chunk === void 0 || chunk === null) continue;
controller.enqueue(Buffer.from(chunk.toString()));

@@ -1003,3 +1011,4 @@ await new Promise(

"transfer-encoding": "chunked",
"content-type": "text/event-stream; charset=utf-8"
"content-type": "text/event-stream; charset=utf-8",
...set?.headers
}

@@ -1006,0 +1015,0 @@ }

@@ -51,6 +51,12 @@ import type { Handler, HookContainer, LifeCycleStore } from './types';

* ```typescript
* retrieveRootParameters('({ hello: { world: { a } }, elysia })') // => 'hello elysia'
* retrieveRootParameters('({ hello: { world: { a } }, elysia })') // => {
* parameters: ['hello', 'elysia'],
* hasParenthesis: true
* }
* ```
*/
export declare const retrieveRootParamters: (parameter: string) => string;
export declare const retrieveRootParamters: (parameter: string) => {
hasParenthesis: boolean;
parameters: string[];
};
/**

@@ -57,0 +63,0 @@ * Find inference from parameter

@@ -120,2 +120,13 @@ "use strict";

};
var removeColonAlias = (parameter) => {
while (true) {
const start = parameter.indexOf(":");
if (start === -1) break;
let end = parameter.indexOf(",", start);
if (end === -1) end = parameter.indexOf("}", start) - 1;
if (end === 0) end = parameter.length;
parameter = parameter.slice(0, start) + parameter.slice(end);
}
return parameter;
};
var retrieveRootParamters = (parameter) => {

@@ -128,26 +139,31 @@ let hasParenthesis = false;

}
parameter = parameter.trim();
parameter = parameter.replace(/( |\t|\n)/g, "").trim();
let parameters = [];
while (true) {
const [start, end] = bracketPairRange(parameter);
let [start, end] = bracketPairRange(parameter);
if (start === -1) break;
parameter = parameter.slice(0, start - 2) + parameter.slice(end + 1);
parameters.push(parameter.slice(0, start - 1));
if (parameter.charCodeAt(end) === 44) end++;
parameter = parameter.slice(end);
}
const result = parameter.replace(/:/g, "").trim();
if (hasParenthesis) return "{ " + result + " }";
return result;
parameter = removeColonAlias(parameter);
if (parameter) parameters = parameters.concat(parameter.split(","));
return {
hasParenthesis,
parameters
};
};
var findParameterReference = (parameter, inference) => {
const root = retrieveRootParamters(parameter);
if (root.charCodeAt(0) === 123) {
if (!inference.query && root.includes("query")) inference.query = true;
if (!inference.headers && root.includes("headers"))
inference.headers = true;
if (!inference.body && root.includes("body")) inference.body = true;
if (!inference.cookie && root.includes("cookie"))
inference.cookie = true;
if (!inference.set && root.includes("set")) inference.set = true;
if (!inference.server && root.includes("server"))
inference.server = true;
}
return root;
const { parameters, hasParenthesis } = retrieveRootParamters(parameter);
if (!inference.query && parameters.includes("query")) inference.query = true;
if (!inference.headers && parameters.includes("headers"))
inference.headers = true;
if (!inference.body && parameters.includes("body")) inference.body = true;
if (!inference.cookie && parameters.includes("cookie"))
inference.cookie = true;
if (!inference.set && parameters.includes("set")) inference.set = true;
if (!inference.server && parameters.includes("server"))
inference.server = true;
if (hasParenthesis) return `{ ${parameters.join(", ")} }`;
return parameters.join(", ");
};

@@ -177,3 +193,3 @@ var findEndIndex = (type, content, index) => {

const [start, end] = bracketPairRangeReverse(part);
aliases.push(content.slice(start, end));
aliases.push(removeColonAlias(content.slice(start, end)));
content = content.slice(index + 3 + type.length);

@@ -210,15 +226,17 @@ continue;

const access = (type, alias) => code.includes(alias + "." + type) || code.includes(alias + '["' + type + '"]') || code.includes(alias + "['" + type + "']");
for (let alias of aliases) {
for (const alias of aliases) {
if (!alias) continue;
if (alias.charCodeAt(0) === 123) {
alias = retrieveRootParamters(alias);
if (!inference.query && alias.includes("query"))
const parameters = retrieveRootParamters(alias).parameters;
if (!inference.query && parameters.includes("query"))
inference.query = true;
if (!inference.headers && alias.includes("headers"))
if (!inference.headers && parameters.includes("headers"))
inference.headers = true;
if (!inference.body && alias.includes("body")) inference.body = true;
if (!inference.cookie && alias.includes("cookie"))
if (!inference.body && parameters.includes("body"))
inference.body = true;
if (!inference.cookie && parameters.includes("cookie"))
inference.cookie = true;
if (!inference.set && alias.includes("set")) inference.set = true;
if (!inference.query && alias.includes("server"))
if (!inference.set && parameters.includes("set"))
inference.set = true;
if (!inference.query && parameters.includes("server"))
inference.server = true;

@@ -314,6 +332,4 @@ continue;

aliases.splice(0, -1, mainParameter);
for (const alias of aliases)
if (isContextPassToFunction(mainParameter, body, inference))
break;
inferBodyReference(body, aliases, inference);
if (!isContextPassToFunction(mainParameter, body, inference))
inferBodyReference(body, aliases, inference);
if (!inference.query && body.includes("return " + mainParameter + ".query"))

@@ -320,0 +336,0 @@ inference.query = true;

@@ -403,3 +403,2 @@ import type { Elysia } from '.';

set: Context['set'];
a: Singleton;
} & Partial<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive']> & Partial<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{

@@ -410,3 +409,3 @@ request: Request;

set: Context['set'];
} & NeverKey<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive']> & NeverKey<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
} & Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & NeverKey<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
request: Request;

@@ -421,3 +420,3 @@ code: 'NOT_FOUND';

set: Context['set'];
} & NeverKey<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive']> & NeverKey<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
} & Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & NeverKey<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
request: Request;

@@ -424,0 +423,0 @@ code: 'INTERNAL_SERVER_ERROR';

@@ -51,6 +51,12 @@ import type { Handler, HookContainer, LifeCycleStore } from './types';

* ```typescript
* retrieveRootParameters('({ hello: { world: { a } }, elysia })') // => 'hello elysia'
* retrieveRootParameters('({ hello: { world: { a } }, elysia })') // => {
* parameters: ['hello', 'elysia'],
* hasParenthesis: true
* }
* ```
*/
export declare const retrieveRootParamters: (parameter: string) => string;
export declare const retrieveRootParamters: (parameter: string) => {
hasParenthesis: boolean;
parameters: string[];
};
/**

@@ -57,0 +63,0 @@ * Find inference from parameter

@@ -403,3 +403,2 @@ import type { Elysia } from '.';

set: Context['set'];
a: Singleton;
} & Partial<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive']> & Partial<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{

@@ -410,3 +409,3 @@ request: Request;

set: Context['set'];
} & NeverKey<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive']> & NeverKey<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
} & Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & NeverKey<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
request: Request;

@@ -421,3 +420,3 @@ code: 'NOT_FOUND';

set: Context['set'];
} & NeverKey<Singleton['derive'] & Ephemeral['derive'] & Volatile['derive']> & NeverKey<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
} & Singleton['derive'] & Ephemeral['derive'] & Volatile['derive'] & NeverKey<Singleton['derive'] & Ephemeral['resolve'] & Volatile['resolve']>> | Prettify<{
request: Request;

@@ -424,0 +423,0 @@ code: 'INTERNAL_SERVER_ERROR';

{
"name": "elysia",
"description": "Ergonomic Framework for Human",
"version": "1.1.2",
"version": "1.1.3",
"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 too big to display

Sorry, the diff of this file is not supported yet

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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