Skip to content

[IMPROVEMENT] ambiguous examples #446

@gander

Description

@gander

What is the type of issue?

Documentation is confusing

What is the issue?

Often examples are unnecessarily confusing, either being too comprehensive or using unnecessary names that are misleading.

import { Elysia } from 'elysia'

const plugin = new Elysia({ name: 'plugin' })
    .macro(({ onBeforeHandle }) => ({
        hi(word: string) {
            onBeforeHandle(() => {
                console.log(word)
            })
        }
    }))

const app = new Elysia()
    .use(plugin)
    .get('/', () => 'hi', {
        hi: 'Elysia'
    })

Shoud be something like:

import { Elysia } from 'elysia'

const plugin = new Elysia({ name: 'plugin' })
    .macro(({ onBeforeHandle }) => ({
        exampleMacroName(word: string) {
            onBeforeHandle(() => {
                console.log(word)
            })
        }
    }))

const app = new Elysia()
    .use(plugin)
    .get('/', () => 'handler result', {
        exampleMacroName: 'text passed to macro'
    })

Where did you find it?

https://elysiajs.com/essential/handler.html#macro

I will try over time to provide a complete list of places where I had problems interpreting the examples.

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