File tree 3 files changed +34
-0
lines changed
3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 9
9
/node_modules /
10
10
11
11
# misc
12
+ .wrangler /
12
13
/.env *
13
14
/.pnp *
14
15
/.sass-cache
Original file line number Diff line number Diff line change 15
15
"lint" : " pnpm -w exec lint" ,
16
16
"lint:types" : " glint" ,
17
17
"lint:fix" : " pnpm -w exec lint fix" ,
18
+ "cf" : " cd dist && npx wrangler pages dev ./" ,
18
19
"start" : " concurrently 'ember serve' 'pnpm _syncPnpm --watch' --names 'serve,sync deps'" ,
19
20
"test:ember" : " ember test --test-port 0" ,
20
21
"_syncPnpm" : " pnpm sync-dependencies-meta-injected" ,
Original file line number Diff line number Diff line change
1
+ import fs from 'node:fs/promises' ;
2
+
3
+ export async function onRequest ( context ) {
4
+ try {
5
+ return errorIfNotFound ( context ) ;
6
+ } catch ( err ) {
7
+ return new Response ( `${ err . message } \n${ err . stack } ` , { status : 500 } ) ;
8
+ }
9
+ }
10
+
11
+ function errorIfNotFound ( context ) {
12
+ const { request, next } = context ;
13
+ const url = new URL ( request . url ) ;
14
+
15
+ /**
16
+ * If the extension ends with gjs
17
+ * or md, we check disk.
18
+ * otherwise we fallback to default behavior.
19
+ */
20
+ let isGJS = url . pathname . endsWith ( '.gjs' ) ;
21
+ let isGTS = url . pathname . endsWith ( '.gts' ) ;
22
+ let isMD = url . pathname . endsWith ( '.md' ) ;
23
+
24
+ let shouldCheck = isGJS || isGTS || isMD ;
25
+
26
+ if ( ! shouldCheck ) {
27
+ // let Cloudflare do its thing
28
+ return await next ( ) ;
29
+ }
30
+
31
+
32
+ }
You can’t perform that action at this time.
0 commit comments