@pirxpilot/connect
Advanced tools
+6
-17
@@ -14,20 +14,9 @@ /*! | ||
| const { EventEmitter } = require('node:events'); | ||
| const http = require('node:http'); | ||
| const parseUrl = require('parseurl'); | ||
| import { EventEmitter } from 'node:events'; | ||
| import http from 'node:http'; | ||
| import Debug from 'debug'; | ||
| import parseUrl from 'parseurl'; | ||
| const debug = require('debug')('connect:dispatcher'); | ||
| const debug = Debug('connect:dispatcher'); | ||
| /** | ||
| * Module exports. | ||
| * @public | ||
| */ | ||
| module.exports = createServer; | ||
| /** | ||
| * Module variables. | ||
| * @private | ||
| */ | ||
| const proto = { | ||
@@ -46,3 +35,3 @@ use, | ||
| function createServer({ finalhandler = makeFinalHandler } = {}) { | ||
| export default function createServer({ finalhandler = makeFinalHandler } = {}) { | ||
| return Object.assign(app, proto, EventEmitter.prototype, { stack: [] }); | ||
@@ -49,0 +38,0 @@ |
+4
-2
| { | ||
| "name": "@pirxpilot/connect", | ||
| "description": "High performance middleware framework", | ||
| "version": "4.2.1", | ||
| "version": "5.0.0", | ||
| "exports": "./index.js", | ||
| "type": "module", | ||
| "author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)", | ||
@@ -27,3 +29,3 @@ "contributors": [ | ||
| "devDependencies": { | ||
| "@biomejs/biome": "~1", | ||
| "@biomejs/biome": "2.3.8", | ||
| "supertest-fetch": "~2" | ||
@@ -30,0 +32,0 @@ }, |
+26
-24
@@ -10,13 +10,14 @@ [![NPM Version][npm-image]][npm-url] | ||
| ```js | ||
| var connect = require('connect'); | ||
| var http = require('http'); | ||
| import connect from 'connect'; | ||
| import { createServer } from 'http'; | ||
| import compression from 'compression'; | ||
| import cookieSession from 'cookie-session'; | ||
| import bodyParser from 'body-parser'; | ||
| var app = connect(); | ||
| const app = connect(); | ||
| // gzip/deflate outgoing responses | ||
| var compression = require('compression'); | ||
| app.use(compression()); | ||
| // store session state in browser cookie | ||
| var cookieSession = require('cookie-session'); | ||
| app.use(cookieSession({ | ||
@@ -27,12 +28,11 @@ keys: ['secret1', 'secret2'] | ||
| // parse urlencoded request bodies into req.body | ||
| var bodyParser = require('body-parser'); | ||
| app.use(bodyParser.urlencoded({extended: false})); | ||
| app.use(bodyParser.urlencoded({ extended: false })); | ||
| // respond to all requests | ||
| app.use(function(req, res){ | ||
| app.use((req, res) => { | ||
| res.end('Hello from Connect!\n'); | ||
| }); | ||
| //create node.js http server and listen on port | ||
| http.createServer(app).listen(3000); | ||
| // create node.js http server and listen on port | ||
| createServer(app).listen(3000); | ||
| ``` | ||
@@ -56,3 +56,3 @@ | ||
| ```js | ||
| var app = connect(); | ||
| const app = connect(); | ||
| ``` | ||
@@ -67,7 +67,7 @@ | ||
| ```js | ||
| app.use(function middleware1(req, res, next) { | ||
| app.use((req, res, next) => { | ||
| // middleware 1 | ||
| next(); | ||
| }); | ||
| app.use(function middleware2(req, res, next) { | ||
| app.use((req, res, next) => { | ||
| // middleware 2 | ||
@@ -84,7 +84,7 @@ next(); | ||
| ```js | ||
| app.use('/foo', function fooMiddleware(req, res, next) { | ||
| app.use('/foo', (req, res, next) => { | ||
| // req.url starts with "/foo" | ||
| next(); | ||
| }); | ||
| app.use('/bar', function barMiddleware(req, res, next) { | ||
| app.use('/bar', (req, res, next) => { | ||
| // req.url starts with "/bar" | ||
@@ -105,3 +105,3 @@ next(); | ||
| // regular middleware | ||
| app.use(function (req, res, next) { | ||
| app.use((req, res, next) => { | ||
| // i had an error | ||
@@ -113,3 +113,3 @@ next(new Error('boom!')); | ||
| // declared before this | ||
| app.use(function onerror(err, req, res, next) { | ||
| app.use((err, req, res, next) => { | ||
| // an error occurred! | ||
@@ -126,3 +126,3 @@ }); | ||
| ```js | ||
| var server = app.listen(port); | ||
| const server = app.listen(port); | ||
| ``` | ||
@@ -134,3 +134,5 @@ | ||
| ```js | ||
| var server = http.createServer(app); | ||
| import { createServer } from 'http'; | ||
| const server = createServer(app); | ||
| ``` | ||
@@ -147,7 +149,7 @@ | ||
| ```js | ||
| // require module | ||
| var connect = require('connect'); | ||
| // import module | ||
| import connect from 'connect'; | ||
| // create app | ||
| var app = connect(); | ||
| const app = connect(); | ||
| ``` | ||
@@ -182,3 +184,3 @@ | ||
| ```js | ||
| app.use(function (req, res, next) { | ||
| app.use((req, res, next) => { | ||
| // req is the Node.js http request object | ||
@@ -201,3 +203,3 @@ // res is the Node.js http response object | ||
| ```js | ||
| app.use('/foo', function (req, res, next) { | ||
| app.use('/foo', (req, res, next) => { | ||
| // req is the Node.js http request object | ||
@@ -204,0 +206,0 @@ // res is the Node.js http response object |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
234
0.86%Yes
NaN15582
-0.76%256
-3.03%