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

feat: enable compression #903

Merged
merged 6 commits into from
Sep 27, 2024
Merged
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
10 changes: 10 additions & 0 deletions packages/waku/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { pathToFileURL } from 'node:url';
import { parseArgs } from 'node:util';
import { createRequire } from 'node:module';
import { Hono } from 'hono';
import { compress } from 'hono/compress';
import { contextStorage } from 'hono/context-storage';
import { serve } from '@hono/node-server';
import { serveStatic } from '@hono/node-server/serve-static';
Expand Down Expand Up @@ -51,6 +52,9 @@ const { values, positionals } = parseArgs({
'experimental-partial': {
type: 'boolean',
},
'experimental-compress': {
type: 'boolean',
},
port: {
type: 'string',
short: 'p',
Expand Down Expand Up @@ -98,6 +102,9 @@ async function runDev() {
const honoEnhancer = config.unstable_honoEnhancer || ((app) => app);
const app = new Hono();
app.use(contextStorage());
if (values['experimental-compress']) {
app.use(compress());
}
app.use('*', runner({ cmd: 'dev', config, env: process.env as any }));
app.notFound((c) => {
// FIXME can we avoid hardcoding the public path?
Expand Down Expand Up @@ -144,6 +151,9 @@ async function runStart() {
import(pathToFileURL(path.resolve(distDir, DIST_ENTRIES_JS)).toString());
const app = new Hono();
app.use(contextStorage());
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.notFound((c) => {
Expand Down
Loading