-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: remove esm package #214
Open
benmccann
wants to merge
3
commits into
lukeed:next
Choose a base branch
from
benmccann:rm-esm
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { RequestListener } from 'http'; | ||
|
||
declare namespace cluster { | ||
export interface ClusterController { | ||
listen(port: number): void; | ||
} | ||
} | ||
|
||
declare function cluster( | ||
app: RequestListener | { | ||
listen: Function | ||
} | ||
): cluster.ClusterController; | ||
|
||
export = cluster; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
import type { RequestListener } from 'http'; | ||
|
||
declare namespace cluster { | ||
export interface ClusterController { | ||
listen(port: number): void; | ||
} | ||
export interface ClusterController { | ||
listen(port: number): void; | ||
} | ||
|
||
declare function cluster( | ||
app: RequestListener | { | ||
listen: Function | ||
} | ||
): cluster.ClusterController; | ||
|
||
export = cluster; | ||
export default function (app: RequestListener | { listen: Function }): ClusterController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { IncomingMessage, ServerResponse } from 'node:http'; | ||
|
||
declare namespace compression { | ||
export type Options = { | ||
/** | ||
* Don't compress responses below this size (in bytes). | ||
* @default 1024 | ||
*/ | ||
threshold?: number; | ||
/** | ||
* Gzip/Brotli compression effort (1-11, or -1 for default) | ||
* @default -1 | ||
*/ | ||
level?: number; | ||
/** | ||
* Generate and serve Brotli-compressed responses. | ||
* @default false | ||
*/ | ||
brotli?: boolean; | ||
/** | ||
* Generate and serve Gzip-compressed responses. | ||
* @default true | ||
*/ | ||
gzip?: boolean; | ||
/** | ||
* Regular expression of response MIME types to compress. | ||
* @default /text|javascript|\/json|xml/i | ||
*/ | ||
mimes?: RegExp; | ||
}; | ||
|
||
export type Middleware = ( | ||
request: Pick<IncomingMessage, 'method' | 'headers'>, | ||
response: ServerResponse, | ||
next?: (error?: Error | string) => any, | ||
) => void; | ||
} | ||
|
||
declare function compression(options?: compression.Options): compression.Middleware; | ||
|
||
export = compression; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,37 @@ | ||
import type { IncomingMessage, ServerResponse } from 'node:http'; | ||
|
||
declare namespace compression { | ||
export type Options = { | ||
/** | ||
* Don't compress responses below this size (in bytes). | ||
* @default 1024 | ||
*/ | ||
threshold?: number; | ||
/** | ||
* Gzip/Brotli compression effort (1-11, or -1 for default) | ||
* @default -1 | ||
*/ | ||
level?: number; | ||
/** | ||
* Generate and serve Brotli-compressed responses. | ||
* @default false | ||
*/ | ||
brotli?: boolean; | ||
/** | ||
* Generate and serve Gzip-compressed responses. | ||
* @default true | ||
*/ | ||
gzip?: boolean; | ||
/** | ||
* Regular expression of response MIME types to compress. | ||
* @default /text|javascript|\/json|xml/i | ||
*/ | ||
mimes?: RegExp; | ||
}; | ||
export type Options = { | ||
/** | ||
* Don't compress responses below this size (in bytes). | ||
* @default 1024 | ||
*/ | ||
threshold?: number; | ||
/** | ||
* Gzip/Brotli compression effort (1-11, or -1 for default) | ||
* @default -1 | ||
*/ | ||
level?: number; | ||
/** | ||
* Generate and serve Brotli-compressed responses. | ||
* @default false | ||
*/ | ||
brotli?: boolean; | ||
/** | ||
* Generate and serve Gzip-compressed responses. | ||
* @default true | ||
*/ | ||
gzip?: boolean; | ||
/** | ||
* Regular expression of response MIME types to compress. | ||
* @default /text|javascript|\/json|xml/i | ||
*/ | ||
mimes?: RegExp; | ||
}; | ||
|
||
export type Middleware = ( | ||
request: Pick<IncomingMessage, 'method' | 'headers'>, | ||
response: ServerResponse, | ||
next?: (error?: Error | string) => any, | ||
) => void; | ||
} | ||
export type Middleware = ( | ||
request: Pick<IncomingMessage, 'method' | 'headers'>, | ||
response: ServerResponse, | ||
next?: (error?: Error | string) => any, | ||
) => void; | ||
|
||
declare function compression(options?: compression.Options): compression.Middleware; | ||
|
||
export = compression; | ||
export default function (options?: Options): Middleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { IncomingMessage, ServerResponse } from 'http'; | ||
|
||
// IncomingMessage | ||
class Request { | ||
constructor(method = 'GET', headers = {}) { | ||
this.method = method.toUpperCase(); | ||
this.headers = {}; | ||
for (let i in headers) { | ||
this.headers[i.toLowerCase()] = headers[i]; | ||
} | ||
} | ||
} | ||
|
||
class Response extends ServerResponse { | ||
constructor(req) { | ||
super(req); | ||
this._chunks = []; | ||
this.done = new Promise(r => this._done = r); | ||
} | ||
write(chunk, enc, cb) { | ||
if (!Buffer.isBuffer(chunk)) chunk = Buffer.from(chunk, enc); | ||
this._chunks.push(chunk); | ||
if (cb) cb(null); | ||
return true; | ||
} | ||
end(chunk, enc, cb) { | ||
if (chunk) this.write(chunk, enc); | ||
if (cb) cb(); | ||
this._done(Buffer.concat(this._chunks)); | ||
return this; | ||
} | ||
getResponseData() { | ||
return this.done; | ||
} | ||
async getResponseText() { | ||
return (await this.done).toString(); | ||
} | ||
} | ||
|
||
/** | ||
* @param {string} method | ||
* @param {string} encoding | ||
* @returns {{ req: IncomingMessage, res: Response }} | ||
*/ | ||
export function prepare(method, encoding) { | ||
let req = new Request(method, { | ||
'Accept-Encoding': encoding, | ||
}); | ||
let res = new Response(req); | ||
// @ts-expect-error | ||
return { req, res }; | ||
} | ||
|
||
export function toAscii(thing) { | ||
return JSON.stringify( | ||
Buffer.from(thing).toString('ascii') | ||
).replace(/(^"|"$)/g,''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also drop 12,14,16 as they reached eof for while https://endoflife.date/nodejs and add new version like 19, 20, 21?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
19 and 21 are EOL too. Adding 20 and 22 would be interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd versions are experimental and should never be used.