mirror of
https://github.com/honojs/hono.git
synced 2024-11-22 19:44:26 +01:00
1b2a4c0800
* feat(jsr): reduce slow types (#2369) * feat(jsr): reduce slow types * fix: use allow function * chore: format code * chore: denoify * add `deno.json` * add `jsr-dry-run` command for CI * don't put `JSX` on `global` * fix test settings for deno * don't use `dynamicClass` * don't declare `ExecutionContext` in `global` * goodbye denoify * exports `./middleware` * exports `./helper` * exports each helper and middleware * remove the `awslambda` implementation which is not enough * feat(jsr): remove helper.ts and middleware.ts (#2667) * feat(jsr): remove helper.ts and middleware.ts * fix: fix test * dont' use `SuperClass` Co-authored-by: Taku Amano <taku@taaas.jp> * feat(jsr): delete `mod.ts` (#2669) * rename `deno.json` to `jsr.json` * lint * remove slow type in lambda adapter * fixed runtime test for deno * export all utils * add a GitHub action to publish the package to JSR * fixed declaring `ContextVariableMap` * fixed the type error * include `jsr.json` in `jsr.json` * update `jsr.json` --------- Co-authored-by: Shotaro Nakamura <79000684+nakasyou@users.noreply.github.com> Co-authored-by: Taku Amano <taku@taaas.jp>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { toSSG } from '../../src/adapter/deno/ssg.ts'
|
|
import { Hono } from '../../src/hono.ts'
|
|
import { assertEquals } from '../deno/deps.ts'
|
|
|
|
Deno.test('toSSG function', async () => {
|
|
const app = new Hono()
|
|
app.get('/', (c) => c.text('Hello, World!'))
|
|
app.get('/about', (c) => c.text('About Page'))
|
|
app.get('/about/some', (c) => c.text('About Page 2tier'))
|
|
app.post('/about/some/thing', (c) => c.text('About Page 3tier'))
|
|
app.get('/bravo', (c) => c.html('Bravo Page'))
|
|
app.get('/Charlie', async (c, next) => {
|
|
c.setRenderer((content) => {
|
|
return c.html(
|
|
<html>
|
|
<body>
|
|
<p>{content}</p>
|
|
</body>
|
|
</html>
|
|
)
|
|
})
|
|
await next()
|
|
})
|
|
app.get('/Charlie', (c) => {
|
|
return c.render('Hello!')
|
|
})
|
|
|
|
const result = await toSSG(app, { dir: './ssg-static' })
|
|
assertEquals(result.success, true)
|
|
assertEquals(result.error, undefined)
|
|
assertEquals(result.files !== undefined, true)
|
|
|
|
await deleteDirectory('./ssg-static')
|
|
})
|
|
|
|
async function deleteDirectory(dirPath: string): Promise<void> {
|
|
try {
|
|
const stat = await Deno.stat(dirPath)
|
|
|
|
if (stat.isDirectory) {
|
|
for await (const dirEntry of Deno.readDir(dirPath)) {
|
|
const entryPath = `${dirPath}/${dirEntry.name}`
|
|
await deleteDirectory(entryPath)
|
|
}
|
|
await Deno.remove(dirPath)
|
|
} else {
|
|
await Deno.remove(dirPath)
|
|
}
|
|
} catch (error) {
|
|
console.error(`Error deleting directory: ${error}`)
|
|
}
|
|
}
|