Skip to content

@types/hapi - request.app and server.app are not the same #30465

@wesselvdv

Description

@wesselvdv

If you know how to fix the issue, make a pull request instead.

If you do not mention the authors the issue will be ignored.

Currently the types for request.app and server.app are considered the same:

/**
     * Provides a safe place to store server-specific run-time application data without potential conflicts with
     * the framework internals. The data can be accessed whenever the server is accessible.
     * Initialized with an empty object.
     * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp)
     */
    app: ApplicationState;
    /**
     * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name].
     * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestapp)
     */
    app: ApplicationState;

I would like to be able to decorate the request.app with request specific application state, whereas the server.app should be decorated with server specific application state. (e.g. difference between a shared db connection, and population session information by default on a query.)

My suggestion is to change it to the following:

/**
     * Provides a safe place to store server-specific run-time application data without potential conflicts with
     * the framework internals. The data can be accessed whenever the server is accessible.
     * Initialized with an empty object.
     * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp)
     */
    app: ServerApplicationState;
    /**
     * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name].
     * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestapp)
     */
    app: RequestApplicationState;

Whereas both still are empty interfaces that we can override at our own leisure.

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