Simple hono boilerplate to develop serverless applications on AWS.
pnpm install
pnpm offline
pnpm g:module --name hello --route /hello
- Routing register using decorators on controller top on (https://hono.dev/)[https://hono.dev/]
- Openapi routes @hono/zod-openapi with routing.
- Dependency injection using @freshgum/typedi
- Formatting and linting code using BiomeJS
- Generating code using hygen.io
- Enviroment type safe variables using env.t3.gg
- Testing using https://vitest.dev/
- Build serverless application using https://github.com/floydspace/serverless-esbuild
- Emulates AWS λ and API Gateway using [https://github.com/dherault/serverless-offline](Serverless offline)
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",
},
},
});
@Route("/hello")
@Service([])
export class HelloController {
constructor() {}
@Post("/", {
openapi: helloOpenApi,
})
index(c: Context) {
return c.json(
{
message1: "Hello, world!",
},
200
);
}
}
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!");
}
}
- https://github.com/honojs/middleware/issues/181 - result doesn't fit with the result type, so you can put anything on result and won't be validated by zod for now