@quilted/create 0.2.48 → 0.3.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.
- package/CHANGELOG.md +16 -0
- package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/index.mjs +1 -1
- package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/async.mjs +1 -1
- package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/sync.mjs +1 -1
- package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.mjs +1 -1
- package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/index.mjs +1 -1
- package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/async.mjs +1 -1
- package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/sync.mjs +1 -1
- package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.mjs +1 -1
- package/build/esm/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.mjs +1 -1
- package/build/esm/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.mjs +1 -1
- package/build/esnext/_virtual/index7.esnext +2 -2
- package/build/esnext/_virtual/index8.esnext +2 -2
- package/build/esnext/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/async.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/sync.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/async.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/sync.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/dir-glob@3.0.1/node_modules/dir-glob/index.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/utils/index.esnext +1 -1
- package/package.json +1 -1
- package/templates/app-basic/App.tsx +8 -20
- package/templates/app-basic/browser.tsx +0 -1
- package/templates/app-basic/package.json +2 -1
- package/templates/app-basic/server.tsx +16 -16
- package/templates/app-basic/shared/context.ts +2 -2
- package/templates/app-empty/package.json +2 -1
- package/templates/app-empty/server.tsx +6 -7
- package/templates/app-graphql/App.tsx +14 -22
- package/templates/app-graphql/browser.tsx +0 -1
- package/templates/app-graphql/package.json +2 -1
- package/templates/app-graphql/server.tsx +20 -18
- package/templates/app-graphql/shared/context.ts +3 -11
- package/templates/app-graphql/shared/graphql.ts +10 -0
- package/templates/app-trpc/App.tsx +15 -22
- package/templates/app-trpc/browser.tsx +0 -1
- package/templates/app-trpc/package.json +2 -1
- package/templates/app-trpc/server.tsx +28 -30
- package/templates/app-trpc/shared/context.ts +2 -2
- package/templates/server-basic/package.json +1 -1
- package/templates/server-basic/server.ts +2 -2
- package/templates/workspace/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#872](https://github.com/lemonmade/quilt/pull/872) [`8bf65e7`](https://github.com/lemonmade/quilt/commit/8bf65e797f929ee95730323426c229409e65c9a4) Thanks [@lemonmade](https://github.com/lemonmade)! - Replace @quilted/request-router with Hono
|
|
8
|
+
|
|
9
|
+
## 0.2.49
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#871](https://github.com/lemonmade/quilt/pull/871) [`c16b322`](https://github.com/lemonmade/quilt/commit/c16b3224d3c86bc3a3b6f6af44267650d1e8dc1d) Thanks [@lemonmade](https://github.com/lemonmade)! - Remove @quilt/quilt/globals module
|
|
14
|
+
|
|
15
|
+
- [`fc772fb`](https://github.com/lemonmade/quilt/commit/fc772fb47bd077eb10f67a986a9f4ae792f631f0) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix old @quilted/rollup dependency in workspace template
|
|
16
|
+
|
|
17
|
+
- [`64fc42b`](https://github.com/lemonmade/quilt/commit/64fc42b87ca72eec8dfab211d2ddecdbbaa0e4ac) Thanks [@lemonmade](https://github.com/lemonmade)! - Transition browser header helpers to use classes
|
|
18
|
+
|
|
3
19
|
## 0.2.48
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as out } from '../../../../../../../_virtual/
|
|
1
|
+
import { __exports as out } from '../../../../../../../_virtual/index10.mjs';
|
|
2
2
|
import { __require as requireAsync } from './providers/async.mjs';
|
|
3
3
|
import { __require as requireSync } from './providers/sync.mjs';
|
|
4
4
|
import { __require as requireSettings } from './settings.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as out } from '../../../../../../../_virtual/
|
|
1
|
+
import { __exports as out } from '../../../../../../../_virtual/index11.mjs';
|
|
2
2
|
import { __require as requireAsync } from './providers/async.mjs';
|
|
3
3
|
import { __require as requireStream } from './providers/stream.mjs';
|
|
4
4
|
import { __require as requireSync } from './providers/sync.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as settings } from '../../../../../../../_virtual/
|
|
1
|
+
import { __exports as settings } from '../../../../../../../_virtual/settings3.mjs';
|
|
2
2
|
import path__default from 'node:path';
|
|
3
3
|
import { __require as requireOut } from '../../../../../@nodelib_fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/index.mjs';
|
|
4
4
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var dirGlob = {exports: {}};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { dirGlob as __module };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var utils = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { utils as __exports };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as settings } from '../../../../../../../_virtual/
|
|
1
|
+
import { __exports as settings } from '../../../../../../../_virtual/settings3.esnext';
|
|
2
2
|
import path__default from 'node:path';
|
|
3
3
|
import { __require as requireOut } from '../../../../../@nodelib_fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/index.esnext';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as dirGlob } from '../../../../../_virtual/
|
|
1
|
+
import { __module as dirGlob } from '../../../../../_virtual/index7.esnext';
|
|
2
2
|
import path__default from 'node:path';
|
|
3
3
|
import { __require as requirePathType } from '../../../path-type@4.0.0/node_modules/path-type/index.esnext';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as utils } from '../../../../../../../_virtual/
|
|
1
|
+
import { __exports as utils } from '../../../../../../../_virtual/index8.esnext';
|
|
2
2
|
import { __require as requireArray } from './array.esnext';
|
|
3
3
|
import { __require as requireErrno } from './errno.esnext';
|
|
4
4
|
import { __require as requireFs } from './fs.esnext';
|
package/package.json
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {RenderableProps} from 'preact';
|
|
2
|
-
|
|
3
1
|
import {NotFound} from '@quilted/quilt/server';
|
|
4
2
|
import {Navigation} from '@quilted/quilt/navigation';
|
|
5
3
|
import {Localization} from '@quilted/quilt/localize';
|
|
@@ -9,14 +7,11 @@ import {Frame} from './foundation/frame.ts';
|
|
|
9
7
|
|
|
10
8
|
import {Home} from './features/home.ts';
|
|
11
9
|
|
|
12
|
-
import {
|
|
13
|
-
AppContextReact,
|
|
14
|
-
type AppContext as AppContextType,
|
|
15
|
-
} from './shared/context.ts';
|
|
10
|
+
import {AppContextPreact, type AppContext} from './shared/context.ts';
|
|
16
11
|
import {routeWithAppContext} from './shared/navigation.ts';
|
|
17
12
|
|
|
18
13
|
export interface AppProps {
|
|
19
|
-
context:
|
|
14
|
+
context: AppContext;
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
// Define the routes for your application. If you have a lot of routes, you
|
|
@@ -40,20 +35,13 @@ const routes = [
|
|
|
40
35
|
// app-wide context in this component.
|
|
41
36
|
export function App({context}: AppProps) {
|
|
42
37
|
return (
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
<AppContextPreact.Provider value={context}>
|
|
39
|
+
<Localization>
|
|
40
|
+
<Head />
|
|
41
|
+
<Navigation router={context.router} routes={routes} context={context} />
|
|
42
|
+
</Localization>
|
|
43
|
+
</AppContextPreact.Provider>
|
|
47
44
|
);
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
export default App;
|
|
51
|
-
|
|
52
|
-
// This component renders any app-wide context.
|
|
53
|
-
function AppContext({children, context}: RenderableProps<AppProps>) {
|
|
54
|
-
return (
|
|
55
|
-
<AppContextReact.Provider value={context}>
|
|
56
|
-
<Localization>{children}</Localization>
|
|
57
|
-
</AppContextReact.Provider>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
4
|
-
import {Router} from '@quilted/quilt/navigation';
|
|
1
|
+
import {Hono} from 'hono';
|
|
5
2
|
import {
|
|
6
3
|
renderAppToHTMLResponse,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
CacheControlHeader,
|
|
5
|
+
ContentSecurityPolicyHeader,
|
|
6
|
+
PermissionsPolicyHeader,
|
|
7
|
+
StrictTransportSecurityHeader,
|
|
11
8
|
} from '@quilted/quilt/server';
|
|
9
|
+
import {Router} from '@quilted/quilt/navigation';
|
|
12
10
|
|
|
13
11
|
import Env from 'quilt:module/env';
|
|
14
12
|
import {BrowserAssets} from 'quilt:module/assets';
|
|
@@ -17,7 +15,7 @@ import type {AppContext} from '~/shared/context.ts';
|
|
|
17
15
|
|
|
18
16
|
import {App} from './App.tsx';
|
|
19
17
|
|
|
20
|
-
const
|
|
18
|
+
const app = new Hono();
|
|
21
19
|
const assets = new BrowserAssets();
|
|
22
20
|
|
|
23
21
|
class ServerAppContext implements AppContext {
|
|
@@ -29,7 +27,9 @@ class ServerAppContext implements AppContext {
|
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
// For all GET requests, render our Preact application.
|
|
32
|
-
|
|
30
|
+
app.get('*', async (c) => {
|
|
31
|
+
const request = c.req.raw;
|
|
32
|
+
|
|
33
33
|
const context = new ServerAppContext(request);
|
|
34
34
|
|
|
35
35
|
const isHttps = request.url.startsWith('https://');
|
|
@@ -53,7 +53,7 @@ router.get(async (request) => {
|
|
|
53
53
|
// app or deployment, make sure to update this component accordingly!
|
|
54
54
|
//
|
|
55
55
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
|
56
|
-
'Cache-Control':
|
|
56
|
+
'Cache-Control': CacheControlHeader.stringify({
|
|
57
57
|
cache: false,
|
|
58
58
|
}),
|
|
59
59
|
|
|
@@ -64,7 +64,7 @@ router.get(async (request) => {
|
|
|
64
64
|
// to the allowlist for more specific directives.
|
|
65
65
|
//
|
|
66
66
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
|
67
|
-
'Content-Security-Policy':
|
|
67
|
+
'Content-Security-Policy': ContentSecurityPolicyHeader.stringify({
|
|
68
68
|
// By default, only allow sources from the page's origin.
|
|
69
69
|
defaultSources: ["'self'"],
|
|
70
70
|
// In development, allow connections to local websockets for hot reloading.
|
|
@@ -89,8 +89,8 @@ router.get(async (request) => {
|
|
|
89
89
|
// Sets a strict permissions policy for this page, which limits access
|
|
90
90
|
// to some native browser features.
|
|
91
91
|
//
|
|
92
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/
|
|
93
|
-
'Permissions-Policy':
|
|
92
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy
|
|
93
|
+
'Permissions-Policy': PermissionsPolicyHeader.stringify({
|
|
94
94
|
// Disables Google's Federated Learning of Cohorts ("FLoC") tracking initiative.
|
|
95
95
|
// @see https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea
|
|
96
96
|
interestCohort: false,
|
|
@@ -110,11 +110,11 @@ router.get(async (request) => {
|
|
|
110
110
|
// Instructs browsers to only load this page over HTTPS.
|
|
111
111
|
//
|
|
112
112
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
|
|
113
|
-
'Strict-Transport-Security':
|
|
113
|
+
'Strict-Transport-Security': StrictTransportSecurityHeader.stringify(),
|
|
114
114
|
},
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
return response;
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
export default
|
|
120
|
+
export default app;
|
|
@@ -2,5 +2,5 @@ import {createOptionalContext} from '@quilted/quilt/context';
|
|
|
2
2
|
|
|
3
3
|
export interface AppContext {}
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
export const useAppContext =
|
|
5
|
+
export const AppContextPreact = createOptionalContext<AppContext>();
|
|
6
|
+
export const useAppContext = AppContextPreact.use;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
1
|
+
import {Hono} from 'hono';
|
|
4
2
|
import {renderAppToHTMLResponse} from '@quilted/quilt/server';
|
|
5
3
|
import {BrowserAssets} from 'quilt:module/assets';
|
|
6
4
|
|
|
7
5
|
import {App} from './App.tsx';
|
|
8
6
|
|
|
9
|
-
const
|
|
7
|
+
const app = new Hono();
|
|
10
8
|
const assets = new BrowserAssets();
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
app.get('*', async (c) => {
|
|
11
|
+
const request = c.req.raw;
|
|
12
|
+
|
|
14
13
|
const response = await renderAppToHTMLResponse(<App />, {
|
|
15
14
|
request,
|
|
16
15
|
assets,
|
|
@@ -19,4 +18,4 @@ router.get(async (request) => {
|
|
|
19
18
|
return response;
|
|
20
19
|
});
|
|
21
20
|
|
|
22
|
-
export default
|
|
21
|
+
export default app;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {RenderableProps} from 'preact';
|
|
2
|
-
|
|
3
1
|
import {NotFound} from '@quilted/quilt/server';
|
|
4
2
|
import {GraphQLContext} from '@quilted/quilt/graphql';
|
|
5
3
|
import {Navigation} from '@quilted/quilt/navigation';
|
|
@@ -10,14 +8,11 @@ import {Frame} from './foundation/frame.ts';
|
|
|
10
8
|
|
|
11
9
|
import {Home, homeQuery} from './features/home.ts';
|
|
12
10
|
|
|
13
|
-
import {
|
|
14
|
-
AppContextReact,
|
|
15
|
-
type AppContext as AppContextType,
|
|
16
|
-
} from './shared/context.ts';
|
|
11
|
+
import {AppContextPreact, type AppContext} from './shared/context.ts';
|
|
17
12
|
import {routeWithAppContext} from './shared/navigation.ts';
|
|
18
13
|
|
|
19
14
|
export interface AppProps {
|
|
20
|
-
context:
|
|
15
|
+
context: AppContext;
|
|
21
16
|
}
|
|
22
17
|
|
|
23
18
|
// Define the routes for your application. If you have a lot of routes, you
|
|
@@ -41,25 +36,22 @@ const routes = [
|
|
|
41
36
|
// app-wide context in this component.
|
|
42
37
|
export function App({context}: AppProps) {
|
|
43
38
|
return (
|
|
44
|
-
<
|
|
45
|
-
<Head />
|
|
46
|
-
<Navigation router={context.router} routes={routes} context={context} />
|
|
47
|
-
</AppContext>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default App;
|
|
52
|
-
|
|
53
|
-
// This component renders any app-wide context.
|
|
54
|
-
function AppContext({children, context}: RenderableProps<AppProps>) {
|
|
55
|
-
return (
|
|
56
|
-
<AppContextReact.Provider value={context}>
|
|
39
|
+
<AppContextPreact.Provider value={context}>
|
|
57
40
|
<GraphQLContext
|
|
58
41
|
fetch={context.graphql.fetch}
|
|
59
42
|
cache={context.graphql.cache}
|
|
60
43
|
>
|
|
61
|
-
<Localization>
|
|
44
|
+
<Localization>
|
|
45
|
+
<Head />
|
|
46
|
+
<Navigation
|
|
47
|
+
router={context.router}
|
|
48
|
+
routes={routes}
|
|
49
|
+
context={context}
|
|
50
|
+
/>
|
|
51
|
+
</Localization>
|
|
62
52
|
</GraphQLContext>
|
|
63
|
-
</
|
|
53
|
+
</AppContextPreact.Provider>
|
|
64
54
|
);
|
|
65
55
|
}
|
|
56
|
+
|
|
57
|
+
export default App;
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
"dependencies": {},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@quilted/graphql-tools": "^0.2.0",
|
|
19
|
-
"@quilted/quilt": "^0.
|
|
19
|
+
"@quilted/quilt": "^0.9.0",
|
|
20
20
|
"graphql": "^16.8.0",
|
|
21
|
+
"hono": "^4.8.0",
|
|
21
22
|
"jsdom": "^26.0.0",
|
|
22
23
|
"preact": "^10.26.0",
|
|
23
24
|
"react": "npm:@quilted/react@^19.0.0",
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
import {RequestRouter, JSONResponse} from '@quilted/quilt/request-router';
|
|
1
|
+
import {Hono} from 'hono';
|
|
4
2
|
import {Router} from '@quilted/quilt/navigation';
|
|
5
3
|
import {
|
|
6
4
|
renderAppToHTMLResponse,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
CacheControlHeader,
|
|
6
|
+
ContentSecurityPolicyHeader,
|
|
7
|
+
PermissionsPolicyHeader,
|
|
8
|
+
StrictTransportSecurityHeader,
|
|
11
9
|
} from '@quilted/quilt/server';
|
|
12
10
|
import {GraphQLCache} from '@quilted/quilt/graphql';
|
|
13
11
|
|
|
@@ -16,7 +14,7 @@ import {BrowserAssets} from 'quilt:module/assets';
|
|
|
16
14
|
|
|
17
15
|
import type {AppContext} from '~/shared/context.ts';
|
|
18
16
|
|
|
19
|
-
const
|
|
17
|
+
const app = new Hono();
|
|
20
18
|
const assets = new BrowserAssets();
|
|
21
19
|
|
|
22
20
|
class ServerAppContext implements AppContext {
|
|
@@ -39,7 +37,9 @@ class ServerAppContext implements AppContext {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
// GraphQL API, called from the client
|
|
42
|
-
|
|
40
|
+
app.post('/api/graphql', async (c) => {
|
|
41
|
+
const request = c.req.raw;
|
|
42
|
+
|
|
43
43
|
const [{query, operationName, variables}, {performGraphQLOperation}] =
|
|
44
44
|
await Promise.all([request.json(), import('./server/graphql.ts')]);
|
|
45
45
|
|
|
@@ -48,11 +48,13 @@ router.post('/api/graphql', async (request) => {
|
|
|
48
48
|
operationName,
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
return
|
|
51
|
+
return Response.json(result);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
//
|
|
55
|
-
|
|
54
|
+
// Preact app
|
|
55
|
+
app.get('*', async (c) => {
|
|
56
|
+
const request = c.req.raw;
|
|
57
|
+
|
|
56
58
|
const [{App}] = await Promise.all([import('./App.tsx')]);
|
|
57
59
|
|
|
58
60
|
const context = new ServerAppContext(request);
|
|
@@ -78,7 +80,7 @@ router.get(async (request) => {
|
|
|
78
80
|
// app or deployment, make sure to update this component accordingly!
|
|
79
81
|
//
|
|
80
82
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
|
81
|
-
'Cache-Control':
|
|
83
|
+
'Cache-Control': CacheControlHeader.stringify({
|
|
82
84
|
cache: false,
|
|
83
85
|
}),
|
|
84
86
|
|
|
@@ -89,7 +91,7 @@ router.get(async (request) => {
|
|
|
89
91
|
// to the allowlist for more specific directives.
|
|
90
92
|
//
|
|
91
93
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
|
92
|
-
'Content-Security-Policy':
|
|
94
|
+
'Content-Security-Policy': ContentSecurityPolicyHeader.stringify({
|
|
93
95
|
// By default, only allow sources from the page's origin.
|
|
94
96
|
defaultSources: ["'self'"],
|
|
95
97
|
// In development, allow connections to local websockets for hot reloading.
|
|
@@ -114,8 +116,8 @@ router.get(async (request) => {
|
|
|
114
116
|
// Sets a strict permissions policy for this page, which limits access
|
|
115
117
|
// to some native browser features.
|
|
116
118
|
//
|
|
117
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/
|
|
118
|
-
'Permissions-Policy':
|
|
119
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy
|
|
120
|
+
'Permissions-Policy': PermissionsPolicyHeader.stringify({
|
|
119
121
|
// Disables Google's Federated Learning of Cohorts ("FLoC") tracking initiative.
|
|
120
122
|
// @see https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea
|
|
121
123
|
interestCohort: false,
|
|
@@ -135,11 +137,11 @@ router.get(async (request) => {
|
|
|
135
137
|
// Instructs browsers to only load this page over HTTPS.
|
|
136
138
|
//
|
|
137
139
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
|
|
138
|
-
'Strict-Transport-Security':
|
|
140
|
+
'Strict-Transport-Security': StrictTransportSecurityHeader.stringify(),
|
|
139
141
|
},
|
|
140
142
|
});
|
|
141
143
|
|
|
142
144
|
return response;
|
|
143
145
|
});
|
|
144
146
|
|
|
145
|
-
export default
|
|
147
|
+
export default app;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import {createOptionalContext} from '@quilted/quilt/context';
|
|
2
|
-
import type {Router} from '@quilted/quilt/navigation';
|
|
3
|
-
import type {GraphQLFetch, GraphQLCache} from '@quilted/quilt/graphql';
|
|
4
2
|
|
|
5
|
-
export interface AppContext {
|
|
6
|
-
readonly router: Router;
|
|
7
|
-
readonly graphql: {
|
|
8
|
-
readonly fetch: GraphQLFetch<any>;
|
|
9
|
-
readonly cache: GraphQLCache;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
3
|
+
export interface AppContext {}
|
|
12
4
|
|
|
13
|
-
export const
|
|
14
|
-
export const useAppContext =
|
|
5
|
+
export const AppContextPreact = createOptionalContext<AppContext>();
|
|
6
|
+
export const useAppContext = AppContextPreact.use;
|
|
@@ -2,8 +2,18 @@ import type {GraphQLFetch, GraphQLCache} from '@quilted/quilt/graphql';
|
|
|
2
2
|
|
|
3
3
|
declare module '~/shared/context.ts' {
|
|
4
4
|
interface AppContext {
|
|
5
|
+
/**
|
|
6
|
+
* The app’s GraphQL client.
|
|
7
|
+
*/
|
|
5
8
|
readonly graphql: {
|
|
9
|
+
/**
|
|
10
|
+
* A function to perform GraphQL operations.
|
|
11
|
+
*/
|
|
6
12
|
readonly fetch: GraphQLFetch;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The app’s GraphQL cache.
|
|
16
|
+
*/
|
|
7
17
|
readonly cache: GraphQLCache;
|
|
8
18
|
};
|
|
9
19
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {RenderableProps} from 'preact';
|
|
2
|
-
|
|
3
1
|
import {NotFound} from '@quilted/quilt/server';
|
|
4
2
|
import {Navigation} from '@quilted/quilt/navigation';
|
|
5
3
|
import {Localization} from '@quilted/quilt/localize';
|
|
@@ -13,7 +11,7 @@ import {Home} from './features/home.ts';
|
|
|
13
11
|
|
|
14
12
|
import {trpc} from './shared/trpc.ts';
|
|
15
13
|
import {
|
|
16
|
-
|
|
14
|
+
AppContextPreact,
|
|
17
15
|
type AppContext as AppContextType,
|
|
18
16
|
} from './shared/context.ts';
|
|
19
17
|
import {routeWithAppContext} from './shared/navigation.ts';
|
|
@@ -43,26 +41,21 @@ const routes = [
|
|
|
43
41
|
// app-wide context in this component.
|
|
44
42
|
export function App({context}: AppProps) {
|
|
45
43
|
return (
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
<AppContextPreact.Provider value={context}>
|
|
45
|
+
<trpc.Provider client={context.trpc} queryClient={context.queryClient}>
|
|
46
|
+
<ReactQueryContext client={context.queryClient}>
|
|
47
|
+
<Localization>
|
|
48
|
+
<Head />
|
|
49
|
+
<Navigation
|
|
50
|
+
router={context.router}
|
|
51
|
+
routes={routes}
|
|
52
|
+
context={context}
|
|
53
|
+
/>
|
|
54
|
+
</Localization>
|
|
55
|
+
</ReactQueryContext>
|
|
56
|
+
</trpc.Provider>
|
|
57
|
+
</AppContextPreact.Provider>
|
|
50
58
|
);
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
export default App;
|
|
54
|
-
|
|
55
|
-
// This component renders any app-wide context.
|
|
56
|
-
function AppContext({children, context}: RenderableProps<AppProps>) {
|
|
57
|
-
return (
|
|
58
|
-
<AppContextReact.Provider value={context}>
|
|
59
|
-
<Localization>
|
|
60
|
-
<trpc.Provider client={context.trpc} queryClient={context.queryClient}>
|
|
61
|
-
<ReactQueryContext client={context.queryClient}>
|
|
62
|
-
{children}
|
|
63
|
-
</ReactQueryContext>
|
|
64
|
-
</trpc.Provider>
|
|
65
|
-
</Localization>
|
|
66
|
-
</AppContextReact.Provider>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@quilted/quilt": "^0.
|
|
18
|
+
"@quilted/quilt": "^0.9.0",
|
|
19
19
|
"@quilted/react-query": "^0.4.0",
|
|
20
20
|
"@quilted/trpc": "^0.2.0",
|
|
21
21
|
"@tanstack/react-query": "^5.0.0",
|
|
22
22
|
"@trpc/client": "next",
|
|
23
23
|
"@trpc/react-query": "next",
|
|
24
24
|
"@trpc/server": "next",
|
|
25
|
+
"hono": "^4.8.0",
|
|
25
26
|
"jsdom": "^26.0.0",
|
|
26
27
|
"preact": "^10.26.0",
|
|
27
28
|
"react": "npm:@quilted/react@^19.0.0",
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
4
|
-
import {Router} from '@quilted/quilt/navigation';
|
|
1
|
+
import {Hono} from 'hono';
|
|
5
2
|
import {
|
|
6
3
|
renderAppToHTMLResponse,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
CacheControlHeader,
|
|
5
|
+
ContentSecurityPolicyHeader,
|
|
6
|
+
PermissionsPolicyHeader,
|
|
7
|
+
StrictTransportSecurityHeader,
|
|
11
8
|
} from '@quilted/quilt/server';
|
|
9
|
+
import {Router} from '@quilted/quilt/navigation';
|
|
12
10
|
|
|
13
11
|
import Env from 'quilt:module/env';
|
|
14
12
|
import {BrowserAssets} from 'quilt:module/assets';
|
|
@@ -21,7 +19,7 @@ import type {AppContext} from '~/shared/context.ts';
|
|
|
21
19
|
|
|
22
20
|
import {appRouter} from './trpc.ts';
|
|
23
21
|
|
|
24
|
-
const
|
|
22
|
+
const app = new Hono();
|
|
25
23
|
const assets = new BrowserAssets();
|
|
26
24
|
|
|
27
25
|
class ServerAppContext implements AppContext {
|
|
@@ -36,21 +34,21 @@ class ServerAppContext implements AppContext {
|
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
// TRPC API
|
|
38
|
+
app.all('/api/*', async (c) => {
|
|
39
|
+
const request = c.req.raw;
|
|
40
|
+
return fetchRequestHandler({
|
|
41
|
+
endpoint: '/api',
|
|
42
|
+
req: request,
|
|
43
|
+
router: appRouter,
|
|
44
|
+
createContext: () => ({}),
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Preact app
|
|
49
|
+
app.get('*', async (c) => {
|
|
50
|
+
const request = c.req.raw;
|
|
51
|
+
|
|
54
52
|
const [{App}] = await Promise.all([import('./App.tsx')]);
|
|
55
53
|
|
|
56
54
|
const context = new ServerAppContext(request);
|
|
@@ -76,7 +74,7 @@ router.get(async (request) => {
|
|
|
76
74
|
// app or deployment, make sure to update this component accordingly!
|
|
77
75
|
//
|
|
78
76
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
|
79
|
-
'Cache-Control':
|
|
77
|
+
'Cache-Control': CacheControlHeader.stringify({
|
|
80
78
|
cache: false,
|
|
81
79
|
}),
|
|
82
80
|
|
|
@@ -87,7 +85,7 @@ router.get(async (request) => {
|
|
|
87
85
|
// to the allowlist for more specific directives.
|
|
88
86
|
//
|
|
89
87
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
|
90
|
-
'Content-Security-Policy':
|
|
88
|
+
'Content-Security-Policy': ContentSecurityPolicyHeader.stringify({
|
|
91
89
|
// By default, only allow sources from the page's origin.
|
|
92
90
|
defaultSources: ["'self'"],
|
|
93
91
|
// In development, allow connections to local websockets for hot reloading.
|
|
@@ -112,8 +110,8 @@ router.get(async (request) => {
|
|
|
112
110
|
// Sets a strict permissions policy for this page, which limits access
|
|
113
111
|
// to some native browser features.
|
|
114
112
|
//
|
|
115
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/
|
|
116
|
-
'Permissions-Policy':
|
|
113
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy
|
|
114
|
+
'Permissions-Policy': PermissionsPolicyHeader.stringify({
|
|
117
115
|
// Disables Google's Federated Learning of Cohorts ("FLoC") tracking initiative.
|
|
118
116
|
// @see https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea
|
|
119
117
|
interestCohort: false,
|
|
@@ -133,11 +131,11 @@ router.get(async (request) => {
|
|
|
133
131
|
// Instructs browsers to only load this page over HTTPS.
|
|
134
132
|
//
|
|
135
133
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
|
|
136
|
-
'Strict-Transport-Security':
|
|
134
|
+
'Strict-Transport-Security': StrictTransportSecurityHeader.stringify(),
|
|
137
135
|
},
|
|
138
136
|
});
|
|
139
137
|
|
|
140
138
|
return response;
|
|
141
139
|
});
|
|
142
140
|
|
|
143
|
-
export default
|
|
141
|
+
export default app;
|
|
@@ -2,5 +2,5 @@ import {createOptionalContext} from '@quilted/quilt/context';
|
|
|
2
2
|
|
|
3
3
|
export interface AppContext {}
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
export const useAppContext =
|
|
5
|
+
export const AppContextPreact = createOptionalContext<AppContext>();
|
|
6
|
+
export const useAppContext = AppContextPreact.use;
|