fix: various issues arising from oak removal (#23)
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export * from "../server.ts";
|
||||
@@ -1,5 +1,3 @@
|
||||
import { oak } from "../../api_deps.ts";
|
||||
|
||||
// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/
|
||||
const JOKES = [
|
||||
"Why do Java developers often wear glasses? They can’t C#.",
|
||||
@@ -14,7 +12,8 @@ const JOKES = [
|
||||
"An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.",
|
||||
];
|
||||
|
||||
export default (ctx: oak.Context) => {
|
||||
export default (_req: Request): Response => {
|
||||
const randomIndex = Math.floor(Math.random() * 10);
|
||||
ctx.response.body = JOKES[randomIndex];
|
||||
const body = JOKES[randomIndex];
|
||||
return new Response(body);
|
||||
};
|
||||
|
||||
+5
-1
@@ -1,5 +1,9 @@
|
||||
// std
|
||||
export { join, toFileUrl } from "https://deno.land/std@0.95.0/path/mod.ts";
|
||||
export {
|
||||
join,
|
||||
resolve,
|
||||
toFileUrl,
|
||||
} from "https://deno.land/std@0.95.0/path/mod.ts";
|
||||
export { walk } from "https://deno.land/std@0.95.0/fs/walk.ts";
|
||||
export { parse as parseArgs } from "https://deno.land/std@0.95.0/flags/mod.ts";
|
||||
export {
|
||||
|
||||
+5
-10
@@ -61,11 +61,6 @@ async function init(directory: string) {
|
||||
import.meta.url,
|
||||
)}";\n`;
|
||||
await Deno.writeTextFile(join(directory, "deps.ts"), DEPS_TS);
|
||||
const API_DEPS_TS = `export * from "${new URL(
|
||||
"../../server.ts",
|
||||
import.meta.url,
|
||||
)}";\n`;
|
||||
await Deno.writeTextFile(join(directory, "api_deps.ts"), API_DEPS_TS);
|
||||
const PAGES_INDEX_TSX = `import { h, IS_BROWSER, useState } from "../deps.ts";
|
||||
|
||||
export default function Home() {
|
||||
@@ -112,9 +107,8 @@ export default function Greet(props: Props) {
|
||||
join(directory, "pages", "[name].tsx"),
|
||||
PAGES_GREET_TSX,
|
||||
);
|
||||
const PAGES_API_JOKE_TS = `import { oak } from "../../api_deps.ts";
|
||||
|
||||
// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/
|
||||
const PAGES_API_JOKE_TS =
|
||||
`// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/
|
||||
const JOKES = [
|
||||
"Why do Java developers often wear glasses? They can’t C#.",
|
||||
"A SQL query walks into a bar, goes up to two tables and says “can I join you?",
|
||||
@@ -128,9 +122,10 @@ const JOKES = [
|
||||
"An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.",
|
||||
];
|
||||
|
||||
export default (ctx: oak.Context) => {
|
||||
export default (_req: Request): Response => {
|
||||
const randomIndex = Math.floor(Math.random() * 10);
|
||||
ctx.response.body = JOKES[randomIndex];
|
||||
const body = JOKES[randomIndex];
|
||||
return new Response(body);
|
||||
};
|
||||
`;
|
||||
await Deno.writeTextFile(
|
||||
|
||||
+5
-2
@@ -1,4 +1,4 @@
|
||||
import { join, toFileUrl, walk } from "./deps.ts";
|
||||
import { join, resolve, toFileUrl, walk } from "./deps.ts";
|
||||
|
||||
const help = `fresh routes
|
||||
|
||||
@@ -37,6 +37,7 @@ export async function routesSubcommand(rawArgs: Record<string, any>) {
|
||||
}
|
||||
|
||||
export async function routes(directory: string) {
|
||||
directory = resolve(directory);
|
||||
const files = [];
|
||||
const pagesDir = join(directory, "./pages");
|
||||
const pagesUrl = new URL(pagesDir, "file:///");
|
||||
@@ -71,5 +72,7 @@ const routes = {
|
||||
export default routes;
|
||||
`;
|
||||
|
||||
await Deno.writeTextFile(join(directory, "./routes.gen.ts"), output);
|
||||
const routeManifestPath = join(directory, "./routes.gen.ts");
|
||||
await Deno.writeTextFile(routeManifestPath, output);
|
||||
console.log("Route manifest generated and written to", routeManifestPath);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export function installRoutes(
|
||||
routes[apiRoute.route] = apiRoute.handler;
|
||||
}
|
||||
|
||||
routes[`/${INTERNAL_PREFIX}/${JS_PREFIX}/${BUILD_ID}/:path*`] =
|
||||
routes[`${INTERNAL_PREFIX}${JS_PREFIX}/${BUILD_ID}/:path*`] =
|
||||
internalBundleAssetRoute(bundler);
|
||||
|
||||
return routes;
|
||||
|
||||
Reference in New Issue
Block a user