feat(server): add safety checks during dev (#1489)
Co-authored-by: Reed von Redwitz <reed+github@vonredwitz.com>
This commit is contained in:
co-authored by
Reed von Redwitz
parent
430be774e2
commit
a7fe9d04f1
@@ -0,0 +1 @@
|
||||
This is from a text file in the modified static directory.
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"lock": false,
|
||||
"tasks": {
|
||||
"start": "deno run -A --watch=static/,routes/ dev.ts"
|
||||
},
|
||||
"imports": {
|
||||
"$fresh/": "../../",
|
||||
"preact": "https://esm.sh/preact@10.15.1",
|
||||
"preact/": "https://esm.sh/preact@10.15.1/",
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.0"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
}
|
||||
}
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env -S deno run -A --watch=static/,routes/
|
||||
|
||||
import dev from "$fresh/dev.ts";
|
||||
|
||||
await dev(import.meta.url, "./main.ts");
|
||||
@@ -0,0 +1,25 @@
|
||||
// DO NOT EDIT. This file is generated by Fresh.
|
||||
// This file SHOULD be checked into source version control.
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $0 from "./routes/_app.tsx";
|
||||
import * as $1 from "./routes/custom.txt.ts";
|
||||
import * as $2 from "./routes/index.tsx";
|
||||
import * as $3 from "./routes/nested/_app.tsx";
|
||||
import * as $4 from "./routes/test.tsx";
|
||||
import * as $5 from "./routes/test/index.tsx";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/_app.tsx": $0,
|
||||
"./routes/custom.txt.ts": $1,
|
||||
"./routes/index.tsx": $2,
|
||||
"./routes/nested/_app.tsx": $3,
|
||||
"./routes/test.tsx": $4,
|
||||
"./routes/test/index.tsx": $5,
|
||||
},
|
||||
islands: {},
|
||||
baseUrl: import.meta.url,
|
||||
};
|
||||
|
||||
export default manifest;
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference no-default-lib="true" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
/// <reference lib="deno.ns" />
|
||||
|
||||
import { start } from "$fresh/server.ts";
|
||||
import manifest from "./fresh.gen.ts";
|
||||
import notCallingCtxRender from "./plugins/not_calling_ctx_render.ts";
|
||||
import notHavingModules from "./plugins/not_having_modules.ts";
|
||||
|
||||
await start(manifest, {
|
||||
plugins: [notHavingModules(), notCallingCtxRender()],
|
||||
staticDir: "./custom_static",
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Plugin } from "$fresh/server.ts";
|
||||
|
||||
export default function notCallingCtxRender(): Plugin {
|
||||
return {
|
||||
name: "not_calling_ctx_render",
|
||||
entrypoints: {},
|
||||
render() {
|
||||
return {};
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Plugin } from "$fresh/server.ts";
|
||||
|
||||
export default function notHavingModules(): Plugin {
|
||||
return {
|
||||
name: "not_having_modules",
|
||||
entrypoints: { "main": "() => {}" },
|
||||
render(ctx) {
|
||||
ctx.render();
|
||||
|
||||
return {
|
||||
scripts: [{ entrypoint: "main", state: [] }],
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { AppProps } from "$fresh/server.ts";
|
||||
|
||||
export function App(props: AppProps) {
|
||||
return (
|
||||
<>
|
||||
<props.Component />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export const handler = {
|
||||
GET() {
|
||||
return new Response("This is from the handler!");
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Home(): null {
|
||||
throw new Error("boom!");
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { AppProps } from "$fresh/server.ts";
|
||||
|
||||
export default function App(props: AppProps) {
|
||||
return (
|
||||
<>
|
||||
<props.Component />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export function Test() {
|
||||
return <div>hello</div>;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function Test() {
|
||||
return <div>hello</div>;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
This is from a text file.
|
||||
Reference in New Issue
Block a user