Skip to content

Commit fbc6cb0

Browse files
author
diana.ionita
committed
Merge branch 'release/1.0.0'
2 parents b5e2b87 + 81729a9 commit fbc6cb0

20 files changed

+2029
-1
lines changed

.circleci/config.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
version: 2
2+
3+
references:
4+
container_config: &container_config
5+
docker:
6+
- image: circleci/node:8.10
7+
environment:
8+
MOCHA_FILE: ./test-results/unit/test-results.xml
9+
10+
poke_npmrc: &poke_npmrc
11+
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
12+
13+
restore_npm_cache: &restore_npm_cache
14+
restore_cache:
15+
keys:
16+
- v1-dependencies-{{ checksum "package.json" }}
17+
- v1-dependencies-
18+
19+
save_npm_cache: &save_npm_cache
20+
save_cache:
21+
paths:
22+
- node_modules
23+
key: v1-dependencies-{{ checksum "package.json" }}
24+
25+
create_test_results_dir: &create_test_results_dir
26+
run:
27+
command: |
28+
mkdir ./test-results
29+
mkdir ./test-results/unit
30+
31+
store_test_results: &store_test_results
32+
store_test_results:
33+
path: ./test-results
34+
35+
jobs:
36+
dev:
37+
<<: *container_config
38+
steps:
39+
- *poke_npmrc
40+
- checkout
41+
- *restore_npm_cache
42+
- run: npm install
43+
- *save_npm_cache
44+
- run: npm run test -- --reporter mocha-junit-reporter
45+
- *store_test_results
46+
47+
live:
48+
<<: *container_config
49+
steps:
50+
- *poke_npmrc
51+
- checkout
52+
- *restore_npm_cache
53+
- run: npm install
54+
- *save_npm_cache
55+
- run: npm publish
56+
57+
workflows:
58+
version: 2
59+
build:
60+
jobs:
61+
- dev
62+
- live:
63+
requires:
64+
- dev
65+
filters:
66+
branches:
67+
only: master

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# package directories
2+
node_modules
3+
4+
# Serverless directories
5+
.serverless

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# package directories
2+
node_modules
3+
4+
test
5+
.gitignore

.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": "Tests",
9+
"type": "node",
10+
"request": "launch",
11+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
12+
"args": [
13+
"test/**/*.js",
14+
"-t",
15+
"10000",
16+
"--color"
17+
]
18+
},
19+
]
20+
}

README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,58 @@
11
# serverless-api-gateway-caching
2-
In progress.
2+
3+
[![CircleCI](https://circleci.com/gh/DianaIonita/serverless-api-gateway-caching.svg?style=svg)](https://circleci.com/gh/DianaIonita/serverless-api-gateway-caching)
4+
5+
## Intro
6+
A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.
7+
8+
## Good to know
9+
If you enable caching globally, it does NOT automatically enable caching for your endpoints - you have to be explicit about which endpoints should have caching enabled.
10+
However, disabling caching globally disables it across endpoints.
11+
12+
## Example
13+
14+
```yml
15+
plugins:
16+
- serverless-api-gateway-caching
17+
18+
custom:
19+
# Enable or disable caching globally
20+
apiGatewayCaching:
21+
enabled: true
22+
clusterSize: '0.5' # defaults to '0.5'
23+
ttlInSeconds: 300 # defaults to the maximum allowed: 3600
24+
25+
functions:
26+
# Responses are not cached
27+
list-all-cats:
28+
handler: rest_api/cats/get/handler.handle
29+
role: listCatsRole
30+
events:
31+
- http:
32+
path: /cats
33+
method: get
34+
caching:
35+
enabled: false # default is false
36+
37+
# Responses are cached based on the 'pawId' path parameter and the 'Accept-Language' header
38+
get-cat-by-paw-id:
39+
handler: rest_api/cat/get/handler.handle
40+
events:
41+
- http:
42+
path: /cats/{pawId}
43+
method: get
44+
caching:
45+
enabled: true
46+
ttlInSeconds: 3600
47+
cacheKeyParameters:
48+
- name: request.path.pawId
49+
required: true
50+
- name: request.header.Accept-Language
51+
required: false
52+
```
53+
54+
## Limitations
55+
* For HTTP method `ANY`, caching will be enabled only for the `GET` method and disabled for the other methods.
56+
57+
## Currently not supported:
58+
* lambda functions with many http events

0 commit comments

Comments
 (0)