Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit b7741e4

Browse files
committed
Initial commit
0 parents  commit b7741e4

File tree

15 files changed

+13080
-0
lines changed

15 files changed

+13080
-0
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '17 22 * * 2'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'javascript' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1

.github/workflows/tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
schedule:
9+
- cron: '17 22 * * 2'
10+
11+
jobs:
12+
build:
13+
name: Tests
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [14.x, 16.x]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
- name: Install dependencies
27+
run: npm install
28+
- name: Run tests
29+
run: npm run test:ci

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Ignore the compiled output.
2+
lib/
3+
*.tgz
4+
5+
# TypeScript incremental compilation cache
6+
*.tsbuildinfo
7+
8+
# Logs
9+
logs
10+
*.log
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
15+
# Coverage (from Jest)
16+
coverage/
17+
18+
# JUnit Reports (used mainly in CircleCI)
19+
reports/
20+
junit.xml
21+
22+
# Node modules
23+
node_modules/
24+
25+
# Mac OS
26+
.DS_Store
27+
28+
# Intellij Configuration Files
29+
.idea/
30+
31+
# NPM configuration
32+
.npmrc

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/fermium

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Debug Tests",
9+
"type": "node",
10+
"request": "launch",
11+
"runtimeArgs": [
12+
"--inspect-brk",
13+
"${workspaceRoot}/node_modules/.bin/jest",
14+
"--runInBand"
15+
],
16+
"console": "integratedTerminal",
17+
"internalConsoleOptions": "neverOpen"
18+
}
19+
]
20+
}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"editor.tabSize": 2,
3+
"editor.detectIndentation": true
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Kamil Dybicz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## CompressionCacheWrapper
2+
3+
[![Tests](https://github.com/kdybicz/apollo-server-compression-cache-wrapper/actions/workflows/tests.yml/badge.svg)](https://github.com/kdybicz/apollo-server-compression-cache-wrapper/actions/workflows/tests.yml)
4+
[![CodeQL](https://github.com/kdybicz/apollo-server-compression-cache-wrapper/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/kdybicz/apollo-server-compression-cache-wrapper/actions/workflows/codeql-analysis.yml)
5+
[![npm version](https://badge.fury.io/js/apollo-server-compression-cache-wrapper.svg)](https://badge.fury.io/js/apollo-server-compression-cache-wrapper)
6+
[![npm downloads](https://img.shields.io/npm/dw/apollo-server-compression-cache-wrapper)](https://www.npmjs.com/package/apollo-server-compression-cache-wrapper)
7+
8+
This package exports an implementation of `KeyValueCache` that allows wrapping any other
9+
[Apollo](https://github.com/apollographql/apollo-server) `KeyValueCache` implementation with a
10+
configurable (default: `zlib deflate`) compression layer. Its main goal is
11+
to limit the amount of memory used by the caching environment and at the same time the amount of
12+
data being in-transit from and to the caching environment.
13+
14+
## Usage
15+
16+
```js
17+
const { RedisCache } = require('apollo-server-cache-redis');
18+
const { CompressionCacheWrapper } = require('apollo-server-compression-cache-wrapper');
19+
const 'zlib' = require('zlib');
20+
21+
const redisCache = new RedisCache({
22+
host: 'redis-server',
23+
});
24+
25+
const server = new ApolloServer({
26+
typeDefs,
27+
resolvers,
28+
cache: new CompressionCacheWrapper(redisCache, {
29+
compress: (data: Buffer) => zlib.deflateSync(data, { level: 1 }),
30+
decompress: (data: Buffer) => zlib.inflateSync(data),
31+
minimumCompressionSize: 262144,
32+
}),
33+
dataSources: () => ({
34+
moviesAPI: new MoviesAPI(),
35+
}),
36+
});
37+
```
38+
39+
## Options
40+
41+
- **compress** (default: `zlib deflate`) - defines a custom compression method taking and returning a `Buffer`.
42+
- **decompress** (default: `zlib deflate`) - defines a custom decompression method taking and returning a `Buffer`.
43+
- **minimumCompressionSize** (default: 262144) - defines minimal length of the data _string_, after
44+
exceeding which data proxied to wrapped cache are compressed before being passed forward.
45+
46+
## Debug
47+
48+
For better performance monitor of **CompressionCacheWrapper** module in your app, run your app with
49+
_DEBUG_ env.
50+
51+
To get all debug messages from all modules:
52+
```
53+
DEBUG=* npm run start
54+
```
55+
56+
To get debug messages only from _compression-wrapper_ module:
57+
```
58+
DEBUG=compression-wrapper npm run start
59+
```

jest.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { defaults } = require("jest-config");
2+
3+
module.exports = {
4+
testEnvironment: "node",
5+
preset: "ts-jest",
6+
testMatch: null,
7+
testRegex: "/__tests__/.*\\.test\\.(js|ts)$",
8+
testPathIgnorePatterns: [
9+
"/node_modules/",
10+
"/lib/"
11+
],
12+
moduleFileExtensions: [...defaults.moduleFileExtensions, "ts", "tsx"],
13+
clearMocks: true,
14+
globals: {
15+
"ts-jest": {
16+
tsconfig: "<rootDir>/tsconfig.json",
17+
diagnostics: false
18+
}
19+
}
20+
};

0 commit comments

Comments
 (0)