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

@curveball/core

Package Overview
Dependencies
Maintainers
4
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.20.0 to 0.21.0

cjs/application.d.ts

92

changelog.md
Changelog
=========
0.21.0 (2023-02-14)
-------------------
* ESM support.
* Dropped Node 14 support. Use Node 16 or later.
0.20.0 (2022-09-03)
------------------
-------------------
* Most of the internal plumbing has moved to `@curveball/kernel`.
`@curveball/core` still contains all of the Node-specific code, but
this allows curveball to run on Bun.
`@curveball/core` still contains all of the Node-specific code, but this
allows curveball to run on Bun.

@@ -15,4 +22,4 @@

* Added support for `fetch()`, which lets you make requests in an a
Curveball application using the native `Request` and `Response` objects.
* Added support for `fetch()`, which lets you make requests in an a Curveball
application using the native `Request` and `Response` objects.

@@ -26,13 +33,13 @@

property. This defaults defaults to `http://localhost`. This can be
overridden by setting `Application.origin`, or setting a
`CURVEBALL_ORIGIN` environment variable. `PUBLIC_URI` also works, but
it's mainly a fallback for earlier examples and recommendations.
* `Request` and `Context` now have a `absoluteUrl` property. This is
calculated based on the request path and the `origin`.
* BC Break: Due to the new `origin` property, all `Request` and
`Response` classes now have an extra constructor argument. This means
if you ever manually constructed any of these, there's a small change
you'll need to make. Typescript should point all these problems!
* If `CURVEBALL_TRUSTPROXY` is set, `request.ip()` will trust proxies
by default, and return the ip of the real client instead of the proxy.
overridden by setting `Application.origin`, or setting a `CURVEBALL_ORIGIN`
environment variable. `PUBLIC_URI` also works, but it's mainly a fallback for
earlier examples and recommendations.
* `Request` and `Context` now have a `absoluteUrl` property. This is calculated
based on the request path and the `origin`.
* BC Break: Due to the new `origin` property, all `Request` and `Response`
classes now have an extra constructor argument. This means if you ever
manually constructed any of these, there's a small change you'll need to
make. Typescript should point all these problems!
* If `CURVEBALL_TRUSTPROXY` is set, `request.ip()` will trust proxies by
default, and return the ip of the real client instead of the proxy.

@@ -46,15 +53,16 @@

0.18.0.alpha.0 (2022-04-09)
0.18.0-alpha.0 (2022-04-09)
---------------------------
* The `Context` interface has been removed, and the `BaseContext` class is
renamed to `Context`. This is a BC break, but should only be an issue if
you used the `Context` interface directly. `BaseContext` is still
exported but simply aliased to `Context`. This alias will be removed from
a future version. This change should make ite asier to use interface
declaration merging to extend Context.
renamed to `Context`. This is a BC break, but should only be an issue if you
used the `Context` interface directly. `BaseContext` is still exported but
simply aliased to `Context`. This alias will be removed from a future
version. This change should make ite asier to use interface declaration
merging to extend Context.
* The `ws` dependency has been updated to version 8. There are some [breaking
changes][ws8] in this release. The most likely you'll hit is that incoming
messages are now of type `Buffer` instead of `string`. Check out the
[ws changelog][ws8] for more details.
messages are now of type `Buffer` instead of `string`. Check out the [ws
changelog][ws8] for more details.

@@ -71,2 +79,3 @@

0.16.4 (2022-01-05)

@@ -86,2 +95,3 @@ -------------------

0.16.2 (2021-02-18)

@@ -96,4 +106,4 @@ -------------------

* Request.body is no longer optional, which will help with typing. It can
still be explicitly set to `null`.
* Request.body is no longer optional, which will help with typing. It can still
be explicitly set to `null`.

@@ -127,7 +137,8 @@

* #155 - `listen` and `listenWs` now both have a second `host` argument to
bind to a specific interface. (@Nicholaiii)
* #145 - `request.headers` and `response.headers` now have a `getMany()`
function to get a list of header values for a given header name. (@Nicholaiii)
bind to a specific interface. (@Nicholaiii) function to get a list of header
values for a given header name. (@Nicholaiii)
0.14.2 (2020-07-14)

@@ -144,2 +155,3 @@ -------------------

0.14.0 (2020-07-13)

@@ -225,4 +237,4 @@ -------------------

* The server now sets a `application/hal+json` content-type if nothing else
was set. This fixes a regression from 0.9.0.
* The server now sets a `application/hal+json` content-type if nothing else was
set. This fixes a regression from 0.9.0.

@@ -263,4 +275,4 @@

* Now exporting an `invokeMiddleware` function that can be used to
chain and call mutltiple middlewares.
* Now exporting an `invokeMiddleware` function that can be used to chain and
call mutltiple middlewares.
* Application will now by default throw a `NotFound` exception if nothing

@@ -304,5 +316,5 @@ handled a HTTP request.

* #74: Added `method`, `path`, `status`, `accepts`, `push`, `sendInformational`,
and `query` to Context object. These properties and methods all forward to
the request or response object.
* #74: Added `method`, `path`, `status`, `accepts`, `push`,
`sendInformational`, and `query` to Context object. These properties and
methods all forward to the request or response object.
* #78: By default the Application will return with a `404` response, unless a

@@ -338,4 +350,4 @@ middleware updates the status or a body was set.

* #4: Support for HTTP/2 push via the `Response.push()` method.
* #62: It's now possible to do internal sub-requests without going through
the HTTP stack, with `Application.subRequest()`.
* #62: It's now possible to do internal sub-requests without going through the
HTTP stack, with `Application.subRequest()`.
* Added `MemoryRequest` and `MemoryResponse`.

@@ -347,3 +359,3 @@ * #56: `Response.body` may now be `null`.

0.3.1 (2018-06-29)
-----------------
------------------

@@ -358,4 +370,4 @@ * Added License, Code of Conduct.

* #5: Support for informational status codes such as `100 Continue` and
`103 Early Hints` for both HTTP/1 and HTTP/2.
* #5: Support for informational status codes such as `100 Continue` and `103
Early Hints` for both HTTP/1 and HTTP/2.
* #28: HTTP2 support.

@@ -362,0 +374,0 @@ * #34: `Application` is now the default export.

{
"name": "@curveball/core",
"version": "0.20.0",
"version": "0.21.0",
"description": "Curveball is a framework writting in Typescript for Node.js",
"main": "dist/index.js",
"scripts": {
"prepublishOnly": "make build",
"test": "make test",
"lint": "make lint",
"tsc": "tsc"
"type": "module",
"exports": {
"require": "./cjs/index.js",
"import": "./esm/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/curveball/core.git"
"main": "cjs/index.js",
"homepage": "https://github.com/curveball/core#readme",
"bugs": {
"url": "https://github.com/curveball/core/issues"
},
"files": [
"package.json",
"README.md",
"dist",
"LICENSE",
"src"
],
"keywords": [

@@ -32,11 +24,29 @@ "http",

"license": "MIT",
"bugs": {
"url": "https://github.com/curveball/core/issues"
"scripts": {
"prepublishOnly": "make build",
"test": "make test",
"lint": "make lint",
"fix": "make fix",
"tsc": "tsc",
"start": "make start"
},
"homepage": "https://github.com/curveball/core#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/curveball/core.git"
},
"dependencies": {
"@curveball/kernel": ">=0.21.0 <1",
"@types/ws": "^8.5.3",
"raw-body": "^2.4.1",
"ws": "^8.5.0"
},
"peerDependencies": {
"@curveball/kernel": ">=0.21.0 <1"
},
"devDependencies": {
"@curveball/http-errors": "^0.5.0",
"@types/chai": "^4.2.15",
"@types/co-body": "^6.1.0",
"@types/mocha": "^9.0.0",
"@types/node": "^14.18.14",
"@types/mocha": "^10.0.1",
"@types/node": "^16.18.12",
"@types/node-fetch": "^2.5.8",

@@ -48,27 +58,27 @@ "@types/sinon": "^10.0.6",

"eslint": "^8.6.0",
"mocha": "^9.1.3",
"node-fetch": "^2.6.1",
"mocha": "^10.2.0",
"node-fetch": "^3.3.0",
"nyc": "^15.1.0",
"sinon": "^13.0.1",
"sinon": "^15.0.1",
"ts-node": "^10.4.0",
"typescript": "^4.1.5"
},
"types": "dist/",
"nyc": {
"extension": [
".ts"
]
},
"dependencies": {
"@curveball/http-errors": "^0.4.0",
"@curveball/kernel": "^0.20.0",
"@types/ws": "^8.5.3",
"raw-body": "^2.4.1",
"ws": "^8.5.0"
},
"engines": {
"node": ">=14.4"
},
"files": [
"package.json",
"README.md",
"esm",
"cjs",
"LICENSE",
"src"
],
"mocha": {
"require": "ts-node/register",
"require": [
"./test/polyfills.mjs"
],
"loader": [
"ts-node/esm"
],
"recursive": true,

@@ -80,3 +90,8 @@ "extension": [

]
},
"nyc": {
"extension": [
".ts"
]
}
}

@@ -13,2 +13,3 @@ Curveball

* Async/await-based middleware.
* Support for Node, [Bun](#Bun%20support), AWS Lambda, Azure functions.
* Native support for HTTP/2, including easy access to HTTP/2 Push.

@@ -88,2 +89,25 @@ * Native, deeply integrated Websocket.

Bun support
-----------
To use Curveball with [Bun](https://bun.sh/), use the kernel package:
```typescript
import { Application } from '@curveball/kernel';
const app = new Application();
// Add all your middlewares here!
app.use( ctx => {
ctx.response.body = {msg: 'hello world!'};
});
export default {
port: 3000,
fetch: app.fetch.bind(app)
};
```
Some more details can be found in this [article](https://evertpot.com/bun-curveball-framework/).
Doing internal subrequests

@@ -410,1 +434,4 @@ --------------------------

[controller]: https://github.com/curveball/controller
[bun]: https://github.com/curveball/bun
[lambda]: https://github.com/curveball/bun

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

import * as http from 'http';
import * as WebSocket from 'ws';
import * as net from 'net';
import * as http from 'node:http';
import { WebSocket, WebSocketServer } from 'ws';
import * as net from 'node:net';

@@ -10,5 +10,5 @@ import {

nodeHttpServerCallback,
} from './node/http-utils';
import NodeRequest from './node/request';
import NodeResponse from './node/response';
} from './node/http-utils.js';
import NodeRequest from './node/request.js';
import NodeResponse from './node/response.js';

@@ -26,3 +26,3 @@ import {

private wss: WebSocket.Server | undefined;
private wss: WebSocketServer | undefined;

@@ -47,5 +47,5 @@ /**

*/
listenWs(port: number, host?: string): WebSocket.Server {
listenWs(port: number, host?: string): WebSocketServer {
const wss = new WebSocket.Server({
const wss = new WebSocketServer({
port,

@@ -88,3 +88,3 @@ host

// We don't have an existing Websocket server. Lets make one.
this.wss = new WebSocket.Server({ noServer: true });
this.wss = new WebSocketServer({ noServer: true });
this.wss.on('connection', async(ws, req) => {

@@ -91,0 +91,0 @@ const request = new NodeRequest(req, this.origin);

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

import Application from './application';
import Application from './application.js';

@@ -3,0 +3,0 @@ export default Application;

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

import * as http from 'http';
import * as http2 from 'http2';
import { Readable, Writable } from 'stream';
import { NodeRequest as CurveballNodeRequest } from './request';
import { NodeResponse as CurveballNodeResponse } from './response';
import * as http from 'node:http';
import * as http2 from 'node:http2';
import { Readable, Writable } from 'node:stream';
import { NodeRequest as CurveballNodeRequest } from './request.js';
import { NodeResponse as CurveballNodeResponse } from './response.js';
import { isHttpError } from '@curveball/http-errors';

@@ -7,0 +7,0 @@ import {

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

import * as http2 from 'http2';
import * as http2 from 'node:http2';
import { Context } from '@curveball/kernel';
import { sendBody } from './http-utils';
import { sendBody } from './http-utils.js';

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

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

import * as rawBody from 'raw-body';
import { Readable } from 'stream';
import * as ImpRawBody from 'raw-body';
import { Readable } from 'node:stream';

@@ -10,2 +10,5 @@ import {

// @ts-expect-error ESM / CommonJS interop weirdness.
const rawBody = ImpRawBody.default ?? ImpRawBody;
export class NodeRequest<T> extends Request<T> {

@@ -12,0 +15,0 @@

import { HeadersInterface, HeadersObject } from '@curveball/kernel';
import { NodeHttpResponse } from './http-utils';
import { NodeHttpResponse } from './http-utils.js';

@@ -4,0 +4,0 @@ /**

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

import * as http from 'http';
import { promisify } from 'util';
import { isHttp2Response, NodeHttpResponse } from './http-utils';
import push from './push';
import NodeHeaders from './response-headers';
import * as http from 'node:http';
import { promisify } from 'node:util';
import { isHttp2Response, NodeHttpResponse } from './http-utils.js';
import push from './push.js';
import NodeHeaders from './response-headers.js';
import {

@@ -7,0 +7,0 @@ Context,

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