Skip to content
This repository was archived by the owner on Apr 15, 2021. It is now read-only.

Commit fcf7d53

Browse files
committed
Header prefix and config file name
1 parent 7a500ae commit fcf7d53

30 files changed

+129
-126
lines changed

constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export const PRODUCT_NAME = 'Layer0'
2+
export const PRODUCT_NAME_LOWER = PRODUCT_NAME.toLowerCase()
23
export const CLI_NAME = 'zero'
34
export const PACKAGE_NAME = '@layer0'
5+
export const CONFIG_FILE = 'layer0.config.js'
6+
export const HEADER_PREFIX = 'x-layer0-'
47

58
export const DOMAIN = 'layer0.co'
69
export const APP_DOMAIN = `app.${DOMAIN}`

guides/angular.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If you don't already have an Angular application, you can create one using the f
2525

2626
```bash
2727
npm install -g @angular/cli
28-
ng new my-xdn-angular-app
28+
ng new my-{{ PRODUCT_NAME_LOWER }}-angular-app
2929
```
3030

3131
You should now have a working starter app. Run `ng serve` to see the application running on `localhost:4200`.
@@ -68,7 +68,7 @@ This will automatically add all of the required dependencies and files to your p
6868
- The `{{ PACKAGE_NAME }}/core` package
6969
- The `{{ PACKAGE_NAME }}/angular` package
7070
- The `{{ PACKAGE_NAME }}/cli` package
71-
- `xdn.config.js`- Contains various configuration options for {{ PRODUCT_NAME }}.
71+
- `{{ CONFIG_FILE }}`- Contains various configuration options for {{ PRODUCT_NAME }}.
7272
- `routes.js` - A default routes file that sends all requests to the Angular Universal server. Update this file to add caching or proxy some URLs to a different origin.
7373

7474
#### 3. Use the right angular project

guides/caching.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ router.get('/some/path', ({ cache }) => {
8383
})
8484
```
8585

86-
This will remove the given query parameters from the URL before it is used in cache. On cache miss the transformed URL will be passed to your code with the original query strings available to your code in `x-xdn-original-qs` request header.
86+
This will remove the given query parameters from the URL before it is used in cache. On cache miss the transformed URL will be passed to your code with the original query strings available to your code in `{{ HEADER_PREFIX }}original-qs` request header.
8787

8888
- Including other request parameters like cookies:
8989

@@ -113,7 +113,7 @@ router.get('/some/path', ({ cache }) => {
113113
})
114114
```
115115

116-
This will take the value of the `x-xdn-device` request header and split based on the following devices:
116+
This will take the value of the `{{ HEADER_PREFIX }}device` request header and split based on the following devices:
117117

118118
- `smartphone`
119119
- `tablet`
@@ -191,7 +191,7 @@ router.get('/some/uncacheable/path', ({ cache, proxy }) => {
191191

192192
## How do I know if a response was served from the cache?
193193

194-
To know if a response is being cached, examine the `x-xdn-t` response header. There are two components that indicate caching status:
194+
To know if a response is being cached, examine the `{{ HEADER_PREFIX }}t` response header. There are two components that indicate caching status:
195195

196196
- `oc` - The outer (level 1) cache
197197
- `sc` - The shield (level 2) cache
@@ -204,11 +204,11 @@ You will see one of the following values for these components:
204204

205205
## Why is my response not being cached?
206206

207-
To understand why a response was not cached, examine the `x-xdn-caching-status` response header. It will have one of the following values:
207+
To understand why a response was not cached, examine the `{{ HEADER_PREFIX }}caching-status` response header. It will have one of the following values:
208208

209209
### ok
210210

211-
The response was cached or served from the cache (see `x-xdn-t`).
211+
The response was cached or served from the cache (see `{{ HEADER_PREFIX }}t`).
212212

213213
### disabled
214214

@@ -338,16 +338,16 @@ This guide walks you through clearing the cache on your site at a scheduled day
338338

339339
Here is an example script you can add to your `package.json` to handle cache clearing for each environment. You can also configure scripts to clear by surrogate key, path, or group (As defined in {{ PRODUCT_NAME }} Console)
340340

341-
These scripts assume that you have created environments called "production", "staging", and "development and you have created a deploy key for your site and added it as a secret in your repo called "xdn_deploy_token".
341+
These scripts assume that you have created environments called "production", "staging", and "development and you have created a deploy key for your site and added it as a secret in your repo called "{{ PRODUCT_NAME_LOWER }}\_deploy_token".
342342

343343
```js
344344
"scripts": {
345345
...
346-
"clearcache:dev": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=development --token=$xdn_deploy_token",
347-
"clearcache:stage": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=staging --token=$xdn_deploy_token",
348-
"clearcache:prod": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=production --token=$xdn_deploy_token",
349-
"clearcache:prod:pdps": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=production --surrogate-key=pdp --token=$xdn_deploy_token",
350-
"clearcache:prod:plps": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=production --surrogate-key=plp --token=$xdn_deploy_token",
346+
"clearcache:dev": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=development --token=${{ PRODUCT_NAME_LOWER }}_deploy_token",
347+
"clearcache:stage": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=staging --token=${{ PRODUCT_NAME_LOWER }}_deploy_token",
348+
"clearcache:prod": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=production --token=${{ PRODUCT_NAME_LOWER }}_deploy_token",
349+
"clearcache:prod:pdps": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=production --surrogate-key=pdp --token=${{ PRODUCT_NAME_LOWER }}_deploy_token",
350+
"clearcache:prod:plps": "xdn cache-clear --team=myTeam --site=my{{ PRODUCT_NAME }}App --environment=production --surrogate-key=plp --token=${{ PRODUCT_NAME_LOWER }}_deploy_token",
351351
...
352352
},
353353
```
@@ -368,7 +368,7 @@ Here is an example GitHub action that clears the cache at a scheduled time using
368368
# 1.) This example depends on a script being defined in your package.json called clearcache:prod
369369
#
370370
# In order for this action to clear your cache, you must create a deploy token from the site settings page
371-
# in Moovweb.app and configure it as a secret called "xdn_deploy_token" in your repo on GitHub.
371+
# in Moovweb.app and configure it as a secret called "{{ PRODUCT_NAME_LOWER }}_deploy_token" in your repo on GitHub.
372372

373373
name: Clear PRODUCTION cache at 5am
374374
on:
@@ -401,5 +401,5 @@ jobs:
401401
- name: Clear cache in production
402402
run: npm run clearcache:prod
403403
env:
404-
xdn_deploy_token: ${{secrets.xdn_deploy_token}}
404+
{{ PRODUCT_NAME_LOWER }}_deploy_token: ${{secrets.{{ PRODUCT_NAME_LOWER }}_deploy_token}}
405405
```

guides/cli.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Creates a build of your app optimized for production
2424

2525
#### Options
2626

27-
| Name | Description |
28-
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29-
| `--skip-framework` | Alias: "-s". Skips the framework (Next.js, Vue, Angular, etc..) build and simply rebundles your router |
30-
| `--disable-permanent-assets` | Set this to true to suppress errors like "Immutable file (...) content was changed" during deployment. |
31-
| `--include-sources` | Includes all non-gitignored source files in the bundle uploaded to {{ PRODUCT_NAME }}. This can be helpful when debugging, especially when working with Moovweb support. You can limit the files that are uploaded using the [sources](/guides/xdn_config#section_sources) config in xdn.config.js. |
27+
| Name | Description |
28+
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29+
| `--skip-framework` | Alias: "-s". Skips the framework (Next.js, Vue, Angular, etc..) build and simply rebundles your router |
30+
| `--disable-permanent-assets` | Set this to true to suppress errors like "Immutable file (...) content was changed" during deployment. |
31+
| `--include-sources` | Includes all non-gitignored source files in the bundle uploaded to {{ PRODUCT_NAME }}. This can be helpful when debugging, especially when working with Moovweb support. You can limit the files that are uploaded using the [sources](/guides/{{ PRODUCT_NAME_LOWER }}\_config#section_sources) config in {{ CONFIG_FILE }}. |
3232

3333
#### Example
3434

@@ -59,7 +59,7 @@ xdn cache-clear --team=my-team --site=my-site --environment=production --path=/p
5959

6060
### completion
6161

62-
Creates a script that provides autocompletion for xdn cli commands that can be installed in your shell.
62+
Creates a script that provides autocompletion for {{ PRODUCT_NAME }} CLI commands that can be installed in your shell.
6363

6464
#### Example
6565

@@ -91,16 +91,16 @@ Builds and deploys your site on {{ PRODUCT_NAME }}.
9191

9292
#### Options
9393

94-
| Name | Description |
95-
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
96-
| `--site` | The name of the site to deploy. By default the `name` field in `package.json` is used. |
97-
| `--environment` | The environment to deploy to. By default the `default` environment is used. |
98-
| `--branch` | The name of the source control branch. This is automatically set when using Git. |
99-
| `--skip-build` | Skips the build step |
100-
| `--token` | Authenticates using a deploy token rather than your user credentials. Use this option when deploying from CI. |
101-
| `--commit-url` | The URL at which the commit can be viewed in your source control provided. If your package.json provides the repository attribute the commit URL will be derived automatically if you use GitHub, GitLab, or BitBucket. |
102-
| `--include-sources` | Includes all non-gitignored source files in the bundle uploaded to {{ PRODUCT_NAME }}. This can be helpful when debugging, especially when working with Moovweb support. You can limit the files that are uploaded using the [sources](/guides/xdn_config#section_sources) config in xdn.config.js. |
103-
| `--disable-permanent-assets` | Set this to true to suppress errors like "Immutable file (...) content was changed" during deployment. |
94+
| Name | Description |
95+
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
96+
| `--site` | The name of the site to deploy. By default the `name` field in `package.json` is used. |
97+
| `--environment` | The environment to deploy to. By default the `default` environment is used. |
98+
| `--branch` | The name of the source control branch. This is automatically set when using Git. |
99+
| `--skip-build` | Skips the build step |
100+
| `--token` | Authenticates using a deploy token rather than your user credentials. Use this option when deploying from CI. |
101+
| `--commit-url` | The URL at which the commit can be viewed in your source control provided. If your package.json provides the repository attribute the commit URL will be derived automatically if you use GitHub, GitLab, or BitBucket. |
102+
| `--include-sources` | Includes all non-gitignored source files in the bundle uploaded to {{ PRODUCT_NAME }}. This can be helpful when debugging, especially when working with Moovweb support. You can limit the files that are uploaded using the [sources](/guides/{{ PRODUCT_NAME_LOWER }}\_config#section_sources) config in {{ CONFIG_FILE }}. |
103+
| `--disable-permanent-assets` | Set this to true to suppress errors like "Immutable file (...) content was changed" during deployment. |
104104

105105
#### Example
106106

0 commit comments

Comments
 (0)