generated from tscircuit/template-api-fake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { withRouteSpec } from "lib/middleware/with-winter-spec" | ||
import { z } from "zod" | ||
|
||
export default withRouteSpec({ | ||
methods: ["GET"], | ||
jsonResponse: z.any(), | ||
})((req, ctx) => { | ||
const events = ctx.db.events | ||
|
||
return new Response( | ||
`<html> | ||
<head> | ||
<title>Events List</title> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
</head> | ||
<body> | ||
<div class="p-4"> | ||
<h1 class="text-3xl font-bold mb-8">Events</h1> | ||
<table class="w-full border-collapse border border-gray-300"> | ||
<thead> | ||
<tr class="bg-gray-100"> | ||
<th class="border border-gray-300 p-2">Event Type</th> | ||
<th class="border border-gray-300 p-2">Created At</th> | ||
<th class="border border-gray-300 p-2">Details</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
${events | ||
.sort( | ||
(a, b) => | ||
new Date(b.created_at).valueOf() - | ||
new Date(a.created_at).valueOf(), | ||
) | ||
.map( | ||
({ event_type, event_id, created_at, ...rest }) => ` | ||
<tr> | ||
<td class="border border-gray-300 p-2">${event_type}</td> | ||
<td class="border border-gray-300 p-2">${new Date( | ||
created_at, | ||
).toLocaleString()}</td> | ||
<td class="border border-gray-300 p-2">${JSON.stringify(rest) | ||
.slice(1, -1) | ||
.replace(/"([^"]+)":/g, "$1:")}</td> | ||
</tr> | ||
`, | ||
) | ||
.join("")} | ||
</tbody> | ||
</table> | ||
</div> | ||
</body> | ||
</html>`, | ||
{ | ||
headers: { | ||
"Content-Type": "text/html; charset=utf-8", | ||
}, | ||
}, | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { withRouteSpec } from "lib/middleware/with-winter-spec" | ||
import { z } from "zod" | ||
|
||
export default withRouteSpec({ | ||
methods: ["GET"], | ||
jsonResponse: z.any(), | ||
})((req, ctx) => { | ||
return new Response( | ||
`<html> | ||
<head> | ||
<title>file-server Admin Dashboard</title> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
</head> | ||
<body> | ||
<div class="max-w-4xl mx-auto px-4 py-8"> | ||
<h1 class="text-3xl font-bold mb-8">file-server Admin Dashboard</h1> | ||
<nav> | ||
<ul class="space-y-4"> | ||
<li> | ||
<a href="./admin/files/list" class="block px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors">File Management</a> | ||
</li> | ||
<li> | ||
<a href="./admin/events/list" class="block px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors">Event Management</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
</div> | ||
</body> | ||
</html>`, | ||
{ | ||
headers: { | ||
"Content-Type": "text/html", | ||
}, | ||
}, | ||
) | ||
}) |