Skip to content

Commit

Permalink
refactor: hono app.use usage (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Sep 29, 2024
1 parent 46a44cf commit 37fd280
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/waku/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function runDev() {
if (values['experimental-compress']) {
app.use(compress());
}
app.use('*', runner({ cmd: 'dev', config, env: process.env as any }));
app.use(runner({ cmd: 'dev', config, env: process.env as any }));
app.notFound((c) => {
// FIXME can we avoid hardcoding the public path?
const file = path.join('public', '404.html');
Expand Down Expand Up @@ -151,8 +151,8 @@ async function runStart() {
if (values['experimental-compress']) {
app.use(compress());
}
app.use('*', serveStatic({ root: path.join(distDir, DIST_PUBLIC) }));
app.use('*', runner({ cmd: 'start', loadEntries, env: process.env as any }));
app.use(serveStatic({ root: path.join(distDir, DIST_PUBLIC) }));
app.use(runner({ cmd: 'start', loadEntries, env: process.env as any }));
app.notFound((c) => {
// FIXME better implementation using node stream?
const file = path.join(distDir, DIST_PUBLIC, '404.html');
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/builder/serve-partykit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const loadEntries = () => import(import.meta.env.WAKU_ENTRIES_FILE!);
let serveWaku: ReturnType<typeof runner> | undefined;

const app = new Hono();
app.use('*', (c, next) => serveWaku!(c, next));
app.use((c, next) => serveWaku!(c, next));
app.notFound(async (c) => {
// @ts-expect-error partykit's types aren't available
const assetsFetcher = c.env.assets as {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const publicDir = '${distPublic}';
const loadEntries = () => import('${srcEntriesFile}');
const app = new Hono();
app.use('*', serveStatic({ root: distDir + '/' + publicDir }));
app.use('*', runner({ cmd: 'start', loadEntries, env: process.env }));
app.use(serveStatic({ root: distDir + '/' + publicDir }));
app.use(runner({ cmd: 'start', loadEntries, env: process.env }));
app.notFound(async (c) => {
const file = path.join(distDir, publicDir, '404.html');
if (existsSync(file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const loadEntries = () => import('${srcEntriesFile}');
let serveWaku;
const app = new Hono();
app.use('*', (c, next) => serveWaku(c, next));
app.use((c, next) => serveWaku(c, next));
app.notFound(async (c) => {
const assetsFetcher = c.env.ASSETS;
const url = new URL(c.req.raw.url);
Expand Down
4 changes: 2 additions & 2 deletions packages/waku/src/lib/plugins/vite-plugin-deploy-deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const loadEntries = () => import('${srcEntriesFile}');
const env = Deno.env.toObject();
const app = new Hono();
app.use('*', serveStatic({ root: distDir + '/' + publicDir }));
app.use('*', runner({ cmd: 'start', loadEntries, env }));
app.use(serveStatic({ root: distDir + '/' + publicDir }));
app.use(runner({ cmd: 'start', loadEntries, env }));
app.notFound(async (c) => {
const file = distDir + '/' + publicDir + '/404.html';
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { Hono } = await importHono();
const loadEntries = () => import('${srcEntriesFile}');
const app = new Hono();
app.use('*', runner({ cmd: 'start', loadEntries, env: process.env }));
app.use(runner({ cmd: 'start', loadEntries, env: process.env }));
app.notFound((c) => {
const notFoundHtml = globalThis.__WAKU_NOT_FOUND_HTML__;
if (typeof notFoundHtml === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-deploy-vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const publicDir = '${distPublic}';
const loadEntries = () => import('${srcEntriesFile}');
const app = new Hono();
app.use('*', runner({ cmd: 'start', loadEntries, env: process.env }));
app.use(runner({ cmd: 'start', loadEntries, env: process.env }));
app.notFound((c) => {
// FIXME better implementation using node stream?
const file = path.join(distDir, publicDir, '404.html');
Expand Down

0 comments on commit 37fd280

Please sign in to comment.