Skip to content

Commit 7822c81

Browse files
issue plugin-deduplication
1 parent 2a83b2e commit 7822c81

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

example/issue.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Elysia } from "elysia"
2+
// import { defaultOptions, ip } from "elysia-ip"
3+
import { defaultOptions, ip } from "../src/index"
4+
5+
import type { Server } from "bun"
6+
7+
let server: Server | null
8+
9+
const getServer =
10+
(mess: string = "default") =>
11+
() => {
12+
console.log(`[${mess}] get Server!`)
13+
return server
14+
}
15+
16+
defaultOptions.injectServer = getServer()
17+
18+
const setup = new Elysia().use(ip())
19+
20+
const aInstance = new Elysia().use(setup).get("/a", () => {
21+
console.log("A")
22+
return "a"
23+
})
24+
25+
const bInstance = new Elysia()
26+
.use(
27+
ip({
28+
injectServer: getServer("B"),
29+
}),
30+
)
31+
.get("/b", () => {
32+
console.log("B")
33+
return "b"
34+
})
35+
36+
const app = new Elysia()
37+
.use(aInstance)
38+
.use(bInstance)
39+
.get("/", () => {
40+
console.log("Hello")
41+
return "hello"
42+
})
43+
.listen({}, ({ development, hostname, port }) => {
44+
console.log(
45+
`🦊 Elysia is running at ${hostname}:${port} ${
46+
development ? "🚧 in development mode!🚧" : ""
47+
}`,
48+
)
49+
})
50+
51+
server = app.server

0 commit comments

Comments
 (0)