You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to used scoped: true and im running into some strange behavior
useing an Elysia instace with scoped: true, doesn't remove the types from that instance, even though they shouldn’t be accessible
store values in Elysia instaces with scoped: true seem to be wrongfully initiazed as undefined
scoped lifecycle hooks don't seem to be working
import{Elysia}from"elysia";constscoped=newElysia({name: "scoped",scoped: true,}).state("count",0).get("/scoped",({ store })=>{console.log("store:",store);store.count+=1;returnstore.count;}).onRequest(()=>{console.log("this should only trigger for /scoped");});constapp=newElysia().use(scoped).get("/",({ store })=>{console.log("store (should be empty):",store);console.log("this should not be possible:",store.count);// ^^ doesn't type errorreturn"Hello World!";}).onRequest(({ request })=>{console.log(`request: ${request.method}${request.url}`);}).listen(8080);console.log(`🦊 Elysia is running at http://${app.server?.hostname}:${app.server?.port}`);
🦊 Elysia is running at http://localhost:8080
request: GET http://localhost:8080/
store (should be empty): {}
this should not be possible: undefined
request: GET http://localhost:8080/scoped
store: {}
request: GET http://localhost:8080/scoped
store: {
count: NaN
}
request: GET http://localhost:8080/
store (should be empty): {
count: NaN
}
this should not be possible: NaN
The text was updated successfully, but these errors were encountered:
Ok, seems like there's some area I haven't cover yet. I'll handle that in 0.7.
As a workaround, does wrapping the scope inside a guard hook should fix the problem.
I'm trying to used
scoped: true
and im running into some strange behavioruse
ing an Elysia instace withscoped: true
, doesn't remove the types from that instance, even though they shouldn’t be accessiblestore
values in Elysia instaces withscoped: true
seem to be wrongfully initiazed as undefinedscoped
lifecycle hooks don't seem to be workingThe text was updated successfully, but these errors were encountered: