diff --git a/templates/http-js/content/src/index.js.tmpl b/templates/http-js/content/src/index.js.tmpl index 9669c87b..3d453154 100644 --- a/templates/http-js/content/src/index.js.tmpl +++ b/templates/http-js/content/src/index.js.tmpl @@ -1,26 +1,26 @@ {%- case http-router -%} -{% when "hono" %} -// For Hono documentation refer to https://hono.dev/docs/ +{% when "hono" %}// For Hono documentation refer to https://hono.dev/docs/ import { Hono } from 'hono'; +import { fire } from 'hono/service-worker'; import { logger } from 'hono/logger'; let app = new Hono(); // Logging to stdout via built-in middleware -app.use(logger()) +app.use(logger()); // Example of a custom middleware to set HTTP response header app.use(async (c, next) => { - c.header('server', 'Spin CLI') + c.header('server', 'Spin CLI'); await next(); }) app.get('/', (c) => c.text('Hello, Spin!')); app.get('/hello/:name', (c) => { - return c.json({ message: `Hello, ${c.req.param('name')}` }) + return c.json({ message: `Hello, ${c.req.param('name')}` }); }); -app.fire(); +fire(app); {% when "itty" %} // For AutoRouter documentation refer to https://itty.dev/itty-router/routers/autorouter import { AutoRouter } from 'itty-router'; @@ -44,7 +44,7 @@ function handle(_request) { headers: { 'content-type': 'text/plain' } - }) + }); } addEventListener('fetch', (event) => { diff --git a/templates/http-ts/content/src/index.ts.tmpl b/templates/http-ts/content/src/index.ts.tmpl index bb3a9443..886ea8e3 100644 --- a/templates/http-ts/content/src/index.ts.tmpl +++ b/templates/http-ts/content/src/index.ts.tmpl @@ -1,27 +1,27 @@ {%- case http-router -%} -{% when "hono" %} -// For Hono documentation refer to https://hono.dev/docs/ +{% when "hono" %}// For Hono documentation refer to https://hono.dev/docs/ import { Hono } from 'hono'; -import type { Context, Next } from 'hono' +import { fire } from 'hono/service-worker'; +import type { Context, Next } from 'hono'; import { logger } from 'hono/logger'; let app = new Hono(); // Logging to stdout via built-in middleware -app.use(logger()) +app.use(logger()); // Example of a custom middleware to set HTTP response header app.use(async (c: Context, next: Next) => { - c.header('server', 'Spin CLI') + c.header('server', 'Spin CLI'); await next(); }) app.get('/', (c: Context) => c.text('Hello, Spin!')); app.get('/hello/:name', (c: Context) => { - return c.json({ message: `Hello, ${c.req.param('name')}!` }) + return c.json({ message: `Hello, ${c.req.param('name')}!` }); }); -app.fire(); +fire(app); {% when "itty" %} // For AutoRouter documentation refer to https://itty.dev/itty-router/routers/autorouter import { AutoRouter } from 'itty-router'; @@ -46,7 +46,7 @@ function handle(_request: Request): Response { headers: { 'content-type': 'text/plain' } - }) + }); } //@ts-ignore