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

elysia

Package Overview
Dependencies
Maintainers
1
Versions
444
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.1.0-rc.1 to 0.1.0-rc.2

dist/cjs/context.d.ts

16

dist/cjs/error.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapErrorCode = void 0;
const knownErrors = new Set([
'BODY_LIMIT',
'BODY_LIMIT',
'INTERNAL_SERVER_ERROR',
'NOT_FOUND',
'VALIDATION'
]);
exports.mapErrorStatus = exports.mapErrorCode = void 0;
const errorCodeToStatus = new Map();
errorCodeToStatus.set('INTERNAL_SERVER_ERROR', 500);
errorCodeToStatus.set('NOT_FOUND', 404);
errorCodeToStatus.set('VALIDATION', 400);
const knownErrors = new Set(errorCodeToStatus.keys());
const mapErrorCode = (error) => knownErrors.has(error) ? error : 'UNKNOWN';
exports.mapErrorCode = mapErrorCode;
const mapErrorStatus = (error) => errorCodeToStatus.get(error) ?? 500;
exports.mapErrorStatus = mapErrorStatus;

@@ -739,3 +739,3 @@ "use strict";

let body;
if (request.method !== 'GET') {
if (request.method !== 'GET' && request.method !== 'HEAD') {
const contentType = request.headers.get('content-type') ?? '';

@@ -753,3 +753,3 @@ if (contentType !== '')

}
let context = {
const context = {
request,

@@ -831,3 +831,5 @@ params: route?.params ?? {},

}
return new Response(typeof error.cause === 'string' ? error.cause : error.message);
return new Response(typeof error.cause === 'string' ? error.cause : error.message, {
status: (0, error_1.mapErrorStatus)((0, error_1.mapErrorCode)(error.message))
});
}

@@ -834,0 +836,0 @@ /**

@@ -48,2 +48,3 @@ "use strict";

let paths = url.slice(queryIndex);
// eslint-disable-next-line no-constant-condition
while (true) {

@@ -50,0 +51,0 @@ // Skip ?/&, and min length of query is 3, so start looking at 1 + 3

import type { ErrorCode } from './types';
export declare const mapErrorCode: (error: string) => ErrorCode;
export declare const mapErrorStatus: (error: string) => number;

@@ -1,8 +0,7 @@

const knownErrors = new Set([
'BODY_LIMIT',
'BODY_LIMIT',
'INTERNAL_SERVER_ERROR',
'NOT_FOUND',
'VALIDATION'
]);
const errorCodeToStatus = new Map();
errorCodeToStatus.set('INTERNAL_SERVER_ERROR', 500);
errorCodeToStatus.set('NOT_FOUND', 404);
errorCodeToStatus.set('VALIDATION', 400);
const knownErrors = new Set(errorCodeToStatus.keys());
export const mapErrorCode = (error) => knownErrors.has(error) ? error : 'UNKNOWN';
export const mapErrorStatus = (error) => errorCodeToStatus.get(error) ?? 500;

@@ -539,3 +539,3 @@ /// <reference types="bun-types" />

handle(request: Request): Promise<Response>;
private handleError;
handleError(error: Error): Response;
/**

@@ -542,0 +542,0 @@ * ### listen

@@ -5,3 +5,3 @@ import { Router } from './router';

import { registerSchemaPath } from './schema';
import { mapErrorCode } from './error';
import { mapErrorCode, mapErrorStatus } from './error';
/**

@@ -737,3 +737,3 @@ * ### Elysia Server

let body;
if (request.method !== 'GET') {
if (request.method !== 'GET' && request.method !== 'HEAD') {
const contentType = request.headers.get('content-type') ?? '';

@@ -751,3 +751,3 @@ if (contentType !== '')

}
let context = {
const context = {
request,

@@ -829,3 +829,5 @@ params: route?.params ?? {},

}
return new Response(typeof error.cause === 'string' ? error.cause : error.message);
return new Response(typeof error.cause === 'string' ? error.cause : error.message, {
status: mapErrorStatus(mapErrorCode(error.message))
});
}

@@ -832,0 +834,0 @@ /**

@@ -25,3 +25,3 @@ /// <reference types="bun-types" />

export type LifeCycleEvent = 'start' | 'request' | 'parse' | 'transform' | 'beforeHandle' | 'afterHandle' | 'error' | 'stop';
export type ListenCallback<Instance extends ElysiaInstance = ElysiaInstance> = ((server: Server) => void) | ((server: Server) => Promise<void>);
export type ListenCallback = ((server: Server) => void) | ((server: Server) => Promise<void>);
export type VoidLifeCycle<Instance extends ElysiaInstance = ElysiaInstance> = ((app: Elysia<Instance>) => void) | ((app: Elysia<Instance>) => Promise<void>);

@@ -158,3 +158,3 @@ export type BodyParser = (request: Request, contentType: string) => any | Promise<any>;

export type HTTPMethod = 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' | 'M-SEARCH' | 'MERGE' | 'MKACTIVITY' | 'MKCALENDAR' | 'MKCOL' | 'MOVE' | 'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE' | 'ALL';
export type ErrorCode = 'NOT_FOUND' | 'INTERNAL_SERVER_ERROR' | 'BODY_LIMIT' | 'VALIDATION' | 'UNKNOWN';
export type ErrorCode = 'NOT_FOUND' | 'INTERNAL_SERVER_ERROR' | 'VALIDATION' | 'UNKNOWN';
export type ErrorHandler = (code: ErrorCode, error: Error) => void | Response;

@@ -161,0 +161,0 @@ type Head<T> = T extends [infer I, ...infer _Rest] ? I : never;

@@ -41,2 +41,3 @@ import { TypeCompiler } from '@sinclair/typebox/compiler';

let paths = url.slice(queryIndex);
// eslint-disable-next-line no-constant-condition
while (true) {

@@ -43,0 +44,0 @@ // Skip ?/&, and min length of query is 3, so start looking at 1 + 3

{
"name": "elysia",
"description": "Fast, and friendly Bun web framework",
"version": "0.1.0-rc.1",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
"email": "saltyaom@gmail.com"
},
"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",
"type": "module",
"scripts": {
"test": "bun wiptest",
"dev": "bun run --hot example/http.ts",
"build": "rimraf dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"release": "npm run build && npm run test && npm publish"
},
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/index.js",
"node": "./dist/index.js",
"default": "./dist/index.js"
},
"types": "./dist/index.d.ts",
"dependencies": {
"@sinclair/typebox": "0.25.10"
},
"devDependencies": {
"@types/node": "^18.11.10",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"bun-types": "^0.2.2",
"eslint": "^8.29.0",
"rimraf": "^3.0.2",
"typescript": "^4.9.3"
}
"name": "elysia",
"description": "Fast, and friendly Bun web framework",
"version": "0.1.0-rc.2",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
"email": "saltyaom@gmail.com"
},
"main": "./dist/index.js",
"exports": {
"require": "./dist/cjs/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 && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"release": "npm run build && npm run test && npm publish"
},
"dependencies": {
"@sinclair/typebox": "0.25.10"
},
"devDependencies": {
"@types/node": "^18.11.10",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"bun-types": "^0.3.0",
"eslint": "^8.29.0",
"rimraf": "^3.0.2",
"typescript": "^4.9.3"
}
}
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