Skip to content
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
14 changes: 7 additions & 7 deletions templates/http-js/content/src/index.js.tmpl
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -44,7 +44,7 @@ function handle(_request) {
headers: {
'content-type': 'text/plain'
}
})
});
}

addEventListener('fetch', (event) => {
Expand Down
16 changes: 8 additions & 8 deletions templates/http-ts/content/src/index.ts.tmpl
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -46,7 +46,7 @@ function handle(_request: Request): Response {
headers: {
'content-type': 'text/plain'
}
})
});
}

//@ts-ignore
Expand Down
Loading