@LoganArnett mentioned in a PR the idea of renaming derived or decorated properties of plugins when they are included in an actual application. This could prevent naming collisions in the future and give users the freedom to name things as they wish.
It would be nice to do this standardized via Elysia itself, such as:
import { Elysia } from 'elysia';
// this would be a plugin provided by a third party
const myPlugin = (app: Elysia) => app.decorate('myProperty', 42);
new Elysia()
.use(
myPlugin
.mapContext({
myProperty: 'prop' // rename derived or decorated properties one by one
})
.prefixAll('my-') // and/or apply a prefix to all
)
.get('/', (ctx) => ctx['my-prop'])
.listen(8080);
In the logger plugin it is currently implemented as follows:
const app = new Elysia()
.use(
logger({
contextKeyName: 'myLogger'
})
)
.get('/', (ctx) => {
// property "myLogger" is available instead of "log"
ctx.myLogger.info(ctx.request, 'Request');
return 'Hello World';
})
.listen(8080);
@LoganArnett mentioned in a PR the idea of renaming derived or decorated properties of plugins when they are included in an actual application. This could prevent
naming collisions
in the future and give users thefreedom to name things as they wish
.It would be nice to do this standardized via
Elysia
itself, such as:In the logger plugin it is currently implemented as follows: