@curveball/core
Version:
Curveball is a framework writting in Typescript for Node.js
39 lines (38 loc) • 1.51 kB
TypeScript
import * as http from 'node:http';
import { WebSocketServer } from 'ws';
import * as net from 'node:net';
import { HttpCallback, NodeHttpRequest, NodeHttpResponse } from './node/http-utils.js';
import { Application as BaseApplication, Context, Middleware } from '@curveball/kernel';
export default class Application extends BaseApplication {
middlewares: Middleware[];
private wss;
/**
* Starts a HTTP server on the specified port.
*/
listen(port: number, host?: string): http.Server;
/**
* Starts a Websocket-only server on the specified port.
*
* Note that this is now deprecated. The listen() function already starts
* a websocket on the main HTTP port, so this is somewhat redundant.
*
* @deprecated
*/
listenWs(port: number, host?: string): WebSocketServer;
/**
* Returns a callback that can be used with Node's http.Server, http2.Server, https.Server.
*
* Normally you want to pass this to the constructor of each of these classes.
*/
callback(): HttpCallback;
/**
* This callback can be used to tie to the Node.js Http(s/2) server 'upgrade' event'.
*
* It's used to facilitate incoming Websocket requests
*/
upgradeCallback(request: http.IncomingMessage, socket: net.Socket, head: Buffer): void;
/**
* Creates a Context object based on a node.js request and response object.
*/
buildContextFromHttp(req: NodeHttpRequest, res: NodeHttpResponse): Context;
}