-
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
1 parent
d74a983
commit a1fe696
Showing
12 changed files
with
103 additions
and
73 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,13 @@ | ||
/** | ||
* Playground is a jsonx playground. | ||
*/ | ||
export interface Playground { | ||
id: string; | ||
version: string; | ||
code: string; | ||
} | ||
|
||
/** | ||
* AddPlaygroundRequest is the request to add a playground. | ||
*/ | ||
export type AddPlaygroundRequest = Omit<Playground, "id">; |
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 |
---|---|---|
|
@@ -20,8 +20,7 @@ | |
} | ||
}, | ||
"exclude": [ | ||
"**/_fresh/*", | ||
"./static" | ||
"**/_fresh/*" | ||
], | ||
"imports": { | ||
"#/": "./", | ||
|
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
File renamed without changes.
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,15 @@ | ||
import type { Handlers } from "$fresh/server.ts"; | ||
import { getPlayground, setPlayground } from "#/server/playgrounds.ts"; | ||
import { kv } from "#/server/kv.ts"; | ||
|
||
export const handler: Handlers = { | ||
async GET(_request, ctx) { | ||
const playground = await getPlayground(kv, ctx.params.id); | ||
return Response.json(playground); | ||
}, | ||
async POST(request, _ctx) { | ||
const playground = await request.json(); | ||
await setPlayground(kv, playground); | ||
return Response.json(playground); | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,25 +1,37 @@ | ||
import type { Handlers, PageProps } from "$fresh/server.ts"; | ||
import { getPlayground, setPlayground } from "#/server/playgrounds.ts"; | ||
import type { FreshContext } from "$fresh/server.ts"; | ||
import { Head } from "$fresh/runtime.ts"; | ||
import Nav from "#/client/nav.tsx"; | ||
import Playground from "#/client/components/playground/playground.tsx"; | ||
import { getMeta } from "#/client/meta.ts"; | ||
import { getPlayground } from "#/server/playgrounds.ts"; | ||
import { kv } from "#/server/kv.ts"; | ||
|
||
export const handler: Handlers = { | ||
async GET(_request, ctx) { | ||
const playground = await getPlayground(kv, ctx.params.id); | ||
return Response.json(playground); | ||
}, | ||
async POST(request, _ctx) { | ||
const playground = await request.json(); | ||
await setPlayground(kv, playground); | ||
return Response.json(playground); | ||
}, | ||
}; | ||
export default async function PlaygroundHandler( | ||
_request: Request, | ||
ctx: FreshContext, | ||
) { | ||
const playground = await getPlayground(kv, ctx.params.id); | ||
if (!playground) { | ||
return new Response("Not found!", { status: 404 }); | ||
} | ||
|
||
export default async function PlaygroundHandler(props: PageProps) { | ||
const playground = await getPlayground(kv, props.params.id); | ||
// TODO: Render playground component. | ||
const meta = await getMeta(); | ||
return ( | ||
<> | ||
<pre><code>{JSON.stringify(playground, null, 2)}</code></pre> | ||
<Head> | ||
<title>jsonx | Playground</title> | ||
<link rel="stylesheet" href="/playground.css" /> | ||
</Head> | ||
|
||
<Nav /> | ||
|
||
<main> | ||
<Playground | ||
code={playground.code} | ||
version={playground.version} | ||
meta={meta} | ||
/> | ||
</main> | ||
</> | ||
); | ||
} |
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