Skip to content

Implement /status Health Check Endpoint and Refactor Plugin Registration #59

Description

@ruthvik-mt

Description

Added a new root-status.controller.ts that provides two routes:

  • GET / — returns a simple welcome message

  • GET /status — returns server uptime, current timestamp, and status

  • Registered this controller plugin in homeserver.module.ts.

  • Also added a custom 404 error handler using app.onError for cleaner “not found” responses.

Key Code Snippets

root-status.controller.ts

import { Elysia } from 'elysia';

export const rootStatusPlugin = new Elysia()
  .get('/', () => ({
    message: 'Matrix server is live. Try /status.',
  }))
  .get('/status', () => ({
    status: 'ok',
    uptime: process.uptime(),
    timestamp: new Date().toISOString(),
  }));

homeserver.module.ts

app.onError(({ code }) => {
  if (code === 'NOT_FOUND') {
    return {
      error: 'Route not found. Are you lost?',
    };
  }
});

If this looks good, I’d be happy to create a PR for these changes. Please assign it to me if so, happy to contribute!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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