Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: hono app.use usage #916

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading