-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade to Fastify v3 * Added missing input types * Update node versions * Updated fastify requirements * Remove legacy brotli support * Add github actions and depdendabot * Update index.js Co-authored-by: Thomas Heymann <thom@thoms-air.home> Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
1 parent
d108e63
commit f6fed1c
Showing
11 changed files
with
105 additions
and
117 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
version: 1 | ||
update_configs: | ||
- package_manager: "javascript" | ||
directory: "/" | ||
update_schedule: "daily" |
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,18 @@ | ||
name: Continuous Integration | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [10.x, 12.x, 14.x] | ||
name: Node ${{ matrix.node }} | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- run: npm install | ||
- run: npm test |
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
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,27 +1,24 @@ | ||
import { Plugin, FastifyReply, FastifyRequest } from 'fastify' | ||
import { Server, IncomingMessage, ServerResponse } from 'http' | ||
import { FastifyPlugin, FastifyReply, FastifyRequest, RawServerBase } from 'fastify' | ||
import { Stream } from 'stream'; | ||
import { Input, InputObject } from 'into-stream'; | ||
|
||
type EncodingToken = 'br' | 'deflate' | 'gzip' | 'identity' | ||
|
||
declare namespace fastifyCompress { | ||
interface FastifyCompressOptions { | ||
global?: boolean | ||
threshold?: number | ||
customTypes?: RegExp | ||
brotli?: NodeModule | ||
zlib?: NodeModule | ||
inflateIfDeflated?: boolean | ||
onUnsupportedEncoding?: (encoding: string, request: FastifyRequest<ServerResponse>, reply: FastifyReply<ServerResponse>) => string | Buffer | Stream | ||
encodings?: Array<EncodingToken> | ||
declare module "fastify" { | ||
interface FastifyReplyInterface { | ||
compress(input: Stream | Input | InputObject): void; | ||
} | ||
} | ||
|
||
declare const fastifyCompress: Plugin< | ||
Server, | ||
IncomingMessage, | ||
ServerResponse, | ||
fastifyCompress.FastifyCompressOptions | ||
> | ||
type EncodingToken = 'br' | 'deflate' | 'gzip' | 'identity' | ||
|
||
export interface FastifyCompressOptions { | ||
global?: boolean | ||
threshold?: number | ||
customTypes?: RegExp | ||
zlib?: NodeModule | ||
inflateIfDeflated?: boolean | ||
onUnsupportedEncoding?: (encoding: string, request: FastifyRequest<RawServerBase>, reply: FastifyReply<RawServerBase>) => string | Buffer | Stream | ||
encodings?: Array<EncodingToken> | ||
} | ||
|
||
export = fastifyCompress | ||
declare const fastifyCompress: FastifyPlugin<FastifyCompressOptions> | ||
export default fastifyCompress; |
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,26 @@ | ||
import fastify from 'fastify' | ||
import { createReadStream } from 'fs' | ||
import fastifyCompress from '..' | ||
|
||
const zlib = require('zlib') | ||
|
||
const app = fastify() | ||
|
||
app.register(fastifyCompress, { | ||
global: true, | ||
threshold: 10, | ||
zlib: zlib, | ||
inflateIfDeflated: true, | ||
customTypes: /x-protobuf$/, | ||
encodings: ['gzip', 'br', 'identity', 'deflate'] | ||
}) | ||
|
||
const appWithoutGlobal = fastify(); | ||
|
||
appWithoutGlobal.register(fastifyCompress, { global: false }) | ||
|
||
appWithoutGlobal.get('/', (req, reply) => { | ||
reply | ||
.type('text/plain') | ||
.compress(createReadStream('./package.json')) | ||
}) |
Oops, something went wrong.