New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

retes

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retes - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

7

dist/index.d.ts

@@ -55,5 +55,10 @@ /// <reference types="node" />

stop: () => Promise<void>;
constructor(routes: Routes);
handleError: (context: Context) => (error: Error) => void;
append: (context: Context) => () => void;
constructor(routes: Routes, handleError?: ({ response }: {
response: any;
}) => (error: any) => void, append?: (context: any) => () => void);
use(middleware: Middleware | Promise<Middleware>): this;
add(method: HTTPMethod, path: string, ...fns: (LocalMiddleware | Handler)[]): this;
setup(): Promise<void>;
start(port?: number): Promise<http.Server>;

@@ -60,0 +65,0 @@ get port(): number;

18

dist/index.js

@@ -188,3 +188,5 @@ "use strict";

class ServerApp {
constructor(routes) {
constructor(routes, handleError = ({ response }) => error => {
response.statusCode = 500;
}, append = context => () => { }) {
this.middlewares = new Base();

@@ -195,2 +197,4 @@ this.router = new router_1.Router();

this.stop = () => Promise.reject(`You should start the server first`);
this.handleError = handleError;
this.append = append;
// TODO move it to `start` once it's abstracted

@@ -227,3 +231,3 @@ for (const [path, params] of this.routes) {

}
async start(port = 0) {
async setup() {
this.use(routing_1.Routing(this.router));

@@ -233,2 +237,5 @@ // append 404 middleware handler: it must be put at the end and only once

this.use(() => Response.NotFound());
}
async start(port = 0) {
await this.setup();
this.server = http_1.default

@@ -240,5 +247,4 @@ .createServer((request, response) => {

.then(core_1.handle(context))
.catch(error => {
response.statusCode = 500;
});
.then(this.append(context))
.catch(this.handleError(context));
})

@@ -249,5 +255,5 @@ .on('error', error => {

});
this.stop = graceful_stop_1.getServerStopFunc(this.server);
return new Promise((resolve, reject) => {
this.server?.listen(port, () => {
this.stop = graceful_stop_1.getServerStopFunc(this.server);
resolve(this.server);

@@ -254,0 +260,0 @@ });

{
"name": "retes",
"version": "0.3.0",
"version": "0.4.0",
"description": "Typed, Declarative, Data-Driven Routing for Node.js",

@@ -18,3 +18,3 @@ "main": "dist/index.js",

"debug": "^4.3.1",
"zod": "^2.0.0-beta.24"
"zod": "^2.0.0-beta.29"
},

@@ -24,4 +24,4 @@ "devDependencies": {

"@types/debug": "^4.1.5",
"@types/node": "^14.14.10",
"ava": "^3.13.0",
"@types/node": "^14.14.11",
"ava": "^3.14.0",
"axios": "^0.21.0",

@@ -28,0 +28,0 @@ "form-data": "^3.0.0",

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