seagull-js/seagull

View on GitHub
examples/helloworld/src/routes/frontend-logging/write_logs.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { WriteLogs } from '@seagull/commands-logging'
import { WriteLogsRequest } from '@seagull/libraries'
import { HttpMethod, Route, RouteContext } from '@seagull/routes'

export default class extends Route {
  static method: HttpMethod = 'POST'
  static path = '/log/writeLogs'

  static async handler(this: RouteContext) {
    const {
      logStreamName,
      logs,
      logLevel,
    }: WriteLogsRequest = this.request.body

    const result = await new WriteLogs({
      logLevel,
      logStreamName,
      logs,
    }).execute()

    return this.json(result)
  }
}