create-qwik 0.0.39 → 0.0.41

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 (42) hide show
  1. package/package.json +1 -1
  2. package/starters/apps/base/package.json +3 -3
  3. package/starters/apps/blank/src/entry.express.tsx +2 -1
  4. package/starters/apps/qwik-city/package.json +1 -1
  5. package/starters/apps/qwik-city/src/components/body/body.tsx +2 -2
  6. package/starters/apps/qwik-city/src/components/breadcrumbs/breadcrumbs.tsx +2 -2
  7. package/starters/apps/qwik-city/src/components/counter/counter.tsx +2 -2
  8. package/starters/apps/qwik-city/src/components/footer/footer.tsx +0 -3
  9. package/starters/apps/qwik-city/src/components/menu/menu.tsx +2 -2
  10. package/starters/apps/qwik-city/src/root.tsx +1 -1
  11. package/starters/apps/qwik-city/src/routes/{about-us.tsx → about-us/index.tsx} +0 -0
  12. package/starters/apps/qwik-city/src/routes/api/[org]/[user].json/index.ts +4 -10
  13. package/starters/apps/qwik-city/src/routes/api/{_layout-foo/api.css → api.css} +0 -0
  14. package/starters/apps/qwik-city/src/routes/api/data.json/index.ts +9 -0
  15. package/starters/apps/qwik-city/src/routes/api/{index@foo.tsx → index@api.tsx} +5 -10
  16. package/starters/apps/qwik-city/src/routes/api/{_layout-foo/index.tsx → layout-api.tsx} +7 -2
  17. package/starters/apps/qwik-city/src/routes/blog/{[...slug].tsx → [...slug]/index.tsx} +3 -3
  18. package/starters/apps/qwik-city/src/routes/blog/{_layout/index.tsx → layout.tsx} +0 -0
  19. package/starters/apps/qwik-city/src/routes/dashboard/dashboard.css +14 -0
  20. package/starters/apps/qwik-city/src/routes/dashboard/index.tsx +2 -4
  21. package/starters/apps/qwik-city/src/routes/dashboard/layout!.tsx +44 -0
  22. package/starters/apps/qwik-city/src/routes/dashboard/{profile@dashboard.tsx → profile/index.tsx} +5 -0
  23. package/starters/apps/qwik-city/src/routes/dashboard/settings/{index@dashboard.tsx → index.tsx} +5 -0
  24. package/starters/apps/qwik-city/src/routes/docs/{_layout!/index.css → docs.css} +0 -0
  25. package/starters/apps/qwik-city/src/routes/docs/{getting-started.md → getting-started/index.md} +0 -0
  26. package/starters/apps/qwik-city/src/routes/docs/{_layout!/index.tsx → layout!.tsx} +5 -5
  27. package/starters/apps/qwik-city/src/routes/docs/{_menu.md → menu.md} +1 -1
  28. package/starters/apps/qwik-city/src/routes/index.tsx +1 -1
  29. package/starters/apps/qwik-city/src/routes/{_layout.tsx → layout.tsx} +0 -0
  30. package/starters/apps/qwik-city/src/routes/products/{[id].tsx → [id]/index.tsx} +35 -44
  31. package/starters/servers/cloudflare-pages/src/entry.cloudflare.tsx +3 -49
  32. package/starters/servers/express/src/entry.express.tsx +18 -7
  33. package/starters/servers/{netlify → netlify-edge}/.node-version +0 -0
  34. package/starters/servers/{netlify → netlify-edge}/README.md +0 -0
  35. package/starters/servers/{netlify → netlify-edge}/netlify.toml +0 -0
  36. package/starters/servers/{netlify → netlify-edge}/package.json +0 -0
  37. package/starters/servers/{netlify → netlify-edge}/public/_headers +0 -0
  38. package/starters/servers/netlify-edge/src/entry.netlify.ts +6 -0
  39. package/starters/servers/{netlify → netlify-edge}/tsconfig.json +0 -0
  40. package/starters/apps/qwik-city/src/routes/api/data.json.ts +0 -13
  41. package/starters/apps/qwik-city/src/routes/dashboard/_layout-dashboard.tsx +0 -18
  42. package/starters/servers/netlify/src/entry.netlify.ts +0 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-qwik",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "Interactive CLI and API for generating Qwik projects.",
5
5
  "bin": "create-qwik",
6
6
  "main": "index.js",
@@ -15,12 +15,12 @@
15
15
  "typecheck": "tsc --incremental --noEmit"
16
16
  },
17
17
  "devDependencies": {
18
- "@builder.io/qwik": "0.0.39",
18
+ "@builder.io/qwik": "0.0.41",
19
19
  "@types/eslint": "8.4.5",
20
20
  "@types/node": "latest",
21
21
  "@typescript-eslint/eslint-plugin": "5.30.7",
22
22
  "@typescript-eslint/parser": "5.30.7",
23
- "eslint-plugin-qwik": "0.0.39",
23
+ "eslint-plugin-qwik": "0.0.41",
24
24
  "eslint": "8.20.0",
25
25
  "node-fetch": "3.2.9",
26
26
  "typescript": "4.7.4",
@@ -30,6 +30,6 @@
30
30
  "homepage": "https://qwik.builder.io/",
31
31
  "private": true,
32
32
  "engines": {
33
- "node": ">=14"
33
+ "node": "^14.18.0 || >=16.0.0"
34
34
  }
35
35
  }
@@ -36,12 +36,13 @@ app.get('/*', async (req, res, next) => {
36
36
  // Render the Root component to a string
37
37
  const result = await render({
38
38
  stream: res,
39
- url: req.url,
40
39
  });
41
40
 
42
41
  // respond with SSR'd HTML
43
42
  if ('html' in result) {
44
43
  res.send((result as any).html);
44
+ } else {
45
+ res.end();
45
46
  }
46
47
  } catch (e) {
47
48
  // Error while server-side rendering
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "type": "module",
16
16
  "devDependencies": {
17
- "@builder.io/qwik-city": "0.0.26",
17
+ "@builder.io/qwik-city": "0.0.30",
18
18
  "vite-tsconfig-paths": "3.5.0"
19
19
  }
20
20
  }
@@ -1,11 +1,11 @@
1
1
  import { component$, Host } from '@builder.io/qwik';
2
- import { Content } from '@builder.io/qwik-city';
2
+ import { RouterOutlet } from '@builder.io/qwik-city';
3
3
 
4
4
  export const Body = component$(
5
5
  () => {
6
6
  return (
7
7
  <Host>
8
- <Content />
8
+ <RouterOutlet />
9
9
  </Host>
10
10
  );
11
11
  },
@@ -1,10 +1,10 @@
1
- import { component$, Host, useScopedStyles$ } from '@builder.io/qwik';
1
+ import { component$, Host, useStyles$ } from '@builder.io/qwik';
2
2
  import { useContent, useLocation, ContentMenu } from '@builder.io/qwik-city';
3
3
  import styles from './breadcrumbs.css?inline';
4
4
 
5
5
  export const Breadcrumbs = component$(
6
6
  () => {
7
- useScopedStyles$(styles);
7
+ useStyles$(styles);
8
8
 
9
9
  const { menu } = useContent();
10
10
  const loc = useLocation();
@@ -1,8 +1,8 @@
1
- import { component$, useScopedStyles$, useStore } from '@builder.io/qwik';
1
+ import { component$, useStyles$, useStore } from '@builder.io/qwik';
2
2
 
3
3
  export const Counter = component$(() => {
4
4
  const store = useStore({ count: 0 });
5
- useScopedStyles$(`
5
+ useStyles$(`
6
6
  .counter {
7
7
  border: 3px solid #1474ff;
8
8
  padding: 10px;
@@ -17,9 +17,6 @@ export default component$(
17
17
  <li>
18
18
  <a href="/about-us">About Us</a>
19
19
  </li>
20
- <li>
21
- <a href="/sign-in">Sign In</a>
22
- </li>
23
20
  <li>
24
21
  <a class="footer-home" href="/">
25
22
  Home
@@ -1,10 +1,10 @@
1
- import { component$, Host, useScopedStyles$ } from '@builder.io/qwik';
1
+ import { component$, Host, useStyles$ } from '@builder.io/qwik';
2
2
  import { useContent, Link, useLocation } from '@builder.io/qwik-city';
3
3
  import styles from './menu.css?inline';
4
4
 
5
5
  export const Menu = component$(
6
6
  () => {
7
- useScopedStyles$(styles);
7
+ useStyles$(styles);
8
8
 
9
9
  const { menu } = useContent();
10
10
  const loc = useLocation();
@@ -6,7 +6,7 @@ import './global.css';
6
6
 
7
7
  export default () => {
8
8
  return (
9
- <Html lang="en">
9
+ <Html lang="en" dir="ltr">
10
10
  <Head />
11
11
  <Body />
12
12
  </Html>
@@ -1,21 +1,15 @@
1
- import type { EndpointHandler } from '@builder.io/qwik-city';
2
- import os from 'os';
1
+ import type { RequestHandler } from '@builder.io/qwik-city';
3
2
 
4
- export const onGet: EndpointHandler = ({ request, params }) => {
3
+ export const onGet: RequestHandler = ({ request, params }) => {
5
4
  return {
6
5
  timestamp: Date.now(),
7
6
  method: request.method,
8
7
  url: request.url,
9
8
  params,
10
- os: os.platform(),
11
- arch: os.arch(),
12
- node: process.versions.node,
13
9
  };
14
10
  };
15
11
 
16
- export const onPost: EndpointHandler = async ({ request, response }) => {
12
+ export const onPost: RequestHandler = async ({ request, response }) => {
17
13
  response.headers.set('Content-Type', 'text/plain');
18
- return `Platform: ${os.platform()}, Node: ${process.versions.node}, HTTP Method: ${
19
- request.method
20
- }`;
14
+ return `HTTP Method: ${request.method}`;
21
15
  };
@@ -0,0 +1,9 @@
1
+ import type { RequestHandler } from '@builder.io/qwik-city';
2
+
3
+ export const onGet: RequestHandler = ({ request }) => {
4
+ return {
5
+ timestamp: Date.now(),
6
+ method: request.method,
7
+ url: request.url,
8
+ };
9
+ };
@@ -1,7 +1,11 @@
1
1
  import { component$, Host, useClientEffect$, useStore } from '@builder.io/qwik';
2
2
 
3
+ /**
4
+ * Uses named layout `foo`
5
+ */
6
+
3
7
  export default component$(() => {
4
- const store = useStore({ timestamp: '', os: '', arch: '', node: '' });
8
+ const store = useStore({ timestamp: '' });
5
9
 
6
10
  useClientEffect$(async () => {
7
11
  const url = `/api/builder.io/oss.json`;
@@ -9,9 +13,6 @@ export default component$(() => {
9
13
  const data: any = await rsp.json();
10
14
 
11
15
  store.timestamp = data.timestamp;
12
- store.os = data.os;
13
- store.arch = data.arch;
14
- store.node = data.node;
15
16
  });
16
17
 
17
18
  return (
@@ -28,12 +29,6 @@ export default component$(() => {
28
29
  </ul>
29
30
 
30
31
  <p>Timestamp: {store.timestamp}</p>
31
- <p>
32
- Node: <span>{store.node}</span>
33
- </p>
34
- <p>
35
- OS: <span>{store.os}</span>
36
- </p>
37
32
  </Host>
38
33
  );
39
34
  });
@@ -1,9 +1,14 @@
1
- import { component$, Host, Slot, useScopedStyles$ } from '@builder.io/qwik';
1
+ import { component$, Host, Slot, useStyles$ } from '@builder.io/qwik';
2
2
  import type { DocumentHead } from '@builder.io/qwik-city';
3
3
  import styles from './api.css?inline';
4
4
 
5
+ /**
6
+ * Named layout `foo`
7
+ * Any index files named `index@foo.tsx` will use this layout
8
+ */
9
+
5
10
  export default component$(() => {
6
- useScopedStyles$(styles);
11
+ useStyles$(styles);
7
12
 
8
13
  return (
9
14
  <Host class="api">
@@ -1,5 +1,5 @@
1
1
  import { component$, Host, Resource } from '@builder.io/qwik';
2
- import { useEndpoint, DocumentHead, EndpointHandler } from '@builder.io/qwik-city';
2
+ import { useEndpoint, DocumentHead, RequestHandler } from '@builder.io/qwik-city';
3
3
 
4
4
  export default component$(() => {
5
5
  const resource = useEndpoint<typeof onGet>();
@@ -19,10 +19,10 @@ export default component$(() => {
19
19
  );
20
20
  });
21
21
 
22
- export const onGet: EndpointHandler<EndpointData> = async ({ params, request }) => {
22
+ export const onGet: RequestHandler<EndpointData> = async ({ params, url }) => {
23
23
  return {
24
24
  blogTitle: `Blog: ${params.slug}`,
25
- blogContent: `${params.slug}, ${request.url}`,
25
+ blogContent: `${params.slug}, ${url.pathname}`,
26
26
  };
27
27
  };
28
28
 
@@ -0,0 +1,14 @@
1
+ .dashboard {
2
+ display: grid;
3
+ grid-template-columns: 200px 1fr;
4
+ padding: 0;
5
+ }
6
+
7
+ .dashboard-menu {
8
+ background: #eee;
9
+ padding-left: 20px;
10
+ }
11
+
12
+ .dashboard-content {
13
+ padding-left: 20px;
14
+ }
@@ -5,13 +5,11 @@ export default component$(() => {
5
5
  return (
6
6
  <Host>
7
7
  <h1>Dashboard</h1>
8
- <p>
9
- <a href="/sign-out">Sign Out</a>
10
- </p>
8
+ <p>Welcome to the dashboard.</p>
11
9
  </Host>
12
10
  );
13
11
  });
14
12
 
15
13
  export const head: DocumentHead = {
16
- title: 'Dashboard',
14
+ title: 'Home',
17
15
  };
@@ -0,0 +1,44 @@
1
+ import { component$, Host, Slot, useStyles$ } from '@builder.io/qwik';
2
+ import type { DocumentHead } from '@builder.io/qwik-city';
3
+ import Footer from '../../components/footer/footer';
4
+ import Header from '../../components/header/header';
5
+ import styles from './dashboard.css?inline';
6
+
7
+ /**
8
+ * `layout!` means this is the top level layout. Because of the
9
+ * `!` at the end of the filename, it stops at this layout and does
10
+ * not keep crawling up the directories making more nested layouts.
11
+ */
12
+
13
+ export default component$(() => {
14
+ useStyles$(styles);
15
+
16
+ return (
17
+ <Host>
18
+ <Header />
19
+ <main class="dashboard">
20
+ <aside class="dashboard-menu">
21
+ <h5>Dashboard Menu</h5>
22
+ <ul>
23
+ <li>
24
+ <a href="/dashboard/profile">Profile</a>
25
+ </li>
26
+ <li>
27
+ <a href="/dashboard/settings">Settings</a>
28
+ </li>
29
+ </ul>
30
+ </aside>
31
+ <section class="dashboard-content">
32
+ <Slot />
33
+ </section>
34
+ </main>
35
+ <Footer />
36
+ </Host>
37
+ );
38
+ });
39
+
40
+ export const head: DocumentHead = ({ head }) => {
41
+ return {
42
+ title: `Dashboard ${head.title}`,
43
+ };
44
+ };
@@ -1,4 +1,5 @@
1
1
  import { component$, Host } from '@builder.io/qwik';
2
+ import type { DocumentHead } from '@builder.io/qwik-city';
2
3
 
3
4
  export default component$(() => {
4
5
  return (
@@ -8,3 +9,7 @@ export default component$(() => {
8
9
  </Host>
9
10
  );
10
11
  });
12
+
13
+ export const head: DocumentHead = {
14
+ title: 'Profile',
15
+ };
@@ -1,4 +1,5 @@
1
1
  import { component$, Host } from '@builder.io/qwik';
2
+ import type { DocumentHead } from '@builder.io/qwik-city';
2
3
 
3
4
  export default component$(() => {
4
5
  return (
@@ -8,3 +9,7 @@ export default component$(() => {
8
9
  </Host>
9
10
  );
10
11
  });
12
+
13
+ export const head: DocumentHead = {
14
+ title: 'Settings',
15
+ };
@@ -1,10 +1,10 @@
1
1
  import { component$, Host, Slot, useStyles$ } from '@builder.io/qwik';
2
2
  import type { DocumentHead } from '@builder.io/qwik-city';
3
- import { Breadcrumbs } from '../../../components/breadcrumbs/breadcrumbs';
4
- import Footer from '../../../components/footer/footer';
5
- import Header from '../../../components/header/header';
6
- import { Menu } from '../../../components/menu/menu';
7
- import styles from './index.css?inline';
3
+ import { Breadcrumbs } from '../../components/breadcrumbs/breadcrumbs';
4
+ import Footer from '../../components/footer/footer';
5
+ import Header from '../../components/header/header';
6
+ import { Menu } from '../../components/menu/menu';
7
+ import styles from './docs.css?inline';
8
8
 
9
9
  export default component$(() => {
10
10
  useStyles$(styles);
@@ -3,7 +3,7 @@
3
3
  ## Introduction
4
4
 
5
5
  - [Overview](overview/index.md)
6
- - [Getting Started](getting-started.md)
6
+ - [Getting Started](getting-started/index.md)
7
7
 
8
8
  ## Components
9
9
 
@@ -4,7 +4,7 @@ import type { DocumentHead } from '@builder.io/qwik-city';
4
4
  export default component$(() => {
5
5
  return (
6
6
  <Host>
7
- <h1 onClick$={() => console.warn('hola')}>Welcome to Qwik City</h1>
7
+ <h1>Welcome to Qwik City</h1>
8
8
 
9
9
  <p>The meta-framework for Qwik.</p>
10
10
  </Host>
@@ -1,10 +1,8 @@
1
- import { Resource, component$, Host, useStore } from '@builder.io/qwik';
2
- import { useEndpoint, useLocation, EndpointHandler, DocumentHead } from '@builder.io/qwik-city';
3
- import os from 'os';
1
+ import { Resource, component$, Host } from '@builder.io/qwik';
2
+ import { useEndpoint, useLocation, RequestHandler, DocumentHead } from '@builder.io/qwik-city';
4
3
 
5
4
  export default component$(() => {
6
- const { params, pathname } = useLocation();
7
- const store = useStore({ productFetchData: '' });
5
+ const { params } = useLocation();
8
6
 
9
7
  const resource = useEndpoint<typeof onGet>();
10
8
 
@@ -30,23 +28,6 @@ export default component$(() => {
30
28
 
31
29
  <p>(Artificial response delay of 250ms)</p>
32
30
 
33
- <p>
34
- <button
35
- onClick$={async () => {
36
- const rsp = await fetch(pathname, {
37
- headers: { accept: 'application/json' },
38
- });
39
- store.productFetchData = JSON.stringify(await rsp.json(), null, 2);
40
- }}
41
- >
42
- fetch("{pathname}") data
43
- </button>
44
- </p>
45
-
46
- <pre>
47
- <code>{store.productFetchData}</code>
48
- </pre>
49
-
50
31
  <hr />
51
32
 
52
33
  <ul>
@@ -67,53 +48,63 @@ export default component$(() => {
67
48
  );
68
49
  });
69
50
 
70
- export const head: DocumentHead<ProductData | null> = ({ data }) => {
51
+ export const head: DocumentHead<EndpointData> = ({ data }) => {
71
52
  if (!data) {
72
53
  return {
73
- title: 'Product Not Found',
54
+ title: `Product not found`,
74
55
  };
75
56
  }
76
-
77
57
  return {
78
58
  title: `Product ${data.productId}, ${data.price}`,
79
59
  };
80
60
  };
81
61
 
82
- export const onGet: EndpointHandler<EndpointData> = async ({ params, response }) => {
62
+ export const onGet: RequestHandler<EndpointData> = async ({ params, response }) => {
83
63
  // Serverside Endpoint
84
64
  // During SSR, this method is called directly on the server and returns the data object
85
65
  // On the client, this same data can be requested with fetch() at the same URL, but also
86
66
  // requires the "accept: application/json" request header.
87
67
 
88
- // artificial slow response
89
- await new Promise<void>((resolve) => setTimeout(resolve, 250));
90
-
91
68
  if (params.id === 'shirt') {
92
69
  // Redirect, which will skip any rendering and the server will immediately redirect
93
- response.redirect('/products/tshirt');
94
- return;
70
+ throw response.redirect('/products/tshirt');
95
71
  }
96
72
 
97
- const productPrice = PRODUCT_DB[params.id];
98
-
99
- if (!productPrice) {
100
- // Product data not found
101
- // but the data is still given to the renderer to decide what to do
73
+ // artificially slow database call
74
+ const productData = await loadProduct(params.id);
75
+ if (!productData) {
76
+ // Product data not found, but the data is still
77
+ // given to the renderer to decide how to render
102
78
  response.status = 404;
103
- return null;
79
+ return productData;
104
80
  }
105
81
 
106
82
  // Found the product data
107
83
  // This same data is passed to the head() function
108
84
  // and in the component$() it can be access with useEndpoint()
109
85
  response.headers.set('Cache-Control', 'no-cache, no-store, no-fun');
110
- return {
111
- productId: params.id,
112
- price: productPrice,
113
- description: `Node ${process.versions.node} ${os.platform()} ${os.arch()} ${
114
- os.cpus()[0].model
115
- }`,
116
- };
86
+ return productData;
87
+ };
88
+
89
+ // our pretty awesome function to load product data
90
+ const loadProduct = (productId: string) => {
91
+ return new Promise<ProductData | null>((resolve) =>
92
+ setTimeout(() => {
93
+ const productPrice = PRODUCT_DB[productId];
94
+ if (productPrice) {
95
+ // awesome product database found product data
96
+ const productData: ProductData = {
97
+ productId,
98
+ price: productPrice,
99
+ description: `Product description here.`,
100
+ };
101
+ resolve(productData);
102
+ } else {
103
+ // awesome product database did not find product data
104
+ resolve(null);
105
+ }
106
+ }, 250)
107
+ );
117
108
  };
118
109
 
119
110
  // Our pretty awesome database of prices
@@ -1,52 +1,6 @@
1
1
  import render from './entry.ssr';
2
+ import { qwikCity } from '@builder.io/qwik-city/middleware/cloudflare-pages';
2
3
 
3
- /**
4
- * Cloudflare Pages Request Handler
5
- */
6
- export const onRequest: PagesFunction = async ({ request, next, waitUntil }) => {
7
- try {
8
- const url = new URL(request.url);
4
+ const qwikCityMiddleware = qwikCity(render);
9
5
 
10
- // Handle static assets
11
- if (/\.\w+$/.test(request.url)) {
12
- return next(request);
13
- }
14
-
15
- // Do not using caching during development
16
- const useCache = url.hostname !== 'localhost' && request.method === 'GET';
17
-
18
- // Early return from cache
19
- const cache = await caches.open('custom:qwik');
20
- if (useCache) {
21
- const cachedResponse = await cache.match(request);
22
- if (cachedResponse) {
23
- return cachedResponse;
24
- }
25
- }
26
-
27
- // Generate Qwik SSR HTML
28
- const result = await render({
29
- url: request.url,
30
- });
31
-
32
- // Create HTTP Response
33
- const response = new Response(result.html, {
34
- headers: {
35
- 'Content-Type': 'text/html; charset=utf-8',
36
- 'Cache-Control': useCache
37
- ? `max-age=60, s-maxage=10, stale-while-revalidate=604800, stale-if-error=604800`
38
- : `no-cache, max-age=0`,
39
- },
40
- });
41
-
42
- if (useCache) {
43
- waitUntil(cache.put(request, response.clone()));
44
- }
45
-
46
- // Return Qwik SSR response
47
- return response;
48
- } catch (e) {
49
- // 500 Error
50
- return new Response(String(e), { status: 500 });
51
- }
52
- };
6
+ export const onRequestGet = [qwikCityMiddleware];
@@ -1,19 +1,30 @@
1
1
  import express from 'express';
2
2
  import { fileURLToPath } from 'url';
3
3
  import { join } from 'path';
4
- import cityPlan from '@qwik-city-plan';
5
4
  import { qwikCity } from '@builder.io/qwik-city/middleware/express';
6
5
  import render from './entry.ssr';
7
6
 
7
+ // directories where the static assets are located
8
+ const distDir = join(fileURLToPath(import.meta.url), '..', '..', 'dist');
9
+ const buildDir = join(distDir, 'build');
10
+
11
+ // create the Qwik City express middleware
12
+ const { router, notFound } = qwikCity(render);
13
+
14
+ // create the express server
8
15
  const app = express();
9
16
 
10
- app.use(
11
- qwikCity(render, {
12
- ...cityPlan,
13
- staticDir: join(fileURLToPath(import.meta.url), '..', '..', 'dist'),
14
- })
15
- );
17
+ // use Qwik City's page and endpoint handler
18
+ app.use(router);
19
+
20
+ // static asset handlers
21
+ app.use(`/build`, express.static(buildDir, { immutable: true, maxAge: '1y', index: false }));
22
+ app.use(express.static(distDir, { index: false }));
23
+
24
+ // use Qwik City's 404 handler
25
+ app.use(notFound);
16
26
 
27
+ // start the express server
17
28
  app.listen(8080, () => {
18
29
  /* eslint-disable */
19
30
  console.log(`http://localhost:8080/`);
@@ -0,0 +1,6 @@
1
+ import render from './entry.ssr';
2
+ import { qwikCity } from '@builder.io/qwik-city/middleware/netlify-edge';
3
+
4
+ const qwikCityHandler = qwikCity(render);
5
+
6
+ export default qwikCityHandler;
@@ -1,13 +0,0 @@
1
- import type { EndpointHandler } from '@builder.io/qwik-city';
2
- import os from 'os';
3
-
4
- export const onGet: EndpointHandler = ({ request }) => {
5
- return {
6
- timestamp: Date.now(),
7
- method: request.method,
8
- url: request.url,
9
- os: os.platform(),
10
- arch: os.arch(),
11
- node: process.versions.node,
12
- };
13
- };
@@ -1,18 +0,0 @@
1
- import { component$, Host, Slot } from '@builder.io/qwik';
2
- import Footer from '../../components/footer/footer';
3
- import Header from '../../components/header/header';
4
-
5
- export default component$(() => {
6
- return (
7
- <Host>
8
- <Header />
9
- <main class="dashboard">
10
- <aside class="dashboard-menu">Dashboard Menu</aside>
11
- <section class="dashboard-content">
12
- <Slot />
13
- </section>
14
- </main>
15
- <Footer />
16
- </Host>
17
- );
18
- });
@@ -1,27 +0,0 @@
1
- import render from './entry.ssr';
2
-
3
- const handler = async (request: Request) => {
4
- try {
5
- // Handle static files
6
- if (/\.\w+$/.test(request.url)) {
7
- return;
8
- }
9
-
10
- const ssrResult = await render({
11
- url: request.url,
12
- base: '/build/',
13
- });
14
-
15
- const response = new Response(ssrResult.html, {
16
- headers: {
17
- 'Content-Type': 'text/html; charset=utf-8',
18
- },
19
- });
20
- return response;
21
- } catch (e) {
22
- // 500 Error
23
- return new Response(String(e), { status: 500 });
24
- }
25
- };
26
-
27
- export default handler;