create-atom.io 0.0.1 → 0.0.3

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 (94) hide show
  1. package/dist/{create-atom-BV6WVRvY.js → create-atom-BDzJIQOb.js} +28 -12
  2. package/dist/create-atom-BDzJIQOb.js.map +1 -0
  3. package/dist/create-atom.d.ts +5 -5
  4. package/dist/create-atom.d.ts.map +1 -1
  5. package/dist/create-atom.js +2 -2
  6. package/dist/create-atom.x.js +8 -1
  7. package/dist/create-atom.x.js.map +1 -1
  8. package/package.json +10 -10
  9. package/src/create-atom.ts +29 -6
  10. package/src/create-atom.x.ts +7 -0
  11. package/templates/{base → preact-svg-editor}/eslint.config.ts +4 -3
  12. package/templates/preact-svg-editor/eslint.d.ts +31 -0
  13. package/templates/preact-svg-editor/node_modules/.bin/vite +21 -0
  14. package/templates/{base → preact-svg-editor}/package.json +3 -3
  15. package/templates/{base → preact-svg-editor}/src/BezierPlayground.tsx +157 -147
  16. package/templates/{base → preact-svg-editor}/src/index.tsx +6 -4
  17. package/templates/{base → preact-svg-editor}/vite.config.ts +2 -1
  18. package/templates/react-node-backend/.turbo/turbo-build.log +12 -0
  19. package/templates/react-node-backend/README.md +75 -0
  20. package/templates/react-node-backend/_gitignore +24 -0
  21. package/templates/react-node-backend/dist/assets/index-By2j7w9s.css +1 -0
  22. package/templates/react-node-backend/dist/assets/index-DKQCwCeF.js +9 -0
  23. package/templates/react-node-backend/dist/index.html +14 -0
  24. package/templates/react-node-backend/dist/react.svg +1 -0
  25. package/templates/react-node-backend/dist/vite.svg +1 -0
  26. package/templates/react-node-backend/eslint.config.ts +176 -0
  27. package/templates/react-node-backend/index.html +13 -0
  28. package/templates/react-node-backend/node/authenticator.ts +47 -0
  29. package/templates/react-node-backend/node/server.ts +103 -0
  30. package/templates/react-node-backend/node_modules/.bin/conc +21 -0
  31. package/templates/react-node-backend/node_modules/.bin/concurrently +21 -0
  32. package/templates/react-node-backend/node_modules/.bin/eslint +21 -0
  33. package/templates/react-node-backend/node_modules/.bin/tsc +21 -0
  34. package/templates/react-node-backend/node_modules/.bin/tsserver +21 -0
  35. package/templates/react-node-backend/node_modules/.bin/vite +21 -0
  36. package/templates/react-node-backend/package.json +33 -0
  37. package/templates/react-node-backend/public/react.svg +1 -0
  38. package/templates/react-node-backend/public/vite.svg +1 -0
  39. package/templates/react-node-backend/src/App.tsx +69 -0
  40. package/templates/react-node-backend/src/index.css +145 -0
  41. package/templates/react-node-backend/src/main.tsx +12 -0
  42. package/templates/react-node-backend/tsconfig.app.json +28 -0
  43. package/templates/react-node-backend/tsconfig.json +7 -0
  44. package/templates/react-node-backend/tsconfig.node.json +26 -0
  45. package/templates/react-node-backend/vite.config.ts +13 -0
  46. package/dist/create-atom-BV6WVRvY.js.map +0 -1
  47. package/templates/base/node_modules/.bin/browserslist +0 -21
  48. package/templates/base/node_modules/.bin/eslint +0 -21
  49. package/templates/base/node_modules/.bin/jiti +0 -21
  50. package/templates/base/node_modules/.bin/sass +0 -21
  51. package/templates/base/node_modules/.bin/terser +0 -21
  52. package/templates/base/node_modules/.bin/tsc +0 -21
  53. package/templates/base/node_modules/.bin/tsserver +0 -21
  54. package/templates/base/node_modules/.bin/vite +0 -21
  55. package/templates/base/node_modules/.bin/yaml +0 -21
  56. package/templates/base/node_modules/.vite/deps/_metadata.json +0 -82
  57. package/templates/base/node_modules/.vite/deps/atom__io.js +0 -72
  58. package/templates/base/node_modules/.vite/deps/atom__io.js.map +0 -7
  59. package/templates/base/node_modules/.vite/deps/atom__io_react.js +0 -170
  60. package/templates/base/node_modules/.vite/deps/atom__io_react.js.map +0 -7
  61. package/templates/base/node_modules/.vite/deps/chunk-2PJG54YB.js +0 -364
  62. package/templates/base/node_modules/.vite/deps/chunk-2PJG54YB.js.map +0 -7
  63. package/templates/base/node_modules/.vite/deps/chunk-6VZTUEOV.js +0 -3777
  64. package/templates/base/node_modules/.vite/deps/chunk-6VZTUEOV.js.map +0 -7
  65. package/templates/base/node_modules/.vite/deps/chunk-IHAFLL3M.js +0 -204
  66. package/templates/base/node_modules/.vite/deps/chunk-IHAFLL3M.js.map +0 -7
  67. package/templates/base/node_modules/.vite/deps/chunk-LZJKCPXG.js +0 -84
  68. package/templates/base/node_modules/.vite/deps/chunk-LZJKCPXG.js.map +0 -7
  69. package/templates/base/node_modules/.vite/deps/chunk-PJQAIOAR.js +0 -311
  70. package/templates/base/node_modules/.vite/deps/chunk-PJQAIOAR.js.map +0 -7
  71. package/templates/base/node_modules/.vite/deps/chunk-XRJUZPUF.js +0 -17
  72. package/templates/base/node_modules/.vite/deps/chunk-XRJUZPUF.js.map +0 -7
  73. package/templates/base/node_modules/.vite/deps/package.json +0 -3
  74. package/templates/base/node_modules/.vite/deps/preact.js +0 -27
  75. package/templates/base/node_modules/.vite/deps/preact.js.map +0 -7
  76. package/templates/base/node_modules/.vite/deps/preact_compat.js +0 -100
  77. package/templates/base/node_modules/.vite/deps/preact_compat.js.map +0 -7
  78. package/templates/base/node_modules/.vite/deps/preact_debug.js +0 -240
  79. package/templates/base/node_modules/.vite/deps/preact_debug.js.map +0 -7
  80. package/templates/base/node_modules/.vite/deps/preact_devtools.js +0 -7
  81. package/templates/base/node_modules/.vite/deps/preact_devtools.js.map +0 -7
  82. package/templates/base/node_modules/.vite/deps/preact_hooks.js +0 -29
  83. package/templates/base/node_modules/.vite/deps/preact_hooks.js.map +0 -7
  84. package/templates/base/node_modules/.vite/deps/preact_jsx-dev-runtime.js +0 -18
  85. package/templates/base/node_modules/.vite/deps/preact_jsx-dev-runtime.js.map +0 -7
  86. package/templates/base/node_modules/.vite/deps/preact_jsx-runtime.js +0 -18
  87. package/templates/base/node_modules/.vite/deps/preact_jsx-runtime.js.map +0 -7
  88. /package/templates/{base → preact-svg-editor}/_gitignore +0 -0
  89. /package/templates/{base → preact-svg-editor}/index.html +0 -0
  90. /package/templates/{base → preact-svg-editor}/public/preact.svg +0 -0
  91. /package/templates/{base → preact-svg-editor}/src/msg.md +0 -0
  92. /package/templates/{base → preact-svg-editor}/src/style.css +0 -0
  93. /package/templates/{base → preact-svg-editor}/tsconfig.json +0 -0
  94. /package/templates/{base → react-node-backend}/eslint.d.ts +0 -0
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,176 @@
1
+ import { default as TypeScriptPlugin } from "@typescript-eslint/eslint-plugin"
2
+ import * as parser from "@typescript-eslint/parser"
3
+ import AtomIOPlugin from "atom.io/eslint-plugin"
4
+ import type { Linter } from "eslint"
5
+ import * as ImportPlugin from "eslint-plugin-import-x"
6
+ import { default as SimpleImportSortPlugin } from "eslint-plugin-simple-import-sort"
7
+
8
+ const ERROR = 2
9
+
10
+ const parserOptions = {
11
+ project: [`./tsconfig.app.json`, `./tsconfig.node.json`],
12
+ sourceType: `module`,
13
+ } satisfies parser.ParserOptions
14
+
15
+ const commonRules = {
16
+ "@typescript-eslint/adjacent-overload-signatures": ERROR,
17
+ "@typescript-eslint/array-type": 0,
18
+ "@typescript-eslint/await-thenable": 0,
19
+ "@typescript-eslint/ban-ts-comment": ERROR,
20
+ "@typescript-eslint/ban-tslint-comment": 0,
21
+ "@typescript-eslint/class-literal-property-style": ERROR,
22
+ "@typescript-eslint/consistent-generic-constructors": 0,
23
+ "@typescript-eslint/consistent-indexed-object-style": 0,
24
+ "@typescript-eslint/consistent-return": 0,
25
+ "@typescript-eslint/consistent-type-assertions": 0,
26
+ "@typescript-eslint/consistent-type-definitions": 0,
27
+ "@typescript-eslint/consistent-type-exports": ERROR,
28
+ "@typescript-eslint/consistent-type-imports": [
29
+ ERROR,
30
+ {
31
+ fixStyle: `separate-type-imports`,
32
+ prefer: `type-imports`,
33
+ },
34
+ ],
35
+ "@typescript-eslint/default-param-last": ERROR,
36
+ "@typescript-eslint/dot-notation": 0,
37
+ "@typescript-eslint/explicit-function-return-type": 0,
38
+ "@typescript-eslint/explicit-member-accessibility": ERROR,
39
+ "@typescript-eslint/explicit-module-boundary-types": ERROR,
40
+ "@typescript-eslint/init-declarations": 0,
41
+ "@typescript-eslint/max-params": 0,
42
+ "@typescript-eslint/member-ordering": 0,
43
+ "@typescript-eslint/method-signature-style": 0,
44
+ "@typescript-eslint/naming-convention": [
45
+ 0,
46
+ {
47
+ selector: `variable`,
48
+ format: [`strictCamelCase`, `StrictPascalCase`, `UPPER_CASE`],
49
+ leadingUnderscore: `allow`,
50
+ trailingUnderscore: `allow`,
51
+ },
52
+ ],
53
+ "@typescript-eslint/no-array-constructor": ERROR,
54
+ "@typescript-eslint/no-array-delete": ERROR,
55
+ "@typescript-eslint/no-base-to-string": ERROR,
56
+ "@typescript-eslint/no-confusing-non-null-assertion": ERROR,
57
+ "@typescript-eslint/no-confusing-void-expression": ERROR,
58
+ "@typescript-eslint/no-duplicate-enum-values": ERROR,
59
+ "@typescript-eslint/no-duplicate-type-constituents": ERROR,
60
+ "@typescript-eslint/no-dynamic-delete": ERROR,
61
+ "@typescript-eslint/no-empty-function": 0,
62
+ "@typescript-eslint/no-empty-interface": ERROR,
63
+ "@typescript-eslint/no-explicit-any": 0,
64
+ "@typescript-eslint/no-extra-non-null-assertion": ERROR,
65
+ "@typescript-eslint/no-extraneous-class": 0,
66
+ "@typescript-eslint/no-floating-promises": ERROR,
67
+ "@typescript-eslint/no-for-in-array": ERROR,
68
+ "@typescript-eslint/no-implied-eval": ERROR,
69
+ "@typescript-eslint/no-import-type-side-effects": ERROR,
70
+ "@typescript-eslint/no-inferrable-types": 0, // not compatible with isolatedDeclarations
71
+ "@typescript-eslint/no-invalid-void-type": 0, // void is good in unions sometimes?
72
+ "@typescript-eslint/no-loop-func": 0,
73
+ "@typescript-eslint/no-loss-of-precision": ERROR,
74
+ "@typescript-eslint/no-magic-numbers": 0,
75
+ "@typescript-eslint/no-meaningless-void-operator": ERROR,
76
+ "@typescript-eslint/no-misused-new": ERROR,
77
+ "@typescript-eslint/no-misused-promises": 0,
78
+ "@typescript-eslint/no-mixed-enums": ERROR,
79
+ "@typescript-eslint/no-namespace": 0,
80
+ "@typescript-eslint/no-non-null-asserted-nullish-coalescing": ERROR,
81
+ "@typescript-eslint/no-non-null-asserted-optional-chain": ERROR,
82
+ "@typescript-eslint/no-non-null-assertion": 0,
83
+ "@typescript-eslint/no-redundant-type-constituents": ERROR,
84
+ "@typescript-eslint/no-require-imports": ERROR,
85
+ "@typescript-eslint/no-restricted-imports": 0,
86
+ "@typescript-eslint/no-shadow": ERROR,
87
+ "@typescript-eslint/no-this-alias": ERROR,
88
+ "@typescript-eslint/no-throw-literal": 0,
89
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare": 0,
90
+ "@typescript-eslint/no-unnecessary-condition": 0,
91
+ "@typescript-eslint/no-unnecessary-qualifier": 0,
92
+ "@typescript-eslint/no-unnecessary-type-arguments": 0,
93
+ "@typescript-eslint/no-unnecessary-type-assertion": ERROR,
94
+ "@typescript-eslint/no-unnecessary-type-constraint": ERROR,
95
+ "@typescript-eslint/no-unnecessary-type-conversion": ERROR,
96
+ "@typescript-eslint/no-unsafe-argument": 0,
97
+ "@typescript-eslint/no-unsafe-assignment": 0,
98
+ "@typescript-eslint/no-unsafe-call": 0,
99
+ "@typescript-eslint/no-unsafe-member-access": 0,
100
+ "@typescript-eslint/no-unsafe-return": 0,
101
+ "@typescript-eslint/no-unsafe-unary-minus": ERROR,
102
+ "@typescript-eslint/no-unused-expressions": 0,
103
+ "@typescript-eslint/no-unused-vars": 0,
104
+ "@typescript-eslint/no-use-before-define": 0,
105
+ "@typescript-eslint/no-useless-constructor": ERROR,
106
+ "@typescript-eslint/no-useless-empty-export": ERROR,
107
+ "@typescript-eslint/no-var-requires": ERROR,
108
+ "@typescript-eslint/non-nullable-type-assertion-style": 0,
109
+ "@typescript-eslint/only-throw-error": ERROR,
110
+ "@typescript-eslint/parameter-properties": 0,
111
+ "@typescript-eslint/prefer-as-const": ERROR,
112
+ "@typescript-eslint/prefer-destructuring": 0,
113
+ "@typescript-eslint/prefer-enum-initializers": ERROR,
114
+ "@typescript-eslint/prefer-find": ERROR,
115
+ "@typescript-eslint/prefer-for-of": ERROR,
116
+ "@typescript-eslint/prefer-function-type": ERROR,
117
+ "@typescript-eslint/prefer-includes": ERROR,
118
+ "@typescript-eslint/prefer-literal-enum-member": ERROR,
119
+ "@typescript-eslint/prefer-namespace-keyword": ERROR,
120
+ "@typescript-eslint/prefer-nullish-coalescing": ERROR,
121
+ "@typescript-eslint/prefer-optional-chain": ERROR,
122
+ "@typescript-eslint/prefer-promise-reject-errors": 0,
123
+ "@typescript-eslint/prefer-readonly": 0,
124
+ "@typescript-eslint/prefer-readonly-parameter-types": 0,
125
+ "@typescript-eslint/prefer-reduce-type-parameter": 0,
126
+ "@typescript-eslint/prefer-regexp-exec": 0,
127
+ "@typescript-eslint/prefer-return-this-type": ERROR,
128
+ "@typescript-eslint/prefer-string-starts-ends-with": ERROR,
129
+ "@typescript-eslint/prefer-ts-expect-error": ERROR,
130
+ "@typescript-eslint/promise-function-async": 0,
131
+ "@typescript-eslint/require-array-sort-compare": 0,
132
+ "@typescript-eslint/require-await": ERROR,
133
+ "@typescript-eslint/restrict-plus-operands": ERROR,
134
+ "@typescript-eslint/restrict-template-expressions": ERROR,
135
+ "@typescript-eslint/return-await": ERROR,
136
+ "@typescript-eslint/sort-type-constituents": ERROR,
137
+ "@typescript-eslint/strict-boolean-expressions": 0,
138
+ "@typescript-eslint/switch-exhaustiveness-check": [
139
+ ERROR,
140
+ { requireDefaultForNonUnion: true },
141
+ ],
142
+ "@typescript-eslint/triple-slash-reference": ERROR,
143
+ "@typescript-eslint/typedef": 0,
144
+ "@typescript-eslint/unbound-method": 0,
145
+ "@typescript-eslint/unified-signatures": ERROR,
146
+
147
+ "atom.io/explicit-state-types": ERROR,
148
+
149
+ "import/newline-after-import": ERROR,
150
+ "import/no-duplicates": ERROR,
151
+
152
+ "simple-import-sort/imports": ERROR,
153
+ "simple-import-sort/exports": ERROR,
154
+
155
+ "no-mixed-spaces-and-tabs": 0,
156
+ quotes: [ERROR, `backtick`],
157
+ } satisfies Linter.Config[`rules`]
158
+
159
+ const configs: Linter.Config[] = [
160
+ {
161
+ ignores: [`**/dist/**`, `**/gen/**`, `**/node_modules/**`],
162
+ },
163
+ {
164
+ languageOptions: { parser, parserOptions },
165
+ files: [`**/*.ts{,x}`, `eslint.config.ts`],
166
+ plugins: {
167
+ "@typescript-eslint": TypeScriptPlugin,
168
+ "atom.io": AtomIOPlugin,
169
+ import: ImportPlugin,
170
+ "simple-import-sort": SimpleImportSortPlugin,
171
+ },
172
+ rules: commonRules,
173
+ },
174
+ ]
175
+
176
+ export default configs
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>vite-react</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+
3
+ import http from "http"
4
+ import { parse as parseUrl } from "url"
5
+
6
+ const PORT = 4000
7
+ const BACKEND_REDIRECT_URL = `http://localhost:3000/redirect`
8
+
9
+ const server = http.createServer((req, res) => {
10
+ const r = req as http.IncomingMessage & { url: string; method: string }
11
+ const { pathname, query } = parseUrl(r.url, true)
12
+
13
+ if (pathname === `/login` && r.method === `GET`) {
14
+ const html = `
15
+ <html>
16
+ <body style="font-family: sans-serif; text-align: center; margin-top: 50px;">
17
+ <h1>Mock Auth Provider</h1>
18
+ <form action="${BACKEND_REDIRECT_URL}" method="get">
19
+ <input type="hidden" name="token" value="SECRET" />
20
+ <button type="submit" style="font-size: 1.2em;">Sign in</button>
21
+ </form>
22
+ </body>
23
+ </html>
24
+ `
25
+ res.writeHead(200, { "Content-Type": `text/html` })
26
+ return res.end(html)
27
+ }
28
+
29
+ // --- /validate route ---
30
+ if (pathname === `/validate` && r.method === `GET`) {
31
+ const token = query.token
32
+ if (token === `SECRET`) {
33
+ res.writeHead(200, { "Content-Type": `application/json` })
34
+ return res.end(JSON.stringify({ valid: true, user: `mock-user` }))
35
+ }
36
+ res.writeHead(401, { "Content-Type": `application/json` })
37
+ return res.end(JSON.stringify({ valid: false, error: `Invalid token` }))
38
+ }
39
+
40
+ // --- fallback 404 ---
41
+ res.writeHead(404, { "Content-Type": `application/json` })
42
+ res.end(JSON.stringify({ error: `Not found` }))
43
+ })
44
+
45
+ server.listen(PORT, () => {
46
+ console.log(`Mock authenticator running at http://localhost:${PORT}`)
47
+ })
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+
3
+ import * as http from "node:http"
4
+ import { parse as parseUrl } from "node:url"
5
+
6
+ const PORT = process.env.PORT ?? 3000
7
+ const FRONTEND_ORIGIN = process.env.FRONTEND_ORIGIN ?? `http://localhost:5173`
8
+
9
+ function parseCookies(cookieHeader = ``) {
10
+ return Object.fromEntries(
11
+ cookieHeader
12
+ .split(`;`)
13
+ .map((c) => c.trim().split(`=`))
14
+ .filter(([k, v]) => k && v),
15
+ )
16
+ }
17
+
18
+ function sendJSON(
19
+ res: http.ServerResponse,
20
+ status: number,
21
+ data: any,
22
+ cors = false,
23
+ ) {
24
+ const body = JSON.stringify(data)
25
+ const headers: http.OutgoingHttpHeaders = {
26
+ "Content-Type": `application/json`,
27
+ "Content-Length": Buffer.byteLength(body),
28
+ }
29
+ if (cors) {
30
+ headers[`Access-Control-Allow-Origin`] = FRONTEND_ORIGIN
31
+ headers[`Access-Control-Allow-Credentials`] = `true`
32
+ }
33
+ res.writeHead(status, headers)
34
+ res.end(body)
35
+ }
36
+
37
+ const server = http.createServer(async (req, res) => {
38
+ const r = req as http.IncomingMessage & { url: string; method: string }
39
+
40
+ const { pathname, query } = parseUrl(r.url, true)
41
+
42
+ console.log(r.method, pathname, { ...query })
43
+
44
+ const cookies = parseCookies(r.headers.cookie)
45
+
46
+ if (req.method === `OPTIONS`) {
47
+ res.writeHead(204, {
48
+ "Access-Control-Allow-Origin": FRONTEND_ORIGIN,
49
+ "Access-Control-Allow-Credentials": `true`,
50
+ "Access-Control-Allow-Methods": `GET,POST,OPTIONS`,
51
+ "Access-Control-Allow-Headers": `Content-Type`,
52
+ })
53
+ return res.end()
54
+ }
55
+
56
+ // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
57
+ switch (pathname) {
58
+ case `/redirect`: {
59
+ const token = query.token
60
+ if (typeof token !== `string`) {
61
+ sendJSON(res, 400, { error: `Missing token` })
62
+ return
63
+ }
64
+
65
+ res.writeHead(302, {
66
+ "Set-Cookie": `auth_token=${token}; HttpOnly; Path=/; SameSite=Lax; Max-Age=10`,
67
+ "Access-Control-Allow-Origin": FRONTEND_ORIGIN,
68
+ "Access-Control-Allow-Credentials": `true`,
69
+ Location: FRONTEND_ORIGIN,
70
+ })
71
+ return res.end()
72
+ }
73
+ case `/random`: {
74
+ await new Promise((resolve) => setTimeout(resolve, 1000))
75
+ const token = cookies[`auth_token`]
76
+ console.log({ token })
77
+ if (!token) {
78
+ sendJSON(res, 401, { error: `Unauthenticated` }, true)
79
+ return
80
+ }
81
+
82
+ const random = Math.floor(Math.random() * 100)
83
+ sendJSON(res, 200, random, true)
84
+ return
85
+ }
86
+ case `/logout`: {
87
+ res.writeHead(302, {
88
+ "Set-Cookie": `auth_token=; HttpOnly; Path=/; SameSite=Lax; Max-Age=0`,
89
+ "Access-Control-Allow-Origin": FRONTEND_ORIGIN,
90
+ "Access-Control-Allow-Credentials": `true`,
91
+ Location: FRONTEND_ORIGIN,
92
+ })
93
+ return res.end()
94
+ }
95
+ }
96
+
97
+ sendJSON(res, 404, { error: `Not found` })
98
+ })
99
+
100
+ // Start server
101
+ server.listen(PORT, () => {
102
+ console.log(`Server running at http://localhost:${PORT}`)
103
+ })
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/dist/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/dist/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/dist/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/dist/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../concurrently/dist/bin/concurrently.js" "$@"
19
+ else
20
+ exec node "$basedir/../concurrently/dist/bin/concurrently.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/dist/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/dist/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/dist/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/dist/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules/concurrently/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/concurrently@9.2.1/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../concurrently/dist/bin/concurrently.js" "$@"
19
+ else
20
+ exec node "$basedir/../concurrently/dist/bin/concurrently.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/eslint@9.39.1_jiti@2.6.1/node_modules/eslint/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/eslint@9.39.1_jiti@2.6.1/node_modules/eslint/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/eslint@9.39.1_jiti@2.6.1/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/eslint@9.39.1_jiti@2.6.1/node_modules/eslint/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/eslint@9.39.1_jiti@2.6.1/node_modules/eslint/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/eslint@9.39.1_jiti@2.6.1/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../eslint/bin/eslint.js" "$@"
19
+ else
20
+ exec node "$basedir/../eslint/bin/eslint.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsc" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsserver" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/rolldown-vite@7.1.20_@types+node@24.10.0_esbuild@0.25.11_jiti@2.6.1_sass-embedded@1.93._f24e7d6a78bdd13ddcbe63b540231081/node_modules/rolldown-vite/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/rolldown-vite@7.1.20_@types+node@24.10.0_esbuild@0.25.11_jiti@2.6.1_sass-embedded@1.93._f24e7d6a78bdd13ddcbe63b540231081/node_modules/rolldown-vite/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/rolldown-vite@7.1.20_@types+node@24.10.0_esbuild@0.25.11_jiti@2.6.1_sass-embedded@1.93._f24e7d6a78bdd13ddcbe63b540231081/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/wayforge/wayforge/node_modules/.pnpm/rolldown-vite@7.1.20_@types+node@24.10.0_esbuild@0.25.11_jiti@2.6.1_sass-embedded@1.93._f24e7d6a78bdd13ddcbe63b540231081/node_modules/rolldown-vite/bin/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/rolldown-vite@7.1.20_@types+node@24.10.0_esbuild@0.25.11_jiti@2.6.1_sass-embedded@1.93._f24e7d6a78bdd13ddcbe63b540231081/node_modules/rolldown-vite/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/rolldown-vite@7.1.20_@types+node@24.10.0_esbuild@0.25.11_jiti@2.6.1_sass-embedded@1.93._f24e7d6a78bdd13ddcbe63b540231081/node_modules:/home/runner/work/wayforge/wayforge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
19
+ else
20
+ exec node "$basedir/../vite/bin/vite.js" "$@"
21
+ fi
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "react-node-backend",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "concurrently vite ./node/server.ts ./node/authenticator.ts",
8
+ "build": "vite build",
9
+ "lint": "eslint .",
10
+ "preview": "concurrently \"vite preview\" ./node/server.ts ./node/authenticator.ts"
11
+ },
12
+ "dependencies": {
13
+ "atom.io": "0.44.1",
14
+ "react": "19.2.0",
15
+ "react-dom": "19.2.0"
16
+ },
17
+ "devDependencies": {
18
+ "@eslint/js": "9.39.1",
19
+ "@types/node": "24.10.0",
20
+ "@types/react": "19.2.2",
21
+ "@types/react-dom": "19.2.2",
22
+ "@vitejs/plugin-react": "5.1.0",
23
+ "babel-plugin-react-compiler": "1.0.0",
24
+ "concurrently": "9.2.1",
25
+ "eslint": "9.39.1",
26
+ "eslint-plugin-react-hooks": "7.0.1",
27
+ "eslint-plugin-react-refresh": "0.4.24",
28
+ "globals": "16.5.0",
29
+ "typescript": "5.9.3",
30
+ "typescript-eslint": "8.46.3",
31
+ "vite": "npm:rolldown-vite@7.1.20"
32
+ }
33
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,69 @@
1
+ import { atom, type Loadable } from "atom.io"
2
+ import { useLoadable } from "atom.io/react"
3
+
4
+ const SERVER_URL = `http://localhost:3000`
5
+ const AUTHENTICATOR_URL = `http://localhost:4000`
6
+
7
+ const randomAtom = atom<Loadable<number>, Error>({
8
+ key: `random`,
9
+ default: async () => {
10
+ const url = new URL(`/random`, SERVER_URL)
11
+ const response = await fetch(url, { credentials: `include` })
12
+ if (!response.ok) throw new Error(response.status.toString())
13
+ const data = (await response.json()) as unknown
14
+ if (typeof data === `number`) return data
15
+ console.error(`Unexpected response from server`, data)
16
+ return 0
17
+ },
18
+ catch: [Error],
19
+ })
20
+
21
+ function App(): React.JSX.Element {
22
+ const { error, value, loading } = useLoadable(randomAtom, 0)
23
+
24
+ return (
25
+ <main>
26
+ {error ? (
27
+ <article className="takeover">
28
+ <main className="card">
29
+ <h1>Signed Out</h1>
30
+ <button
31
+ type="button"
32
+ onClick={() => {
33
+ window.location.href = `${AUTHENTICATOR_URL}/login`
34
+ }}
35
+ >
36
+ Log in
37
+ </button>
38
+ </main>
39
+ </article>
40
+ ) : null}
41
+ <header>
42
+ {error ? (
43
+ <div className="pfp signed-out" />
44
+ ) : loading ? (
45
+ <div className="pfp loading" />
46
+ ) : (
47
+ <>
48
+ <button
49
+ type="button"
50
+ onClick={() => {
51
+ window.location.href = `${SERVER_URL}/logout`
52
+ }}
53
+ >
54
+ Log out
55
+ </button>
56
+ <div className="pfp signed-in" />
57
+ </>
58
+ )}
59
+ </header>
60
+ {loading ? (
61
+ <div className="data loading">{value}</div>
62
+ ) : (
63
+ <div className="data">{value}</div>
64
+ )}
65
+ </main>
66
+ )
67
+ }
68
+
69
+ export default App