Skip to content

Feature request: Access app states + decorator in the cron handler #30

@KONFeature

Description

@KONFeature

What is the problem this feature would solve?

Would be awesome to have access to the current instance sstore + decorators in the cron handler.

As of right now, I'm using smth like this to retrieve params from decorators / store :

const baseApp = new Elysia().decorate({someStuff: "test"})

export const demoCron = (app: typeof baseApp) => app.use(
    cron({
        name: "demo",
        pattern: Patterns.everyMinutes(30),
        run: async () => {
            // Get some stuff from the app
            const {
                someStuff
            } = app.decorator;
        },
    })
)

Not a huge fan of this design (but it's working)
I've tried a few different way to "correct" this, by implementing custom cron, with custom generics etc, but tbh I'm new to Elysia and a bit lost in it's types ahah

What is the feature you are proposing to solve the problem?

Updating the cron run method of the cron plugin, to accept the current Elysia instance store + decorators as params

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions