project.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { Hono } from "hono"
  2. import { describeRoute } from "hono-openapi"
  3. import { resolver } from "hono-openapi"
  4. import { Instance } from "../project/instance"
  5. import { Project } from "../project/project"
  6. export const ProjectRoute = new Hono()
  7. .get(
  8. "/",
  9. describeRoute({
  10. description: "List all projects",
  11. operationId: "project.list",
  12. responses: {
  13. 200: {
  14. description: "List of projects",
  15. content: {
  16. "application/json": {
  17. schema: resolver(Project.Info.array()),
  18. },
  19. },
  20. },
  21. },
  22. }),
  23. async (c) => {
  24. const projects = await Project.list()
  25. return c.json(projects)
  26. },
  27. )
  28. .get(
  29. "/current",
  30. describeRoute({
  31. description: "Get the current project",
  32. operationId: "project.current",
  33. responses: {
  34. 200: {
  35. description: "Current project",
  36. content: {
  37. "application/json": {
  38. schema: resolver(Project.Info),
  39. },
  40. },
  41. },
  42. },
  43. }),
  44. async (c) => {
  45. return c.json(Instance.project)
  46. },
  47. )