Skip to content

Commit

Permalink
updated prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
ntotten committed Nov 13, 2023
1 parent fc1ad8d commit 200d1c3
Show file tree
Hide file tree
Showing 97 changed files with 1,000 additions and 518 deletions.
4 changes: 3 additions & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
If you have a security concern or believe you have found a vulnerability in any part of Zuplo please contact us immediately by emailing us at security@zuplo.com.
If you have a security concern or believe you have found a vulnerability in any
part of Zuplo please contact us immediately by emailing us at
security@zuplo.com.
63 changes: 31 additions & 32 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: ["main"]
schedule:
- cron: '18 10 * * 1'
- cron: "18 10 * * 1"

jobs:
analyze:
Expand All @@ -32,43 +32,42 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
6 changes: 3 additions & 3 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
name: "Dependency Review"
on: [pull_request]

permissions:
Expand All @@ -14,7 +14,7 @@ jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: 'Dependency Review'
- name: "Dependency Review"
uses: actions/dependency-review-action@v3
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
};
2 changes: 1 addition & 1 deletion crawler.blog.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
"lvl5": "article h6",
"text": "article p, article li, article pre, article code, article td:last-child"
}
}
}
11 changes: 2 additions & 9 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@
// language - current active spelling language
"language": "en",
// words - list of words to be always considered correct
"words": [
"Kubernetes",
"Linkerd",
"Quickstart",
"quickstarts"
],
"words": ["Kubernetes", "Linkerd", "Quickstart", "quickstarts"],
// flagWords - list of words to be always considered incorrect
// This is useful for offensive words and common spelling errors.
// For example "hte" should be "the"
"flagWords": [
"hte"
]
"flagWords": ["hte"]
}
2 changes: 1 addition & 1 deletion docs/articles/archiving-requests-to-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type RequestArchivePolicyOptions = {
export default async function (
request: ZuploRequest,
context: ZuploContext,
options: RequestArchivePolicyOptions
options: RequestArchivePolicyOptions,
) {
// because we will read the body, we need to
// create a clone of this request first, otherwise
Expand Down
54 changes: 38 additions & 16 deletions docs/articles/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ sidebar_label: Cache
draft: true
---

The [Cache API](https://developer.mozilla.org/en-US/docs/Web/API/Cache) provides a persistent storage mechanism for Request / Response object pairs that are cached in long lived memory.
The [Cache API](https://developer.mozilla.org/en-US/docs/Web/API/Cache) provides
a persistent storage mechanism for Request / Response object pairs that are
cached in long lived memory.

:::tip

Only a subset of the standard Cache API is supported. Below are the interfaces and methods that are supported and known limitations.
Only a subset of the standard Cache API is supported. Below are the interfaces
and methods that are supported and known limitations.

:::

## CacheStorage

The `CacheStorage` is exposed as the `caches` global object. This object allows you to open instances of a `Cache`. When calling `caches.open` if the named cache does not exist it will be created, otherwise the existing cache will be returned.
The `CacheStorage` is exposed as the `caches` global object. This object allows
you to open instances of a `Cache`. When calling `caches.open` if the named
cache does not exist it will be created, otherwise the existing cache will be
returned.

**Definition**

Expand All @@ -32,7 +38,8 @@ const cache = await caches.open("MY_CACHE");

## Cache

The `Cache` object stores `Request` and `Response` objects based on header values.
The `Cache` object stores `Request` and `Response` objects based on header
values.

**Definition**

Expand All @@ -41,7 +48,7 @@ interface Cache {
put(request: RequestInfo, response: Response): Promise<void>;
match(
request: RequestInfo,
options?: CacheQueryOptions
options?: CacheQueryOptions,
): Promise<Response | undefined>;
delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
}
Expand All @@ -64,7 +71,9 @@ interface CacheQueryOptions {

:::warning

At this time, the `options` parameter will be ignored entirely when running on in a developer environment (i.e. working copy). In non-developer environments, the `ignoreMethod` property is supported. All other properties will be ignored.
At this time, the `options` parameter will be ignored entirely when running on
in a developer environment (i.e. working copy). In non-developer environments,
the `ignoreMethod` property is supported. All other properties will be ignored.

:::

Expand All @@ -74,36 +83,46 @@ At this time, the `options` parameter will be ignored entirely when running on i
await cache.put(request, response);
```

The `put()` method of the `Cache` interface allows key/value pairs to be added to the current Cache object.
The `put()` method of the `Cache` interface allows key/value pairs to be added
to the current Cache object.

### Match

```ts
const response = await cache.match(request);
```

The `match()` method of the `Cache` interface returns a Promise that resolves to the Response associated with the first matching request in the Cache object. If no match is found, the Promise resolves to `undefined`.
The `match()` method of the `Cache` interface returns a Promise that resolves to
the Response associated with the first matching request in the Cache object. If
no match is found, the Promise resolves to `undefined`.

### Delete

```ts
await cache.delete(request);
```

The delete() method of the Cache interface finds the Cache entry whose key is the request, and if found, deletes the Cache entry and returns a Promise that resolves to true. If no Cache entry is found, it resolves to false.
The delete() method of the Cache interface finds the Cache entry whose key is
the request, and if found, deletes the Cache entry and returns a Promise that
resolves to true. If no Cache entry is found, it resolves to false.

## Headers

The following headers can be used to control the cache when adding a response using the `put()` method.
The following headers can be used to control the cache when adding a response
using the `put()` method.

- `Cache-Control`: Controls caching directives. [More info](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control)
- `ETag`: Allows cache.match() to evaluate conditional requests with If-None-Match.
- `Cache-Control`: Controls caching directives.
[More info](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control)
- `ETag`: Allows cache.match() to evaluate conditional requests with
If-None-Match.
- `Expires`: A string that specifies when the resource becomes invalid.
- `Last-Modified`: Allows cache.match() to evaluate conditional requests with If-Modified-Since.
- `Last-Modified`: Allows cache.match() to evaluate conditional requests with
If-Modified-Since.

## Examples

The below example shows how to use a cached response and populate the cache in the event there is no response already cached.
The below example shows how to use a cached response and populate the cache in
the event there is no response already cached.

```ts
const request = new Request(`https://echo.zuplo.io`);
Expand All @@ -117,7 +136,8 @@ if (!response) {
const data = await response.json();
```

If you just want to store the value, just create a new simple Response and set the `Cache-Control` header.
If you just want to store the value, just create a new simple Response and set
the `Cache-Control` header.

```ts
const request = new Request(`https://echo.zuplo.io`);
Expand All @@ -135,7 +155,9 @@ const cachedResponse = new Response(response, {
await cache.put(request, cachedResponse);
```

When adding to the cache, headers are used to control how long resources are stored. If you are reusing the response headers, make sure to account for additional cache headers that may have been sent.
When adding to the cache, headers are used to control how long resources are
stored. If you are reusing the response headers, make sure to account for
additional cache headers that may have been sent.

```ts
const request = new Request(`https://echo.zuplo.io`);
Expand Down
3 changes: 2 additions & 1 deletion docs/articles/check-ip-address.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
title: How to check an incoming IP address
---

Sometimes you want to access the true IP address of the gateway's client making the current request. To do this you can read the `true-client-ip` header:
Sometimes you want to access the true IP address of the gateway's client making
the current request. To do this you can read the `true-client-ip` header:

```ts
const ip = request.headers.get("true-client-ip");
Expand Down
43 changes: 36 additions & 7 deletions docs/articles/cloudflare-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,55 @@ title: Zuplo and Cloudflare Settings
sidebar_label: Cloudflare Settings
---

All Zuplo environments are deployed behind Cloudflare's Web Application Firewall, DDoS protection, Bot Detection, and SSL termination. The combination of Cloudflare's network infrastructure and Zuplo's API Gateway help provide critical security and performance capabilities to your API all with zero custom configuration.
All Zuplo environments are deployed behind Cloudflare's Web Application
Firewall, DDoS protection, Bot Detection, and SSL termination. The combination
of Cloudflare's network infrastructure and Zuplo's API Gateway help provide
critical security and performance capabilities to your API all with zero custom
configuration.

## Web Application Firewall Rules

By default, WAF settings are in log only mode. This means that no request should be blocked by the Web Application Firewall.
By default, WAF settings are in log only mode. This means that no request should
be blocked by the Web Application Firewall.

You can choose to enable some preconfigured default rulesets to protect your API Gateway. Our default rules provide a high level of protection with a low likelihood of causing false positives for API transactions. For enterprise customers, Zuplo offers the ability to customize WAF rules to suite your specific needs.
You can choose to enable some preconfigured default rulesets to protect your API
Gateway. Our default rules provide a high level of protection with a low
likelihood of causing false positives for API transactions. For enterprise
customers, Zuplo offers the ability to customize WAF rules to suite your
specific needs.

## DDos Protection

DDoS protection is available for every Zuplo API through [Cloudflare's DDoS protection service](https://support.cloudflare.com/hc/en-us/articles/200172676-Understanding-Cloudflare-DDoS-protection). By default, the **rule sensitivy** setting is set to **Essentially Off** meaning almost no requests will be blocked. For paying customers, we offer the ability to modify this setting as needed.
DDoS protection is available for every Zuplo API through
[Cloudflare's DDoS protection service](https://support.cloudflare.com/hc/en-us/articles/200172676-Understanding-Cloudflare-DDoS-protection).
By default, the **rule sensitivy** setting is set to **Essentially Off** meaning
almost no requests will be blocked. For paying customers, we offer the ability
to modify this setting as needed.

## Security Level

Cloudflare uses a blanket [security protection setting](https://support.cloudflare.com/hc/en-us/articles/200170056-Understanding-the-Cloudflare-Security-Level) that uses the IP reputation of a visitor to decide if the request should be blocked. By default, Zuplo this security setting is **Off** for all Zuplo APIs. For paying customers, this setting can be customized as needed for your API.
Cloudflare uses a blanket
[security protection setting](https://support.cloudflare.com/hc/en-us/articles/200170056-Understanding-the-Cloudflare-Security-Level)
that uses the IP reputation of a visitor to decide if the request should be
blocked. By default, Zuplo this security setting is **Off** for all Zuplo APIs.
For paying customers, this setting can be customized as needed for your API.

## Caching

Cloudflare's global CDN enables your API Gateway to set cache headers in order to reduce the number of requests that hit your origin API. By default, all APIs deployed to Zuplo are configured on Cloudflare to respect existing cache headers. The means that if you want content cached, simply set the [appropriate headers](https://developers.cloudflare.com/cache/about/cache-control/) and Cloudflare's global CDN will cache responses at the edge.
Cloudflare's global CDN enables your API Gateway to set cache headers in order
to reduce the number of requests that hit your origin API. By default, all APIs
deployed to Zuplo are configured on Cloudflare to respect existing cache
headers. The means that if you want content cached, simply set the
[appropriate headers](https://developers.cloudflare.com/cache/about/cache-control/)
and Cloudflare's global CDN will cache responses at the edge.

## Developer Environments

Generally, developer environments (i.e. any API running on the domain `zuplo.dev`) has similar security configurations as "production" environments (i.e. any API running on the domain `zuplo.app` or your own custom domain). There are some exceptions where we have slightly more security measures in place to prevent abuse of developer resources. If you see any issues or have requests blocked to your developer instance please contact [support@zuplo.com](mailto:support@zuplo.com) and we can assist with adjusting rules to ensure you can test your API as needed.
Generally, developer environments (i.e. any API running on the domain
`zuplo.dev`) has similar security configurations as "production" environments
(i.e. any API running on the domain `zuplo.app` or your own custom domain).
There are some exceptions where we have slightly more security measures in place
to prevent abuse of developer resources. If you see any issues or have requests
blocked to your developer instance please contact
[support@zuplo.com](mailto:support@zuplo.com) and we can assist with adjusting
rules to ensure you can test your API as needed.
Loading

0 comments on commit 200d1c3

Please sign in to comment.