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

@eventual/core

Package Overview
Dependencies
Maintainers
2
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eventual/core - npm Package Compare versions

Comparing version 0.13.0 to 0.13.1

14

lib/cjs/api.d.ts
/// <reference types="node" />
export declare const api: Router;
export type RouteHandler = (request: ApiRequest, ...args: any) => ApiResponse | Promise<ApiResponse>;
export interface ApiRequest {
export interface ApiRequestInit {
method: string;
headers?: Record<string, string>;
body?: string | Buffer;
params?: Record<string, string>;
query?: Record<string, string | string[]>;
}
export declare class ApiRequest {
private props;
url: string;

@@ -11,7 +19,5 @@ method: string;

query?: Record<string, string | string[]>;
constructor(url: string, props: ApiRequestInit);
json(): Promise<any>;
text(): Promise<any>;
arrayBuffer?(): Promise<any>;
blob?(): Promise<any>;
formData?(): Promise<any>;
}

@@ -18,0 +24,0 @@ export interface ApiResponse {

@@ -6,5 +6,43 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.api = void 0;
exports.ApiRequest = exports.api = void 0;
const itty_router_1 = __importDefault(require("itty-router"));
exports.api = itty_router_1.default.Router();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSw4REFBK0I7QUFFbEIsUUFBQSxHQUFHLEdBQVcscUJBQUksQ0FBQyxNQUFNLEVBQW1CLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgaXR0eSBmcm9tIFwiaXR0eS1yb3V0ZXJcIjtcblxuZXhwb3J0IGNvbnN0IGFwaTogUm91dGVyID0gaXR0eS5Sb3V0ZXIoKSBhcyBhbnkgYXMgUm91dGVyO1xuXG5leHBvcnQ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dGU7XG59XG5cbmV4cG9ydCB0eXBlIFJvdXRlRW50cnkgPSBbc3RyaW5nLCBSZWdFeHAsIFJvdXRlSGFuZGxlcl07XG4iXX0=
class ApiRequest {
constructor(url, props) {
this.props = props;
const _url = new URL(url);
this.method = props.method;
this.headers = props.headers ?? {};
this.body = props.body;
if (props.query) {
this.query = props.query;
}
else {
const query = {};
_url.searchParams.forEach((value, key) => {
query[key] = value.includes(",") ? value.split(",") : value;
});
this.query = query;
}
this.params = props.params;
this.url = _url.href;
}
async json() {
return JSON.parse(await this.text());
}
async text() {
if (this.props.body === undefined) {
return "";
}
else if (typeof this.props.body === "string") {
return JSON.parse(this.props.body);
}
else {
// TODO: is this risky? Should we just fail whenever it's a base64 encoded buffer?
// Or ... is this the best way to best-effort parse a buffer as JSON?
return JSON.parse(this.props.body.toString("utf-8"));
}
}
}
exports.ApiRequest = ApiRequest;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSw4REFBK0I7QUFFbEIsUUFBQSxHQUFHLEdBQVcscUJBQUksQ0FBQyxNQUFNLEVBQW1CLENBQUM7QUFlMUQsTUFBYSxVQUFVO0lBUXJCLFlBQVksR0FBVyxFQUFVLEtBQXFCO1FBQXJCLFVBQUssR0FBTCxLQUFLLENBQWdCO1FBQ3BELE1BQU0sSUFBSSxHQUFHLElBQUksR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBQzFCLElBQUksQ0FBQyxNQUFNLEdBQUcsS0FBSyxDQUFDLE1BQU0sQ0FBQztRQUMzQixJQUFJLENBQUMsT0FBTyxHQUFHLEtBQUssQ0FBQyxPQUFPLElBQUksRUFBRSxDQUFDO1FBQ25DLElBQUksQ0FBQyxJQUFJLEdBQUcsS0FBSyxDQUF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9pZDtcbiAgZ2V0KG5hbWU6IHN0cmluZyk6IHN0cmluZyB8IG51bGw7XG4gIGhhcyhuYW1lOiBzdHJpbmcpOiBib29sZWFuO1xuICBzZXQobmFtZTogc3RyaW5nLCB2YWx1ZTogc3RyaW5nKTogdm9pZDtcbiAgZm9yRWFjaChcbiAgICBjYWxsYmFja2ZuOiAodmFsdWU6IHN0cmluZywga2V5OiBzdHJpbmcsIHBhcmVudDogSGVhZGVycykgPT4gdm9pZCxcbiAgICB0aGlzQXJnPzogYW55XG4gICk6IHZvaWQ7XG59XG5cbmV4cG9ydCB0eXBlIFJvdXRlID0gKHBhdGg6IHN0cmluZywgLi4uaGFuZGxlcnM6IFJvdXRlSGFuZGxlcltdKSA9PiBSb3V0ZXI7XG5cbmV4cG9ydCBpbnRlcmZhY2UgUm91dGVyIHtcbiAgaGFuZGxlOiAocmVxdWVzdDogQXBpUmVxdWVzdCwgLi4uZXh0cmE6IGFueSkgPT4gUHJvbWlzZTxBcGlSZXNwb25zZT47XG4gIHJvdXRlczogUm91dGVFbnRyeVtdO1xuICBhbGw6IFJvdXRlO1xuICBnZXQ6IFJvdXRlO1xuICBoZWFkOiBSb3V0ZTtcbiAgcG9zdDogUm91dGU7XG4gIHB1dDogUm91dGU7XG4gIGRlbGV0ZTogUm91dGU7XG4gIGNvbm5lY3Q6IFJvdXRlO1xuICBvcHRpb25zOiBSb3V0ZTtcbiAgdHJhY2U6IFJvdXRlO1xuICBwYXRjaDogUm91dGU7XG59XG5cbmV4cG9ydCB0eXBlIFJvdXRlRW50cnkgPSBbc3RyaW5nLCBSZWdFeHAsIFJvdXRlSGFuZGxlcl07XG4iXX0=
/// <reference types="node" resolution-mode="require"/>
export declare const api: Router;
export type RouteHandler = (request: ApiRequest, ...args: any) => ApiResponse | Promise<ApiResponse>;
export interface ApiRequest {
export interface ApiRequestInit {
method: string;
headers?: Record<string, string>;
body?: string | Buffer;
params?: Record<string, string>;
query?: Record<string, string | string[]>;
}
export declare class ApiRequest {
private props;
url: string;

@@ -11,7 +19,5 @@ method: string;

query?: Record<string, string | string[]>;
constructor(url: string, props: ApiRequestInit);
json(): Promise<any>;
text(): Promise<any>;
arrayBuffer?(): Promise<any>;
blob?(): Promise<any>;
formData?(): Promise<any>;
}

@@ -18,0 +24,0 @@ export interface ApiResponse {

import itty from "itty-router";
export const api = itty.Router();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLElBQUksTUFBTSxhQUFhLENBQUM7QUFFL0IsTUFBTSxDQUFDLE1BQU0sR0FBRyxHQUFXLElBQUksQ0FBQyxNQUFNLEVBQW1CLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgaXR0eSBmcm9tIFwiaXR0eS1yb3V0ZXJcIjtcblxuZXhwb3J0IGNvbnN0IGFwaTogUm91dGVyID0gaXR0eS5Sb3V0ZXIoKSBhcyBhbnkgYXMgUm91dGVyO1xuXG5leHBvcnQgdHlwZSBSb3V0ZUhhbmRsZXIgPSAoXG4gIHJlcXVlc3Q6IEFwaVJlcXVlc3QsXG4gIC4uLmFyZ3M6IGFueVxuKSA9PiBBcGlSZXNwb25zZSB8IFByb21pc2U8QXBpUmVzcG9uc2U+O1xuXG5leHBvcnQgaW50ZXJmYWNlIEFwaVJlcXVlc3Qge1xuICB1cmw6IHN0cmluZztcbiAgbWV0aG9kOiBzdHJpbmc7XG4gIGhlYWRlcnM6IFJlY29yZDxzdHJpbmcsIHN0cmluZz47XG4gIGJvZHk6IHN0cmluZyB8IEJ1ZmZlciB8IHVuZGVmaW5lZDtcbiAgcGFyYW1zPzogUmVjb3JkPHN0cmluZywgc3RyaW5nPjtcbiAgcXVlcnk/OiBSZWNvcmQ8c3RyaW5nLCBzdHJpbmcgfCBzdHJpb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WFjaChcbiAgICBjYWxsYmFja2ZuOiAodmFsdWU6IHN0cmluZywga2V5OiBzdHJpbmcsIHBhcmVudDogSGVhZGVycykgPT4gdm9pZCxcbiAgICB0aGlzQXJnPzogYW55XG4gICk6IHZvaWQ7XG59XG5cbmV4cG9ydCB0eXBlIFJvdXRlID0gKHBhdGg6IHN0cmluZywgLi4uaGFuZGxlcnM6IFJvdXRlSGFuZGxlcltdKSA9PiBSb3V0ZXI7XG5cbmV4cG9ydCBpbnRlcmZhY2UgUm91dGVyIHtcbiAgaGFuZGxlOiAocmVxdWVzdDogQXBpUmVxdWVzdCwgLi4uZXh0cmE6IGFueSkgPT4gUHJvbWlzZTxBcGlSZXNwb25zZT47XG4gIHJvdXRlczogUm91dGVFbnRyeVtdO1xuICBhbGw6IFJvdXRlO1xuICBnZXQ6IFJvdXRlO1xuICBoZWFkOiBSb3V0ZTtcbiAgcG9zdDogUm91dGU7XG4gIHB1dDogUm91dGU7XG4gIGRlbGV0ZTogUm91dGU7XG4gIGNvbm5lY3Q6IFJvdXRlO1xuICBvcHRpb25zOiBSb3V0ZTtcbiAgdHJhY2U6IFJvdXRlO1xuICBwYXRjaDogUm91dGU7XG59XG5cbmV4cG9ydCB0eXBlIFJvdXRlRW50cnkgPSBbc3RyaW5nLCBSZWdFeHAsIFJvdXRlSGFuZGxlcl07XG4iXX0=
export class ApiRequest {
constructor(url, props) {
this.props = props;
const _url = new URL(url);
this.method = props.method;
this.headers = props.headers ?? {};
this.body = props.body;
if (props.query) {
this.query = props.query;
}
else {
const query = {};
_url.searchParams.forEach((value, key) => {
query[key] = value.includes(",") ? value.split(",") : value;
});
this.query = query;
}
this.params = props.params;
this.url = _url.href;
}
async json() {
return JSON.parse(await this.text());
}
async text() {
if (this.props.body === undefined) {
return "";
}
else if (typeof this.props.body === "string") {
return JSON.parse(this.props.body);
}
else {
// TODO: is this risky? Should we just fail whenever it's a base64 encoded buffer?
// Or ... is this the best way to best-effort parse a buffer as JSON?
return JSON.parse(this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SkgPT4gUm91dGVyO1xuXG5leHBvcnQgaW50ZXJmYWNlIFJvdXRlciB7XG4gIGhhbmRsZTogKHJlcXVlc3Q6IEFwaVJlcXVlc3QsIC4uLmV4dHJhOiBhbnkpID0+IFByb21pc2U8QXBpUmVzcG9uc2U+O1xuICByb3V0ZXM6IFJvdXRlRW50cnlbXTtcbiAgYWxsOiBSb3V0ZTtcbiAgZ2V0OiBSb3V0ZTtcbiAgaGVhZDogUm91dGU7XG4gIHBvc3Q6IFJvdXRlO1xuICBwdXQ6IFJvdXRlO1xuICBkZWxldGU6IFJvdXRlO1xuICBjb25uZWN0OiBSb3V0ZTtcbiAgb3B0aW9uczogUm91dGU7XG4gIHRyYWNlOiBSb3V0ZTtcbiAgcGF0Y2g6IFJvdXRlO1xufVxuXG5leHBvcnQgdHlwZSBSb3V0ZUVudHJ5ID0gW3N0cmluZywgUmVnRXhwLCBSb3V0ZUhhbmRsZXJdO1xuIl19
{
"name": "@eventual/core",
"version": "0.13.0",
"version": "0.13.1",
"exports": {

@@ -5,0 +5,0 @@ ".": {

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 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