Skip to content

Commit b9e8dbd

Browse files
committed
reduce files at top level
1 parent 5c874f3 commit b9e8dbd

File tree

10 files changed

+23
-23
lines changed

10 files changed

+23
-23
lines changed

app.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import {
1010
type GitHubApiClient,
1111
RealGitHubApiClient,
1212
} from "./lib/github-api-client.ts";
13-
import { ConfigProvider } from "./config.ts";
14-
import { LoggerFactory } from "./logger.ts";
13+
import { ConfigProvider } from "./lib/config.ts";
14+
import { LoggerFactory } from "./lib/logger.ts";
1515
import { InsightsPageController } from "./routes/insights.tsx";
1616
import { HomePageController } from "./routes/index.tsx";
1717
import { RunPageController } from "./routes/results/[runId].tsx";
@@ -20,6 +20,7 @@ import {
2020
type ArtifactParser,
2121
ZipArtifactParser,
2222
} from "./lib/artifact-parser.ts";
23+
import { App, staticFiles } from "fresh";
2324

2425
export interface AppState {
2526
store: AppStore;
@@ -28,7 +29,6 @@ export interface AppState {
2829
export type AppStore = ReturnType<typeof createRequestStore>;
2930

3031
const configProvider = new ConfigProvider();
31-
3232
// services that live for the duration of the application
3333
const appStore = defineStore()
3434
.add("loggerFactory", () => {
@@ -58,7 +58,7 @@ const appStore = defineStore()
5858
})
5959
.finalize();
6060

61-
export function createRequestStore() {
61+
function createRequestStore() {
6262
// services that live for the duration of a request
6363
return appStore.createChild()
6464
.add("logger", (store) => {
@@ -85,3 +85,14 @@ export function createRequestStore() {
8585
})
8686
.finalize();
8787
}
88+
89+
export const app = new App<AppState>();
90+
91+
app
92+
.use(staticFiles())
93+
.use(async (ctx) => {
94+
using scopedStore = createRequestStore();
95+
ctx.state.store = scopedStore;
96+
return await ctx.next();
97+
})
98+
.fsRoutes();
File renamed without changes.

logger.ts renamed to lib/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExtractInterface } from "./lib/types.ts";
1+
import type { ExtractInterface } from "./types.ts";
22

33
export class LoggerFactory {
44
#requestId = 0;
File renamed without changes.

main.ts

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

routes/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Head } from "fresh/runtime";
22
import { define } from "@/define.ts";
33
import type { RunsFetcher } from "@/lib/runs-fetcher.ts";
4-
import { formatDate, getStatusBadge } from "@/render.tsx";
4+
import { formatDate, getStatusBadge } from "@/lib/render.tsx";
55

66
export const handler = define.handlers({
77
GET(ctx) {

routes/insights.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
JobTestResults,
66
TestResultsDownloader,
77
} from "@/lib/test-results-downloader.ts";
8-
import { NullLogger } from "@/logger.ts";
8+
import { NullLogger } from "@/lib/logger.ts";
99

1010
interface RunsWithCount {
1111
totalCount: number;

routes/insights.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
TestResultsDownloader,
66
} from "@/lib/test-results-downloader.ts";
77
import type { GitHubApiClient, WorkflowRun } from "@/lib/github-api-client.ts";
8-
import type { Logger } from "@/logger.ts";
8+
import type { Logger } from "@/lib/logger.ts";
99

1010
export const handler = define.handlers({
1111
GET(ctx) {

routes/results/[runId].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
TestResultsDownloader,
66
} from "@/lib/test-results-downloader.ts";
77
import type { GitHubApiClient } from "@/lib/github-api-client.ts";
8-
import { formatDuration } from "@/render.tsx";
8+
import { formatDuration } from "@/lib/render.tsx";
99

1010
export const handler = define.handlers({
1111
GET(ctx) {

vite.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import tailwindcss from "@tailwindcss/vite";
44

55
export default defineConfig({
66
plugins: [
7-
fresh(),
7+
fresh({
8+
serverEntry: "app.ts",
9+
}),
810
tailwindcss(),
911
],
1012
});

0 commit comments

Comments
 (0)