@fastly/expressly 1.0.0--canary.4.2464710183.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
  2. package/.github/workflows/release.yml +85 -0
  3. package/.husky/pre-commit +4 -0
  4. package/.nvmrc +1 -0
  5. package/LICENSE +21 -0
  6. package/README.md +56 -0
  7. package/SECURITY.MD +9 -0
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.js +5 -0
  10. package/dist/lib/routing/common.d.ts +11 -0
  11. package/dist/lib/routing/common.js +36 -0
  12. package/dist/lib/routing/error-middleware.d.ts +10 -0
  13. package/dist/lib/routing/error-middleware.js +12 -0
  14. package/dist/lib/routing/errors.d.ts +9 -0
  15. package/dist/lib/routing/errors.js +16 -0
  16. package/dist/lib/routing/request/cookie-map.d.ts +9 -0
  17. package/dist/lib/routing/request/cookie-map.js +37 -0
  18. package/dist/lib/routing/request/index.d.ts +27 -0
  19. package/dist/lib/routing/request/index.js +47 -0
  20. package/dist/lib/routing/request-handler.d.ts +10 -0
  21. package/dist/lib/routing/request-handler.js +12 -0
  22. package/dist/lib/routing/response/index.d.ts +24 -0
  23. package/dist/lib/routing/response/index.js +101 -0
  24. package/dist/lib/routing/response/status-codes.d.ts +56 -0
  25. package/dist/lib/routing/response/status-codes.js +57 -0
  26. package/dist/lib/routing/response/surrogate-keys.d.ts +9 -0
  27. package/dist/lib/routing/response/surrogate-keys.js +29 -0
  28. package/dist/lib/routing/router.d.ts +32 -0
  29. package/dist/lib/routing/router.js +165 -0
  30. package/docs/.nvmrc +1 -0
  31. package/docs/README.md +27 -0
  32. package/docs/babel.config.js +3 -0
  33. package/docs/docs/config.md +52 -0
  34. package/docs/docs/handling-data/_category_.json +4 -0
  35. package/docs/docs/handling-data/cookies.md +103 -0
  36. package/docs/docs/handling-data/headers.md +110 -0
  37. package/docs/docs/handling-data/request.md +82 -0
  38. package/docs/docs/handling-data/response.md +162 -0
  39. package/docs/docs/handling-data/search-params.md +45 -0
  40. package/docs/docs/intro.md +61 -0
  41. package/docs/docs/middleware/_category_.json +5 -0
  42. package/docs/docs/middleware/controlling-flow.md +41 -0
  43. package/docs/docs/middleware/error-middleware.md +41 -0
  44. package/docs/docs/middleware/what-is-middleware.md +31 -0
  45. package/docs/docs/origin-data/_category_.json +4 -0
  46. package/docs/docs/origin-data/working-with-origins.md +49 -0
  47. package/docs/docs/routing.md +163 -0
  48. package/docs/docusaurus.config.js +119 -0
  49. package/docs/package.json +48 -0
  50. package/docs/sidebars.js +31 -0
  51. package/docs/src/components/HomepageFeatures.module.css +11 -0
  52. package/docs/src/components/HomepageFeatures.tsx +62 -0
  53. package/docs/src/css/custom.css +45 -0
  54. package/docs/src/pages/index.module.css +35 -0
  55. package/docs/src/pages/index.tsx +109 -0
  56. package/docs/static/.nojekyll +0 -0
  57. package/docs/static/img/favicon.ico +0 -0
  58. package/docs/static/img/logo-black.png +0 -0
  59. package/docs/static/img/logo-transparent.png +0 -0
  60. package/docs/static/img/logo.png +0 -0
  61. package/docs/static-host/Cargo.lock +435 -0
  62. package/docs/static-host/Cargo.toml +16 -0
  63. package/docs/static-host/fastly.toml +9 -0
  64. package/docs/static-host/rust-toolchain +3 -0
  65. package/docs/static-host/src/main.rs +115 -0
  66. package/docs/tsconfig.json +7 -0
  67. package/docs/yarn.lock +8416 -0
  68. package/package.json +56 -0
  69. package/src/index.ts +11 -0
  70. package/src/lib/routing/common.ts +34 -0
  71. package/src/lib/routing/error-middleware.ts +23 -0
  72. package/src/lib/routing/errors.ts +18 -0
  73. package/src/lib/routing/index.d.ts +18 -0
  74. package/src/lib/routing/request/cookie-map.ts +42 -0
  75. package/src/lib/routing/request/index.ts +64 -0
  76. package/src/lib/routing/request-handler.ts +22 -0
  77. package/src/lib/routing/response/index.ts +113 -0
  78. package/src/lib/routing/response/status-codes.ts +57 -0
  79. package/src/lib/routing/response/surrogate-keys.ts +32 -0
  80. package/src/lib/routing/router.ts +191 -0
  81. package/tsconfig.json +20 -0
@@ -0,0 +1,119 @@
1
+ // @ts-check
2
+ // Note: type annotations allow type checking and IDEs autocompletion
3
+
4
+ const lightCodeTheme = require("prism-react-renderer/themes/github");
5
+ const darkCodeTheme = require("prism-react-renderer/themes/nightOwl");
6
+
7
+ /** @type {import('@docusaurus/types').Config} */
8
+ const config = {
9
+ title: "expressly",
10
+ tagline: "Express-style router for Fastly's Compute@Edge",
11
+ url: "https://expressly.edgecompute.app",
12
+ baseUrl: "/",
13
+ onBrokenLinks: "throw",
14
+ onBrokenMarkdownLinks: "warn",
15
+ favicon: "img/favicon.ico",
16
+ organizationName: "fastly",
17
+ projectName: "expressly",
18
+
19
+ presets: [
20
+ [
21
+ "@docusaurus/preset-classic",
22
+ /** @type {import('@docusaurus/preset-classic').Options} */
23
+ ({
24
+ docs: {
25
+ sidebarPath: require.resolve("./sidebars.js"),
26
+ sidebarCollapsed: false,
27
+ editUrl: 'https://github.com/fastly/expressly/edit/main/docs/',
28
+ },
29
+ theme: {
30
+ customCss: require.resolve("./src/css/custom.css"),
31
+ },
32
+ }),
33
+ ],
34
+ ],
35
+
36
+ themeConfig:
37
+ /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
38
+ ({
39
+ colorMode: {
40
+ respectPrefersColorScheme: true,
41
+ },
42
+ navbar: {
43
+ title: "expressly",
44
+ logo: {
45
+ alt: "expressly Logo",
46
+ src: 'img/logo.png',
47
+ },
48
+ items: [
49
+ {
50
+ type: "doc",
51
+ docId: "intro",
52
+ position: "left",
53
+ label: "Docs",
54
+ },
55
+ {
56
+ href: "https://developer.fastly.com/solutions/examples/javascript/",
57
+ label: "Examples",
58
+ position: "left",
59
+ },
60
+ {
61
+ href: "https://github.com/fastly/expressly",
62
+ label: "GitHub",
63
+ position: "right",
64
+ },
65
+ ],
66
+ },
67
+ footer: {
68
+ style: "dark",
69
+ links: [
70
+ {
71
+ title: "expressly",
72
+ items: [
73
+ {
74
+ label: "Documentation",
75
+ to: "/docs/intro",
76
+ },
77
+ {
78
+ label: "Examples",
79
+ href: "https://developer.fastly.com/solutions/examples/javascript/",
80
+ },
81
+ ],
82
+ },
83
+ {
84
+ title: "Compute@Edge",
85
+ items: [
86
+ {
87
+ label: "Learn about Compute@Edge",
88
+ href: "https://developer.fastly.com/learning/compute/",
89
+ },
90
+ {
91
+ label: "Create your first JavaScript app",
92
+ href: "https://developer.fastly.com/learning/compute/javascript/",
93
+ },
94
+ {
95
+ label: "Fastly Developer Hub",
96
+ href: "https://developer.fastly.com/",
97
+ },
98
+ ],
99
+ },
100
+ {
101
+ title: "Fastly",
102
+ items: [
103
+ {
104
+ label: "Twitter",
105
+ href: "https://twitter.com/fastly",
106
+ },
107
+ ],
108
+ },
109
+ ],
110
+ copyright: `Copyright © ${new Date().getFullYear()} Fastly Inc. All rights reserved.`,
111
+ },
112
+ prism: {
113
+ theme: lightCodeTheme,
114
+ darkTheme: darkCodeTheme,
115
+ },
116
+ }),
117
+ };
118
+
119
+ module.exports = config;
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "expressly-docs",
3
+ "version": "0.0.0",
4
+ "description": "Documentation for expressly - an Express-style router for Fastly's Compute@Edge",
5
+ "private": true,
6
+ "engines": {
7
+ "node": "^16.15.0"
8
+ },
9
+ "scripts": {
10
+ "docusaurus": "docusaurus",
11
+ "start": "docusaurus start",
12
+ "build": "docusaurus build",
13
+ "swizzle": "docusaurus swizzle",
14
+ "deploy": "docusaurus deploy",
15
+ "clear": "docusaurus clear",
16
+ "serve": "docusaurus serve",
17
+ "write-translations": "docusaurus write-translations",
18
+ "write-heading-ids": "docusaurus write-heading-ids",
19
+ "typecheck": "tsc"
20
+ },
21
+ "dependencies": {
22
+ "@docusaurus/core": "2.0.0-beta.21",
23
+ "@docusaurus/preset-classic": "2.0.0-beta.21",
24
+ "@mdx-js/react": "^1.6.22",
25
+ "clsx": "^1.1.1",
26
+ "prism-react-renderer": "^1.3.3",
27
+ "react": "^17.0.2",
28
+ "react-dom": "^17.0.2"
29
+ },
30
+ "devDependencies": {
31
+ "@docusaurus/module-type-aliases": "2.0.0-beta.21",
32
+ "@tsconfig/docusaurus": "^1.0.5",
33
+ "@types/react": "^17.0.2",
34
+ "typescript": "^4.7.3"
35
+ },
36
+ "browserslist": {
37
+ "production": [
38
+ ">0.5%",
39
+ "not dead",
40
+ "not op_mini all"
41
+ ],
42
+ "development": [
43
+ "last 1 chrome version",
44
+ "last 1 firefox version",
45
+ "last 1 safari version"
46
+ ]
47
+ }
48
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creating a sidebar enables you to:
3
+ - create an ordered group of docs
4
+ - render a sidebar for each doc of that group
5
+ - provide next/previous navigation
6
+
7
+ The sidebars can be generated from the filesystem, or explicitly defined here.
8
+
9
+ Create as many sidebars as you want.
10
+ */
11
+
12
+ // @ts-check
13
+
14
+ /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
15
+ const sidebars = {
16
+ // By default, Docusaurus generates a sidebar from the docs folder structure
17
+ main: [{ type: "autogenerated", dirName: "." }],
18
+
19
+ // But you can create a sidebar manually
20
+ /*
21
+ tutorialSidebar: [
22
+ {
23
+ type: 'category',
24
+ label: 'Tutorial',
25
+ items: ['hello'],
26
+ },
27
+ ],
28
+ */
29
+ };
30
+
31
+ module.exports = sidebars;
@@ -0,0 +1,11 @@
1
+ .features {
2
+ display: flex;
3
+ align-items: center;
4
+ padding: 2rem 0;
5
+ width: 100%;
6
+ }
7
+
8
+ .featureSvg {
9
+ height: 200px;
10
+ width: 200px;
11
+ }
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import styles from './HomepageFeatures.module.css';
4
+
5
+ type FeatureItem = {
6
+ title: string;
7
+ description: JSX.Element;
8
+ };
9
+
10
+ const FeatureList: FeatureItem[] = [
11
+ {
12
+ title: 'Easy to use',
13
+ description: (
14
+ <>
15
+ <strong>expressly</strong> was designed for JavaScript developers and inspired by the popular framework, <a href="https://expressjs.com/" target="_blank">Express</a>.
16
+ </>
17
+ ),
18
+ },
19
+ {
20
+ title: 'Focus on what matters',
21
+ description: (
22
+ <>
23
+ <strong>expressly</strong> lets you focus on your business logic, and makes it easier than ever to get started with <a href="https://www.fastly.com/products/edge-compute" target="_blank">Compute@Edge</a>.
24
+ </>
25
+ ),
26
+ },
27
+ {
28
+ title: 'Open source',
29
+ description: (
30
+ <>
31
+ Available for free to make the web a better place! Your contributions are welcomed and appreciated.
32
+ </>
33
+ ),
34
+ },
35
+ ];
36
+
37
+ function Feature({title, description}: FeatureItem) {
38
+ return (
39
+ <div className={clsx('col col--4')}>
40
+ <div className="text--center">
41
+ </div>
42
+ <div className="text--center padding-horiz--md">
43
+ <h3>{title}</h3>
44
+ <p>{description}</p>
45
+ </div>
46
+ </div>
47
+ );
48
+ }
49
+
50
+ export default function HomepageFeatures(): JSX.Element {
51
+ return (
52
+ <section className={styles.features}>
53
+ <div className="container">
54
+ <div className="row">
55
+ {FeatureList.map((props, idx) => (
56
+ <Feature key={idx} {...props} />
57
+ ))}
58
+ </div>
59
+ </div>
60
+ </section>
61
+ );
62
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Any CSS included here will be global. The classic template
3
+ * bundles Infima by default. Infima is a CSS framework designed to
4
+ * work well for content-centric websites.
5
+ */
6
+
7
+ /* You can override the default Infima variables here. */
8
+ :root {
9
+ --ifm-color-primary: #25c2a0;
10
+ --ifm-color-primary-dark: rgb(33, 175, 144);
11
+ --ifm-color-primary-darker: rgb(31, 165, 136);
12
+ --ifm-color-primary-darkest: rgb(26, 136, 112);
13
+ --ifm-color-primary-light: rgb(70, 203, 174);
14
+ --ifm-color-primary-lighter: rgb(102, 212, 189);
15
+ --ifm-color-primary-lightest: rgb(146, 224, 208);
16
+ --ifm-code-font-size: 95%;
17
+ }
18
+
19
+ .docusaurus-highlight-code-line {
20
+ background-color: rgba(0, 0, 0, 0.1);
21
+ display: block;
22
+ margin: 0 calc(-1 * var(--ifm-pre-padding));
23
+ padding: 0 var(--ifm-pre-padding);
24
+ }
25
+
26
+ html[data-theme='dark'] .docusaurus-highlight-code-line {
27
+ background-color: rgba(0, 0, 0, 0.3);
28
+ }
29
+
30
+ html[data-theme='dark'] {
31
+ background-color: #182931;
32
+ }
33
+
34
+ html[data-theme='dark'] .navbar {
35
+ background-color: #303846;
36
+ }
37
+
38
+ .hero-logo {
39
+ border-radius: 10px;
40
+ max-width: 200px;
41
+ }
42
+
43
+ .footer__copyright {
44
+ font-size: 0.8em;
45
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * CSS files with the .module.css suffix will be treated as CSS modules
3
+ * and scoped locally.
4
+ */
5
+
6
+ .heroBanner {
7
+ padding: 4rem 0;
8
+ text-align: center;
9
+ position: relative;
10
+ overflow: hidden;
11
+ background-color: #182931;
12
+ }
13
+
14
+ .heroSubtitle, .heroTitle {
15
+ color: white;
16
+ }
17
+
18
+ .description {
19
+ display: flex;
20
+ align-items: center;
21
+ height:auto;
22
+ margin:auto;
23
+ }
24
+
25
+ @media screen and (max-width: 966px) {
26
+ .heroBanner {
27
+ padding: 2rem;
28
+ }
29
+ }
30
+
31
+ .buttons {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ }
@@ -0,0 +1,109 @@
1
+ import React from "react";
2
+ import clsx from "clsx";
3
+ import Layout from "@theme/Layout";
4
+ import Link from "@docusaurus/Link";
5
+ import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
6
+ import styles from "./index.module.css";
7
+ import HomepageFeatures from "../components/HomepageFeatures";
8
+ import CodeBlock from '@theme/CodeBlock';
9
+
10
+ function HomepageHeader() {
11
+ const { siteConfig } = useDocusaurusContext();
12
+ return (
13
+ <header className={clsx("hero hero--primary", styles.heroBanner)}>
14
+ <div className="container">
15
+
16
+ <img src="/img/logo.png" className="hero-logo" />
17
+ <h1 className={clsx("hero__title", styles.heroTitle)}>{siteConfig.title}</h1>
18
+ <p className={clsx("hero__subtitle", styles.heroSubtitle)}>
19
+ {siteConfig.tagline}
20
+ </p>
21
+ <div className={styles.buttons}>
22
+ <Link
23
+ className="button button--secondary button--lg"
24
+ to="/docs/intro"
25
+ >
26
+ GET STARTED
27
+ </Link>
28
+ </div>
29
+ </div>
30
+ </header>
31
+ );
32
+ }
33
+
34
+ export default function Home(): JSX.Element {
35
+ const exampleCode = `import { Router } from "@fastly/expressly";
36
+
37
+ const router = new Router();
38
+
39
+ router.use((req, res) => {
40
+ res.setHeader("x-powered-by", "expressly");
41
+ });
42
+
43
+ router.get("/", async (req, res) => {
44
+ return res.send("Hello world!");
45
+ });
46
+
47
+ router.listen();`;
48
+
49
+ const { siteConfig } = useDocusaurusContext();
50
+ return (
51
+ <Layout
52
+ title={`Routing for C@E`}
53
+ description="Express-style router for Fastly Compute@Edge"
54
+ >
55
+ <HomepageHeader />
56
+ <main>
57
+ <br />
58
+
59
+ <div className="container">
60
+ <div className="row">
61
+ <div className={clsx("col col--6", styles.description)}>
62
+ <div>
63
+ <h2>Don't waste time on boilerplate code</h2>
64
+ <p>
65
+ <strong>expressly</strong> is a lightweight and minimalist routing layer for
66
+ JavaScript apps running on Fastly's Compute@Edge.
67
+ </p>
68
+ <p>
69
+ <dl>
70
+ <dt>Install <strong>expressly</strong> from <a href="https://www.npmjs.com/package/@fastly/expresly" target="_blank">npm</a>:</dt>
71
+ <dd>
72
+ <CodeBlock
73
+ language="shell"
74
+ showLineNumbers={false}
75
+ >
76
+ npm i @fastly/expressly
77
+ </CodeBlock>
78
+ </dd>
79
+ <dd>
80
+ <CodeBlock
81
+ language="shell"
82
+
83
+ showLineNumbers={false}
84
+ >
85
+ yarn add @fastly/expressly
86
+ </CodeBlock>
87
+ </dd>
88
+ </dl>
89
+ </p>
90
+ </div>
91
+ </div>
92
+ <div className="col col--6">
93
+ <CodeBlock
94
+ language="javascript"
95
+ showLineNumbers={true}
96
+ >
97
+ {exampleCode}
98
+ </CodeBlock>
99
+ </div>
100
+ </div>
101
+ </div>
102
+
103
+ <hr />
104
+
105
+ <HomepageFeatures />
106
+ </main>
107
+ </Layout>
108
+ );
109
+ }
File without changes
Binary file
Binary file
Binary file