Skip to content

Why is the code order different from what is described in the documentation? #586

@seekcx

Description

@seekcx

What is the type of issue?

No response

What is the issue?

In the documentation https://elysiajs.com/essential/life-cycle#order-of-code, there is an example:

import { Elysia } from 'elysia'

new Elysia()
    .onBeforeHandle(() => {
        console.log('1')
    })
    .get('/', () => 'hi')
    .onBeforeHandle(() => {
        console.log('2')
    })
    .listen(3000)

Console should log the following:

1

Notice that it doesn't log 2, because the event is registered after the route so it is not applied to the route.

But when I execute this code, it outputs 1 and 2. Am I missing something?

Where did you find it?

https://elysiajs.com/essential/life-cycle#order-of-code & https://elysiajs.com/key-concept.html#order-of-code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions