Skip to content

Commit 47e2033

Browse files
committed
cleanup
1 parent 796731b commit 47e2033

74 files changed

Lines changed: 966 additions & 7864 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
1-
# Example environment variables for local dev, test, and preview deploys.
2-
# Copy this to `.env` for local development and local tests.
3-
4-
# Required
5-
COOKIE_SECRET=79c7d07db29567bc273192c55b1a613bfdc73097c134ef00573a372c51c2ae78
6-
71
# Optional (preview uses request origin by default)
82
APP_BASE_URL=
9-
10-
# Resend (optional; preview deploys overwrite these to point at the mock services)
11-
RESEND_API_BASE_URL=
12-
RESEND_API_KEY=
13-
RESEND_FROM_EMAIL=reset@epic-scheduler.dev
14-
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
# Example environment variables for local dev, test, and preview deploys.
22
# Copy this to `.env` for local development and local tests.
33

4-
# Required
5-
COOKIE_SECRET=LOCAL_AND_PREVIEW_COOKIE_SECRET_32_CHARS_MINIMUM
6-
74
# Optional (preview uses request origin by default)
85
APP_BASE_URL=
96

10-
# Resend (optional; preview deploys overwrite these to point at the mock services)
11-
RESEND_API_BASE_URL=
12-
RESEND_API_KEY=
13-
RESEND_FROM_EMAIL=reset@epic-scheduler.dev
14-

exercises/01.building-an-mvp/04.solution.implementation/AGENTS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ This file is intentionally brief. Detailed instructions live in focused docs:
2424
- Architecture references:
2525
- [docs/architecture/index.md](./docs/architecture/index.md)
2626
- [docs/architecture/request-lifecycle.md](./docs/architecture/request-lifecycle.md)
27-
- [docs/architecture/authentication.md](./docs/architecture/authentication.md)
2827
- [docs/architecture/data-storage.md](./docs/architecture/data-storage.md)

exercises/01.building-an-mvp/04.solution.implementation/cli.ts

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { spawn, type ChildProcess } from 'node:child_process'
2-
import { randomUUID } from 'node:crypto'
32
import { platform } from 'node:os'
43
import readline from 'node:readline'
54
import { setTimeout as delay } from 'node:timers/promises'
65
import getPort, { clearLockedPorts } from 'get-port'
76

87
const defaultWorkerPort = 3742
9-
const defaultMockPort = 8788
10-
const mockReadyTimeoutMs = 10_000
11-
const mockReadyPollMs = 200
128

139
const ansiReset = '\x1b[0m'
1410
const ansiBright = '\x1b[1m'
@@ -48,8 +44,6 @@ const extraArgs = process.argv.slice(2)
4844
let shutdown: (() => void) | null = null
4945
let devChildren: Array<ChildProcess> = []
5046
let workerOrigin = ''
51-
let mockResendProcess: ChildProcess | null = null
52-
let mockEnvOverrides: Record<string, string> = {}
5347

5448
void startDev()
5549

@@ -61,7 +55,7 @@ async function startDev() {
6155
})
6256
shutdown = setupShutdown(
6357
() => devChildren,
64-
() => mockResendProcess,
58+
() => null,
6559
)
6660
}
6761

@@ -230,7 +224,6 @@ async function restartDev(
230224
{ announce }: { announce: boolean } = { announce: true },
231225
) {
232226
await stopChildren(devChildren)
233-
const mockEnv = await ensureMockServers()
234227
const desiredPort = Number.parseInt(
235228
process.env.PORT ?? String(defaultWorkerPort),
236229
10,
@@ -253,7 +246,7 @@ async function restartDev(
253246
const worker = runNpmScript(
254247
'dev:worker',
255248
extraArgs,
256-
{ PORT: String(workerPort), ...mockEnv },
249+
{ PORT: String(workerPort) },
257250
{ outputFilter: 'worker' },
258251
)
259252
devChildren = [client, worker]
@@ -264,87 +257,6 @@ async function restartDev(
264257
}
265258
}
266259

267-
function hasEnvValue(value: string | undefined) {
268-
return typeof value === 'string' && value.trim().length > 0
269-
}
270-
271-
async function isMockReady(baseUrl: string) {
272-
try {
273-
const response = await fetch(`${baseUrl}/__mocks/meta`)
274-
await response.body?.cancel()
275-
return response.ok
276-
} catch {
277-
return false
278-
}
279-
}
280-
281-
async function waitForMockReady(baseUrl: string, child: ChildProcess) {
282-
const start = Date.now()
283-
while (Date.now() - start < mockReadyTimeoutMs) {
284-
if (child.killed || child.exitCode !== null) {
285-
return false
286-
}
287-
if (await isMockReady(baseUrl)) {
288-
return true
289-
}
290-
await delay(mockReadyPollMs)
291-
}
292-
return false
293-
}
294-
295-
async function ensureMockServers() {
296-
if (
297-
mockResendProcess &&
298-
!mockResendProcess.killed &&
299-
mockResendProcess.exitCode === null
300-
) {
301-
return mockEnvOverrides
302-
}
303-
const desiredPort = Number.parseInt(
304-
process.env.MOCK_API_PORT ?? String(defaultMockPort),
305-
10,
306-
)
307-
const portRange = Array.from(
308-
{ length: 10 },
309-
(_, index) => desiredPort + index,
310-
)
311-
const mockPort = await getPort({ port: portRange })
312-
const baseUrl = `http://127.0.0.1:${mockPort}`
313-
const apiToken = `mock-resend-${randomUUID()}`
314-
const child = runNpmScript(
315-
'dev:mock-resend',
316-
[
317-
'--port',
318-
String(mockPort),
319-
'--ip',
320-
'127.0.0.1',
321-
'--var',
322-
`MOCK_API_TOKEN:${apiToken}`,
323-
],
324-
{},
325-
)
326-
mockResendProcess = child
327-
child.once('exit', () => {
328-
mockResendProcess = null
329-
})
330-
mockEnvOverrides = {
331-
RESEND_API_BASE_URL: baseUrl,
332-
RESEND_API_KEY: apiToken,
333-
}
334-
if (!hasEnvValue(process.env.RESEND_FROM_EMAIL)) {
335-
mockEnvOverrides.RESEND_FROM_EMAIL = 'reset@epic-scheduler.dev'
336-
}
337-
const didStart = await waitForMockReady(baseUrl, child)
338-
if (!didStart) {
339-
console.warn(
340-
`Mock API worker did not become ready within ${mockReadyTimeoutMs}ms.`,
341-
)
342-
}
343-
console.log(dim(`Mock API worker running at ${baseUrl}`))
344-
console.log(dim(`Resend mock base URL ${baseUrl}`))
345-
return mockEnvOverrides
346-
}
347-
348260
async function stopChildren(children: Array<ChildProcess>) {
349261
await Promise.all(children.map((child) => stopChild(child)))
350262
}

exercises/01.building-an-mvp/04.solution.implementation/client/app-session-refresh.test.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

exercises/01.building-an-mvp/04.solution.implementation/client/auth-links.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)