Skip to content

mandado/hono-serverless-boilerplate

Repository files navigation

HONO serverless Boilerplate

Simple hono boilerplate to develop serverless applications on AWS.

Installing project

pnpm install

Testing offline api

pnpm offline

Generating code

pnpm g:module --name hello --route /hello

Features

Examples

Open api Schema
import { createRoute, z } from "@infra/zod";

export const helloOpenApi = createRoute({
  request: {
    body: {
      content: {
        "application/json": {
          schema: z.object({
            name: z.string().openapi("name"),
          }),
        },
      },
    },
  },
  responses: {
    200: {
      content: {
        "application/json": {
          schema: z.object({
            message: z.string(),
          }),
        },
      },
      description: "Retrieve the user",
    },
  },
});
Routing
@Route("/hello")
@Service([])
export class HelloController {
  constructor() {}

  @Post("/", {
    openapi: helloOpenApi,
  })
  index(c: Context) {
    return c.json(
      {
        message1: "Hello, world!",
      },
      200
    );
  }
}
Dependency injection
import { Service } from "@infra/container";

@Service([])
class LogService {
  log(message: string) {
    console.log(message);
  }
}

@Service([LogService])
class RootService {
  constructor(private logger: LogService) {}
  run() {
    this.logger.log("hello world!");
  }
}

Troubleshooting

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published