4.2.6 • Published 1 year ago

koishi-web-connect v4.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

koishi-web-connect

connect web backends for koishi

usage

const { asExpressMiddleware } = require('koishi-web-connect')

const { App } = require('koishi')
const koishiApp = new App({
    port: 12344
})
// a plugin that handles web requests
koishiApp.plugin((ctx) => ctx.router.get('/koa' ({response}) => response.body = 'koa'))

const express = require('express')
const expressApp = express()
expressApp.use(asExpressMiddleware(koishiApp))
const customServer = require('http').createServer(expressApp)
customServer.listen(12345)

if everything goes well then you should have koishi routes available in your custom server!

fetch('http://localhost:12345/koa')
  .then(res => res.text())
  .then(text => assert.strictEqual(text, 'koa'))
4.2.6

1 year ago

4.2.5

2 years ago

4.2.4

2 years ago

4.2.3

2 years ago

4.2.2

2 years ago

4.0.0

2 years ago