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

@curveball/core

Package Overview
Dependencies
Maintainers
3
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@curveball/core - npm Package Compare versions

Comparing version 0.15.0 to 0.16.0-beta.0

src/.conditional.ts.swp

9

changelog.md
Changelog
=========
0.16.0-beta.0 (2021-01-10)
--------------------------
* BC Break: `Request.body` is now typed as `unknown` instead of `any`. This
forces users to either validate the body, or cast to `any`.
* It's now possible to write directly to response streams by setting
response.body to a callback.
0.15.0 (2020-12-05)

@@ -5,0 +14,0 @@ -------------------

2

dist/base-context.d.ts

@@ -33,3 +33,3 @@ import { Middleware } from './application';

};
constructor(req: Request, res: Response);
constructor(req: Request<ReqT>, res: Response<ResT>);
/**

@@ -36,0 +36,0 @@ * The Request path.

@@ -6,3 +6,3 @@ import { Middleware } from './application';

import * as WebSocket from 'ws';
export interface Context<ReqT = any, ResT = any> {
export interface Context<ReqT = unknown, ResT = any> {
/**

@@ -110,3 +110,3 @@ * HTTP Request

*/
export interface WsContext extends Context<any, any> {
export interface WsContext extends Context<unknown, any> {
/**

@@ -113,0 +113,0 @@ * WebSocket object.

/// <reference types="node" />
import { Readable } from 'stream';
import { HeadersInterface, HeadersObject } from './headers';
import Request from './request';
import { Request, Encoding } from './request';
export declare class MemoryRequest<T> extends Request<T> {

@@ -35,3 +35,3 @@ /**

*/
rawBody(encoding?: string, limit?: string): Promise<string>;
rawBody(encoding?: Encoding, limit?: string): Promise<string>;
rawBody(encoding?: undefined, limit?: string): Promise<Buffer>;

@@ -38,0 +38,0 @@ /**

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

const request_1 = require("./request");
class MemoryRequest extends request_1.default {
class MemoryRequest extends request_1.Request {
constructor(method, requestTarget, headers, body = null) {

@@ -10,0 +10,0 @@ super(method, requestTarget);

import { Headers } from './headers';
import Response from './response';
export declare class MemoryResponse<T> extends Response<T> {
import { Response, Body } from './response';
export declare class MemoryResponse<T = Body> extends Response<T> {
constructor();

@@ -5,0 +5,0 @@ /**

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

const response_1 = require("./response");
class MemoryResponse extends response_1.default {
class MemoryResponse extends response_1.Response {
constructor() {

@@ -9,0 +9,0 @@ super();

/// <reference types="node" />
import * as http from 'http';
import * as http2 from 'http2';
import { Body } from '../response';
/**

@@ -16,3 +17,3 @@ * A node.js Http request

export declare function isHttp2Response(response: NodeHttpResponse): response is http2.Http2ServerResponse;
export declare function sendBody(res: NodeHttpResponse | http2.Http2Stream, body: Buffer | Record<string, any> | string | null): void;
export declare function sendBody(res: NodeHttpResponse | http2.Http2Stream, body: Body): void;
/**

@@ -19,0 +20,0 @@ * The HttpCallback is the function that is passed as a request listener to

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

else if (body instanceof stream_1.Readable) {
// @ts-expect-error - not sure why this line fails
body.pipe(res);

@@ -31,2 +30,5 @@ }

}
else if (typeof body === 'function') {
body(res);
}
else {

@@ -33,0 +35,0 @@ throw new TypeError('Unsupported type for body: ' + typeof body);

/// <reference types="node" />
import { Readable } from 'stream';
import { HeadersInterface } from './headers';
export declare type Encoding = 'utf-8' | 'ascii' | 'hex';
/**
* This interface represents an incoming server request.
*/
export declare abstract class Request<T = any> {
export declare abstract class Request<T = unknown> {
constructor(method: string, requestTarget: string);

@@ -67,3 +68,3 @@ /**

*/
abstract rawBody(encoding: string, limit?: string): Promise<string>;
abstract rawBody(encoding: Encoding, limit?: string): Promise<string>;
abstract rawBody(encoding?: undefined, limit?: string): Promise<Buffer>;

@@ -70,0 +71,0 @@ /**

@@ -0,7 +1,10 @@

/// <reference types="node" />
import { Middleware } from './application';
import { HeadersInterface, HeadersObject } from './headers';
import { Readable, Writable } from 'stream';
export declare type Body = Buffer | Record<string, any> | string | null | Readable | ((writeable: Writable) => void);
/**
* This interface represents an incoming server request.
*/
export declare abstract class Response<T = any> {
export declare abstract class Response<T = Body> {
constructor();

@@ -8,0 +11,0 @@ /**

{
"name": "@curveball/core",
"version": "0.15.0",
"version": "0.16.0-beta.0",
"description": "Curveball is a framework writting in Typescript for Node.js",

@@ -39,16 +39,16 @@ "main": "dist/index.js",

"@types/co-body": "^5.1.0",
"@types/mocha": "^8.0.4",
"@types/node": "^12.19.8",
"@types/mocha": "^8.2.0",
"@types/node": "^12.19.12",
"@types/node-fetch": "^2.5.7",
"@types/sinon": "^9.0.9",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"@types/sinon": "^9.0.10",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"chai": "^4.2.0",
"eslint": "^7.15.0",
"eslint": "^7.17.0",
"mocha": "^8.2.1",
"node-fetch": "^2.6.1",
"nyc": "^15.1.0",
"sinon": "^9.2.1",
"ts-node": "^9.1.0",
"typescript": "^4.1.2"
"sinon": "^9.2.3",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
},

@@ -66,3 +66,3 @@ "types": "dist/",

"raw-body": "^2.4.1",
"ws": "^7.4.1"
"ws": "^7.4.2"
},

@@ -69,0 +69,0 @@ "engines": {

@@ -38,3 +38,3 @@ import { Middleware } from './application';

constructor(req: Request, res: Response) {
constructor(req: Request<ReqT>, res: Response<ResT>) {

@@ -41,0 +41,0 @@ this.request = req;

@@ -7,3 +7,3 @@ import { Middleware } from './application';

export interface Context<ReqT = any, ResT = any> {
export interface Context<ReqT = unknown, ResT = any> {

@@ -123,3 +123,3 @@ /**

*/
export interface WsContext extends Context<any, any> {
export interface WsContext extends Context<unknown, any> {

@@ -126,0 +126,0 @@ /**

import { Readable } from 'stream';
import { Headers, HeadersInterface, HeadersObject } from './headers';
import Request from './request';
import { Request, Encoding } from './request';

@@ -53,5 +53,5 @@ export class MemoryRequest<T> extends Request<T> {

*/
rawBody(encoding?: string, limit?: string): Promise<string>;
rawBody(encoding?: Encoding, limit?: string): Promise<string>;
rawBody(encoding?: undefined, limit?: string): Promise<Buffer>;
async rawBody(encoding?: undefined|string, limit?: string): Promise<Buffer|string> {
async rawBody(encoding?: undefined|Encoding, limit?: string): Promise<Buffer|string> {

@@ -76,3 +76,3 @@ return this.getBody(encoding);

private getBody(encoding?: string) {
private getBody(encoding?: Encoding) {

@@ -79,0 +79,0 @@ if (!this.originalBody) {

import { Headers } from './headers';
import Response from './response';
import { Response, Body } from './response';
export class MemoryResponse<T> extends Response<T> {
export class MemoryResponse<T = Body> extends Response<T> {

@@ -6,0 +6,0 @@ constructor() {

import * as http from 'http';
import * as http2 from 'http2';
import { Readable } from 'stream';
import { Readable, Writable } from 'stream';
import { Body } from '../response';

@@ -24,3 +25,3 @@ /**

export function sendBody(res: NodeHttpResponse | http2.Http2Stream, body: Buffer | Record<string, any> | string | null) {
export function sendBody(res: NodeHttpResponse | http2.Http2Stream, body: Body): void {

@@ -35,6 +36,7 @@ if (body === null) {

} else if (body instanceof Readable) {
// @ts-expect-error - not sure why this line fails
body.pipe(res);
body.pipe(res as Writable);
} else if (typeof body === 'object') {
res.end(JSON.stringify(body));
} else if (typeof body === 'function') {
body(res as Writable);
} else {

@@ -41,0 +43,0 @@ throw new TypeError('Unsupported type for body: ' + typeof body);

@@ -9,6 +9,8 @@ import * as accepts from 'accepts';

export type Encoding = 'utf-8' | 'ascii' | 'hex';
/**
* This interface represents an incoming server request.
*/
export abstract class Request<T = any> {
export abstract class Request<T = unknown> {

@@ -93,3 +95,3 @@ constructor(method: string, requestTarget: string) {

*/
abstract rawBody(encoding: string, limit?: string): Promise<string>;
abstract rawBody(encoding: Encoding, limit?: string): Promise<string>;
abstract rawBody(encoding?: undefined, limit?: string): Promise<Buffer>;

@@ -96,0 +98,0 @@

@@ -5,7 +5,17 @@ import { Middleware } from './application';

import { Headers } from './headers';
import { Readable, Writable } from 'stream';
export type Body =
Buffer |
Record<string, any> |
string |
null |
Readable |
((writeable: Writable) => void);
/**
* This interface represents an incoming server request.
*/
export abstract class Response<T = any> {
export abstract class Response<T = Body> {

@@ -12,0 +22,0 @@ constructor() {

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

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