Skip to content

Add a Hono to Nimbus Route Adapter #31

@dgoerdes

Description

@dgoerdes

Maybe we should add an adapter function to connect the Hono route handler to the Nimbus message router.

Writing this for each command/query feels bad.

httpUserCommandRouter.post(
    '/invite-user',
    async (c) => {
        const body = await c.req.json();
        const correlationId = getCorrelationId(c);

        const command = createCommand<InviteUserCommand>({
            type: INVITE_USER_COMMAND_TYPE,
            source: 'https://nimbus.overlap.at',
            correlationid: correlationId,
            data: body,
        });

        const result = await getRouter('commandRouter').route(command);

        return c.json(result);
    },
);

httpUserCommandRouter.post(
    '/accept-user-invitation',
    async (c) => {
        const body = await c.req.json();
        const correlationId = getCorrelationId(c);

        const command = createCommand<AcceptUserInvitationCommand>({
            type: ACCEPT_USER_INVITATION_COMMAND_TYPE,
            source: 'https://nimbus.overlap.at',
            correlationid: correlationId,
            data: body,
        });

        const result = await getRouter('commandRouter').route(command);

        return c.json(result);
    },
);

// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions