Created
April 8, 2024 13:49
-
-
Save yusukebe/aa0a1c8cbdc9257447179d139debcae3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/routes/_middleware.ts | |
import { createRoute } from 'honox/factory' | |
export default createRoute(async (c, next) => { | |
console.log('middleware at app/routes/_middleware.ts') | |
await next() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/server.ts | |
import { createApp } from 'honox/server' | |
const app = createApp({ | |
init: (app) => { | |
// The following will be executed. | |
app.use(async (c, next) => { | |
console.log('middleware at app/server.ts') | |
await next() | |
}) | |
} | |
}) | |
// The following is not executed because the middleware is overwritten by the HonoX funcs: | |
app.use(async (c, next) => { | |
console.log('not executed') | |
await next() | |
}) | |
export default app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment