Skip to content

GitTuanKiet/elysia-middleware

Repository files navigation

elysia-middleware

Plugin for elysia use node middleware

Installation

bun add elysia-middleware

Example

import { Elysia } from 'elysia'
import { middleware_plugin } from 'elysia-middleware'

const app = new Elysia()
    .use(middleware_plugin())
    .get('/', async ({ connect, ...ctx}) => {
        connect.use(middleware);
        const res = await connect.handle();

        // means that the middleware has handled the request and return the response
        if (res) return res
        // no response from middleware, continue to the next handler
        return ctx
    })
    .listen(3000)

This plugin is not complete yet, I created this plugin for use with vite dev server so it maybe it only works for development

About

Plugin for Elysia use node middleware

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published