deploy-bbc 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/README.md +345 -0
  2. package/dist/index.js +16870 -0
  3. package/dist/templates/base/package.json +20 -0
  4. package/dist/templates/base/src/routes/index.ts +12 -0
  5. package/dist/templates/base/src/types/index.ts +2 -0
  6. package/dist/templates/base-bun-native/package.json +19 -0
  7. package/dist/templates/base-bun-native/src/index.ts +50 -0
  8. package/dist/templates/base-bun-native/src/routes/index.ts +21 -0
  9. package/dist/templates/base-bun-native/src/types/index.ts +2 -0
  10. package/dist/templates/base-express/package.json +21 -0
  11. package/dist/templates/base-express/src/routes/index.ts +12 -0
  12. package/dist/templates/base-express/src/types/index.ts +2 -0
  13. package/dist/templates/templates/base/.env.example +3 -0
  14. package/dist/templates/templates/base/README.md +31 -0
  15. package/dist/templates/templates/base/src/config/index.ts +8 -0
  16. package/dist/templates/templates/base/src/index.ts +26 -0
  17. package/dist/templates/templates/base/src/middleware/error.ts +13 -0
  18. package/dist/templates/templates/base/src/middleware/logger.ts +8 -0
  19. package/dist/templates/templates/base/src/utils/env.ts +5 -0
  20. package/dist/templates/templates/base/tsconfig.json +20 -0
  21. package/dist/templates/templates/base-bun-native/.env.example +3 -0
  22. package/dist/templates/templates/base-bun-native/README.md +31 -0
  23. package/dist/templates/templates/base-bun-native/src/config/index.ts +8 -0
  24. package/dist/templates/templates/base-bun-native/src/middleware/error.ts +20 -0
  25. package/dist/templates/templates/base-bun-native/src/middleware/logger.ts +6 -0
  26. package/dist/templates/templates/base-bun-native/src/utils/env.ts +5 -0
  27. package/dist/templates/templates/base-bun-native/tsconfig.json +20 -0
  28. package/dist/templates/templates/base-express/.env.example +3 -0
  29. package/dist/templates/templates/base-express/README.md +31 -0
  30. package/dist/templates/templates/base-express/src/config/index.ts +8 -0
  31. package/dist/templates/templates/base-express/src/index.ts +27 -0
  32. package/dist/templates/templates/base-express/src/middleware/error.ts +15 -0
  33. package/dist/templates/templates/base-express/src/middleware/logger.ts +12 -0
  34. package/dist/templates/templates/base-express/src/utils/env.ts +5 -0
  35. package/dist/templates/templates/base-express/tsconfig.json +20 -0
  36. package/dist/templates/templates/extras/ai/anthropic/src/services/ai/anthropic.ts +0 -0
  37. package/dist/templates/templates/extras/ai/gemini/src/services/ai/gemini.ts +0 -0
  38. package/dist/templates/templates/extras/ai/openai/src/routes/ai/chat.ts +0 -0
  39. package/dist/templates/templates/extras/ai/openai/src/services/ai/openai.ts +0 -0
  40. package/dist/templates/templates/extras/ai/vercel-ai/src/routes/ai/generate.ts +0 -0
  41. package/dist/templates/templates/extras/ai/vercel-ai/src/routes/ai/stream.ts +0 -0
  42. package/dist/templates/templates/extras/ai/vercel-ai/src/services/ai/index.ts +0 -0
  43. package/dist/templates/templates/extras/auth/jwt/src/middleware/auth.ts +0 -0
  44. package/dist/templates/templates/extras/auth/jwt/src/routes/auth.ts +0 -0
  45. package/dist/templates/templates/extras/auth/jwt/src/utils/jwt.ts +0 -0
  46. package/dist/templates/templates/extras/auth/oauth/src/config/oauth.ts +0 -0
  47. package/dist/templates/templates/extras/auth/oauth/src/routes/auth.ts +0 -0
  48. package/dist/templates/templates/extras/auth/session/src/config/session.ts +0 -0
  49. package/dist/templates/templates/extras/auth/session/src/middleware/session.ts +0 -0
  50. package/dist/templates/templates/extras/cloud/aws/src/services/aws/s3.ts +0 -0
  51. package/dist/templates/templates/extras/cloud/aws/src/services/aws/ses.ts +0 -0
  52. package/dist/templates/templates/extras/cloud/azure/src/services/azure/blob.ts +0 -0
  53. package/dist/templates/templates/extras/cloud/cloudflare-r2/src/services/cloudflare/r2.ts +0 -0
  54. package/dist/templates/templates/extras/cloud/gcp/src/services/gcp/storage.ts +0 -0
  55. package/dist/templates/templates/extras/database/mongodb/src/db/index.ts +0 -0
  56. package/dist/templates/templates/extras/database/mongodb/src/db/models/user.model.ts +0 -0
  57. package/dist/templates/templates/extras/database/mysql/drizzle.config.ts +0 -0
  58. package/dist/templates/templates/extras/database/postgres/src/db/index.ts +0 -0
  59. package/dist/templates/templates/extras/database/redis/src/db/redis.ts +0 -0
  60. package/dist/templates/templates/extras/docs/scalar/src/openapi/index.ts +0 -0
  61. package/dist/templates/templates/extras/docs/scalar/src/routes/docs.ts +0 -0
  62. package/dist/templates/templates/extras/docs/swagger/src/openapi/index.ts +0 -0
  63. package/dist/templates/templates/extras/docs/swagger/src/routes/docs.ts +0 -0
  64. package/dist/templates/templates/extras/email/nodemailer/src/services/email/nodemailer.ts +0 -0
  65. package/dist/templates/templates/extras/email/resend/src/services/email/resend.ts +0 -0
  66. package/dist/templates/templates/extras/email/resend/src/templates/email/welcome.ts +0 -0
  67. package/dist/templates/templates/extras/email/sendgrid/src/services/email/sendgrid.ts +0 -0
  68. package/dist/templates/templates/extras/observability/logtail/src/config/logger.ts +0 -0
  69. package/dist/templates/templates/extras/observability/sentry/src/config/sentry.ts +0 -0
  70. package/dist/templates/templates/extras/observability/sentry/src/middleware/sentry.ts +0 -0
  71. package/dist/templates/templates/extras/queue/bullmq/src/queue/index.ts +0 -0
  72. package/dist/templates/templates/extras/queue/bullmq/src/queue/jobs/email.job.ts +0 -0
  73. package/dist/templates/templates/extras/queue/bullmq/src/queue/processors/email.processor.ts +0 -0
  74. package/dist/templates/templates/extras/queue/bullmq/src/routes/queue.ts +0 -0
  75. package/dist/templates/templates/extras/queue/inngest/src/inngest/client.ts +0 -0
  76. package/dist/templates/templates/extras/queue/inngest/src/inngest/functions/email.ts +0 -0
  77. package/dist/templates/templates/extras/queue/inngest/src/routes/inngest.ts +0 -0
  78. package/dist/templates/templates/extras/realtime/socketio/src/socket/handlers.ts +0 -0
  79. package/dist/templates/templates/extras/realtime/socketio/src/socket/index.ts +0 -0
  80. package/dist/templates/templates/extras/realtime/sse/src/routes/sse.ts +0 -0
  81. package/dist/templates/templates/extras/testing/vitest/src/__tests__/example.test.ts +0 -0
  82. package/dist/templates/templates/extras/testing/vitest/src/__tests__/setup.ts +0 -0
  83. package/dist/templates/templates/extras/testing/vitest/vitest.config.ts +0 -0
  84. package/dist/templates/templates/extras/validation/yup/src/middleware/index.ts +1 -0
  85. package/dist/templates/templates/extras/validation/yup/src/middleware/validate.ts +83 -0
  86. package/dist/templates/templates/extras/validation/yup/src/routes/users.ts +132 -0
  87. package/dist/templates/templates/extras/validation/zod/src/middleware/index.ts +1 -0
  88. package/dist/templates/templates/extras/validation/zod/src/middleware/validate.ts +80 -0
  89. package/dist/templates/templates/extras/validation/zod/src/routes/users.ts +128 -0
  90. package/package.json +43 -9
  91. package/CLAUDE.md +0 -403
  92. package/cli/README.md +0 -345
  93. package/cli/package.json +0 -54
  94. package/cli/src/cli/index.ts +0 -454
  95. package/cli/src/helpers/create-project.ts +0 -66
  96. package/cli/src/helpers/generate-docker-compose.ts +0 -133
  97. package/cli/src/helpers/generate-dockerfile.ts +0 -45
  98. package/cli/src/helpers/init-git.ts +0 -33
  99. package/cli/src/helpers/install-dependencies.ts +0 -28
  100. package/cli/src/helpers/log-next-steps.ts +0 -87
  101. package/cli/src/helpers/scaffold-project.ts +0 -88
  102. package/cli/src/index.ts +0 -18
  103. package/cli/src/installers/ai.ts +0 -123
  104. package/cli/src/installers/auth.ts +0 -132
  105. package/cli/src/installers/base.ts +0 -16
  106. package/cli/src/installers/cloud.ts +0 -127
  107. package/cli/src/installers/database.ts +0 -212
  108. package/cli/src/installers/docs.ts +0 -93
  109. package/cli/src/installers/email.ts +0 -119
  110. package/cli/src/installers/env-variables.ts +0 -27
  111. package/cli/src/installers/index.ts +0 -145
  112. package/cli/src/installers/observability.ts +0 -103
  113. package/cli/src/installers/queue.ts +0 -103
  114. package/cli/src/installers/ratelimit.ts +0 -98
  115. package/cli/src/installers/realtime.ts +0 -79
  116. package/cli/src/installers/testing.ts +0 -88
  117. package/cli/src/installers/validation.ts +0 -85
  118. package/cli/src/types/index.ts +0 -126
  119. package/cli/src/utils/add-package-dependency.ts +0 -56
  120. package/cli/src/utils/dependency-version-map.ts +0 -85
  121. package/cli/src/utils/logger.ts +0 -19
  122. package/cli/src/utils/parse-name-and-path.ts +0 -71
  123. package/cli/src/utils/render-title.ts +0 -11
  124. package/cli/tsconfig.json +0 -35
  125. package/test-cli.sh +0 -56
  126. package/tsconfig.json +0 -15
  127. /package/{cli/src → dist}/templates/base/.env.example +0 -0
  128. /package/{cli/src → dist}/templates/base/README.md +0 -0
  129. /package/{cli/src → dist}/templates/base/src/config/index.ts +0 -0
  130. /package/{cli/src → dist}/templates/base/src/index.ts +0 -0
  131. /package/{cli/src → dist}/templates/base/src/middleware/error.ts +0 -0
  132. /package/{cli/src → dist}/templates/base/src/middleware/logger.ts +0 -0
  133. /package/{cli/src → dist}/templates/base/src/utils/env.ts +0 -0
  134. /package/{cli/src → dist}/templates/base/tsconfig.json +0 -0
  135. /package/{cli/src → dist}/templates/base-bun-native/.env.example +0 -0
  136. /package/{cli/src → dist}/templates/base-bun-native/README.md +0 -0
  137. /package/{cli/src → dist}/templates/base-bun-native/src/config/index.ts +0 -0
  138. /package/{cli/src → dist}/templates/base-bun-native/src/middleware/error.ts +0 -0
  139. /package/{cli/src → dist}/templates/base-bun-native/src/middleware/logger.ts +0 -0
  140. /package/{cli/src → dist}/templates/base-bun-native/src/utils/env.ts +0 -0
  141. /package/{cli/src → dist}/templates/base-bun-native/tsconfig.json +0 -0
  142. /package/{cli/src → dist}/templates/base-express/.env.example +0 -0
  143. /package/{cli/src → dist}/templates/base-express/README.md +0 -0
  144. /package/{cli/src → dist}/templates/base-express/src/config/index.ts +0 -0
  145. /package/{cli/src → dist}/templates/base-express/src/index.ts +0 -0
  146. /package/{cli/src → dist}/templates/base-express/src/middleware/error.ts +0 -0
  147. /package/{cli/src → dist}/templates/base-express/src/middleware/logger.ts +0 -0
  148. /package/{cli/src → dist}/templates/base-express/src/utils/env.ts +0 -0
  149. /package/{cli/src → dist}/templates/base-express/tsconfig.json +0 -0
  150. /package/{cli/src → dist}/templates/extras/ai/anthropic/src/routes/ai/claude.ts +0 -0
  151. /package/{cli/src → dist}/templates/extras/ai/anthropic/src/services/ai/anthropic.ts +0 -0
  152. /package/{cli/src → dist}/templates/extras/ai/gemini/src/services/ai/gemini.ts +0 -0
  153. /package/{cli/src → dist}/templates/extras/ai/openai/src/routes/ai/chat.ts +0 -0
  154. /package/{cli/src → dist}/templates/extras/ai/openai/src/services/ai/openai.ts +0 -0
  155. /package/{cli/src → dist}/templates/extras/ai/vercel-ai/src/routes/ai/generate.ts +0 -0
  156. /package/{cli/src → dist}/templates/extras/ai/vercel-ai/src/routes/ai/stream.ts +0 -0
  157. /package/{cli/src → dist}/templates/extras/ai/vercel-ai/src/services/ai/index.ts +0 -0
  158. /package/{cli/src → dist}/templates/extras/auth/jwt/src/middleware/auth.ts +0 -0
  159. /package/{cli/src → dist}/templates/extras/auth/jwt/src/routes/auth.ts +0 -0
  160. /package/{cli/src → dist}/templates/extras/auth/jwt/src/utils/jwt.ts +0 -0
  161. /package/{cli/src → dist}/templates/extras/auth/oauth/src/config/oauth.ts +0 -0
  162. /package/{cli/src → dist}/templates/extras/auth/oauth/src/routes/auth.ts +0 -0
  163. /package/{cli/src → dist}/templates/extras/auth/session/src/config/session.ts +0 -0
  164. /package/{cli/src → dist}/templates/extras/auth/session/src/middleware/session.ts +0 -0
  165. /package/{cli/src → dist}/templates/extras/cloud/aws/src/services/aws/s3.ts +0 -0
  166. /package/{cli/src → dist}/templates/extras/cloud/aws/src/services/aws/ses.ts +0 -0
  167. /package/{cli/src → dist}/templates/extras/cloud/azure/src/services/azure/blob.ts +0 -0
  168. /package/{cli/src → dist}/templates/extras/cloud/cloudflare-r2/src/services/cloudflare/r2.ts +0 -0
  169. /package/{cli/src → dist}/templates/extras/cloud/gcp/src/services/gcp/storage.ts +0 -0
  170. /package/{cli/src → dist}/templates/extras/database/mongodb/src/db/index.ts +0 -0
  171. /package/{cli/src → dist}/templates/extras/database/mongodb/src/db/models/user.model.ts +0 -0
  172. /package/{cli/src → dist}/templates/extras/database/mysql/drizzle.config.ts +0 -0
  173. /package/{cli/src → dist}/templates/extras/database/postgres/src/db/index.ts +0 -0
  174. /package/{cli/src → dist}/templates/extras/database/redis/src/db/redis.ts +0 -0
  175. /package/{cli/src → dist}/templates/extras/docs/scalar/src/openapi/index.ts +0 -0
  176. /package/{cli/src → dist}/templates/extras/docs/scalar/src/routes/docs.ts +0 -0
  177. /package/{cli/src → dist}/templates/extras/docs/swagger/src/openapi/index.ts +0 -0
  178. /package/{cli/src → dist}/templates/extras/docs/swagger/src/routes/docs.ts +0 -0
  179. /package/{cli/src → dist}/templates/extras/email/nodemailer/src/services/email/nodemailer.ts +0 -0
  180. /package/{cli/src → dist}/templates/extras/email/resend/src/services/email/resend.ts +0 -0
  181. /package/{cli/src → dist}/templates/extras/email/resend/src/templates/email/welcome.ts +0 -0
  182. /package/{cli/src → dist}/templates/extras/email/sendgrid/src/services/email/sendgrid.ts +0 -0
  183. /package/{cli/src → dist}/templates/extras/observability/logtail/src/config/logger.ts +0 -0
  184. /package/{cli/src → dist}/templates/extras/observability/sentry/src/config/sentry.ts +0 -0
  185. /package/{cli/src → dist}/templates/extras/observability/sentry/src/middleware/sentry.ts +0 -0
  186. /package/{cli/src → dist}/templates/extras/queue/bullmq/src/queue/index.ts +0 -0
  187. /package/{cli/src → dist}/templates/extras/queue/bullmq/src/queue/jobs/email.job.ts +0 -0
  188. /package/{cli/src → dist}/templates/extras/queue/bullmq/src/queue/processors/email.processor.ts +0 -0
  189. /package/{cli/src → dist}/templates/extras/queue/bullmq/src/routes/queue.ts +0 -0
  190. /package/{cli/src → dist}/templates/extras/queue/inngest/src/inngest/client.ts +0 -0
  191. /package/{cli/src → dist}/templates/extras/queue/inngest/src/inngest/functions/email.ts +0 -0
  192. /package/{cli/src → dist}/templates/extras/queue/inngest/src/routes/inngest.ts +0 -0
  193. /package/{cli/src → dist}/templates/extras/realtime/socketio/src/socket/handlers.ts +0 -0
  194. /package/{cli/src → dist}/templates/extras/realtime/socketio/src/socket/index.ts +0 -0
  195. /package/{cli/src → dist}/templates/extras/realtime/sse/src/routes/sse.ts +0 -0
  196. /package/{cli/src → dist}/templates/extras/testing/vitest/src/__tests__/example.test.ts +0 -0
  197. /package/{cli/src → dist}/templates/extras/testing/vitest/src/__tests__/setup.ts +0 -0
  198. /package/{cli/src → dist}/templates/extras/testing/vitest/vitest.config.ts +0 -0
  199. /package/{cli/src → dist}/templates/extras/validation/yup/src/middleware/index.ts +0 -0
  200. /package/{cli/src → dist}/templates/extras/validation/yup/src/middleware/validate.ts +0 -0
  201. /package/{cli/src → dist}/templates/extras/validation/yup/src/routes/users.ts +0 -0
  202. /package/{cli/src → dist}/templates/extras/validation/zod/src/middleware/index.ts +0 -0
  203. /package/{cli/src → dist}/templates/extras/validation/zod/src/middleware/validate.ts +0 -0
  204. /package/{cli/src → dist}/templates/extras/validation/zod/src/routes/users.ts +0 -0
  205. /package/{cli/src → dist/templates}/templates/base/package.json +0 -0
  206. /package/{cli/src → dist/templates}/templates/base/src/controllers/user/create-user.controller.ts +0 -0
  207. /package/{cli/src → dist/templates}/templates/base/src/controllers/user/delete-user.controller.ts +0 -0
  208. /package/{cli/src → dist/templates}/templates/base/src/controllers/user/get-user.controller.ts +0 -0
  209. /package/{cli/src → dist/templates}/templates/base/src/controllers/user/get-users.controller.ts +0 -0
  210. /package/{cli/src → dist/templates}/templates/base/src/controllers/user/update-user.controller.ts +0 -0
  211. /package/{cli/src → dist/templates}/templates/base/src/models/user.model.ts +0 -0
  212. /package/{cli/src → dist/templates}/templates/base/src/routes/index.ts +0 -0
  213. /package/{cli/src → dist/templates}/templates/base/src/routes/user.route.ts +0 -0
  214. /package/{cli/src → dist/templates}/templates/base/src/types/common/api-response.types.ts +0 -0
  215. /package/{cli/src → dist/templates}/templates/base/src/types/index.ts +0 -0
  216. /package/{cli/src → dist/templates}/templates/base/src/types/models/user.types.ts +0 -0
  217. /package/{cli/src → dist/templates}/templates/base-bun-native/package.json +0 -0
  218. /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/create-user.controller.ts +0 -0
  219. /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/delete-user.controller.ts +0 -0
  220. /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/get-user.controller.ts +0 -0
  221. /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/get-users.controller.ts +0 -0
  222. /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/update-user.controller.ts +0 -0
  223. /package/{cli/src → dist/templates}/templates/base-bun-native/src/index.ts +0 -0
  224. /package/{cli/src → dist/templates}/templates/base-bun-native/src/models/user.model.ts +0 -0
  225. /package/{cli/src → dist/templates}/templates/base-bun-native/src/routes/index.ts +0 -0
  226. /package/{cli/src → dist/templates}/templates/base-bun-native/src/routes/user.route.ts +0 -0
  227. /package/{cli/src → dist/templates}/templates/base-bun-native/src/types/common/api-response.types.ts +0 -0
  228. /package/{cli/src → dist/templates}/templates/base-bun-native/src/types/index.ts +0 -0
  229. /package/{cli/src → dist/templates}/templates/base-bun-native/src/types/models/user.types.ts +0 -0
  230. /package/{cli/src → dist/templates}/templates/base-express/package.json +0 -0
  231. /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/create-user.controller.ts +0 -0
  232. /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/delete-user.controller.ts +0 -0
  233. /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/get-user.controller.ts +0 -0
  234. /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/get-users.controller.ts +0 -0
  235. /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/update-user.controller.ts +0 -0
  236. /package/{cli/src → dist/templates}/templates/base-express/src/models/user.model.ts +0 -0
  237. /package/{cli/src → dist/templates}/templates/base-express/src/routes/index.ts +0 -0
  238. /package/{cli/src → dist/templates}/templates/base-express/src/routes/user.route.ts +0 -0
  239. /package/{cli/src → dist/templates}/templates/base-express/src/types/common/api-response.types.ts +0 -0
  240. /package/{cli/src → dist/templates}/templates/base-express/src/types/index.ts +0 -0
  241. /package/{cli/src → dist/templates}/templates/base-express/src/types/models/user.types.ts +0 -0
  242. /package/{prettier.config.mjs → dist/templates/templates/extras/ai/anthropic/src/routes/ai/claude.ts} +0 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "my-backend-app",
3
+ "version": "1.0.0",
4
+ "description": "Production-ready Bun backend with TypeScript",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "bun --watch src/index.ts",
8
+ "start": "bun src/index.ts",
9
+ "build": "bun build src/index.ts --outdir dist --target bun",
10
+ "type-check": "tsc --noEmit"
11
+ },
12
+ "dependencies": {
13
+ "hono": "^4.0.0",
14
+ "dotenv": "^16.3.1"
15
+ },
16
+ "devDependencies": {
17
+ "@types/bun": "latest",
18
+ "typescript": "^5.3.3"
19
+ }
20
+ }
@@ -0,0 +1,12 @@
1
+ import { Hono } from "hono";
2
+
3
+ const routes = new Hono();
4
+
5
+ routes.get("/", (c) => {
6
+ return c.json({
7
+ message: "Welcome to your Bun backend!",
8
+ docs: "/docs",
9
+ });
10
+ });
11
+
12
+ export default routes;
@@ -0,0 +1,2 @@
1
+ // Add your TypeScript types and interfaces here
2
+ export {};
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "my-backend-app",
3
+ "version": "1.0.0",
4
+ "description": "Production-ready backend with Bun native HTTP server",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "bun --watch src/index.ts",
8
+ "start": "bun src/index.ts",
9
+ "build": "bun build src/index.ts --outdir dist --target bun",
10
+ "type-check": "tsc --noEmit"
11
+ },
12
+ "dependencies": {
13
+ "dotenv": "^16.3.1"
14
+ },
15
+ "devDependencies": {
16
+ "@types/bun": "latest",
17
+ "typescript": "^5.3.3"
18
+ }
19
+ }
@@ -0,0 +1,50 @@
1
+ import { config } from "./config/index.js";
2
+ import { logger } from "./middleware/logger.js";
3
+ import { errorHandler } from "./middleware/error.js";
4
+ import { router } from "./routes/index.js";
5
+
6
+ /**
7
+ * Simple router matcher for Bun native server
8
+ */
9
+ function match_route(pathname: string, method: string): Response | null {
10
+ return router(pathname, method);
11
+ }
12
+
13
+ const server = Bun.serve({
14
+ port: config.port,
15
+ async fetch(req) {
16
+ const url = new URL(req.url);
17
+ const start = Date.now();
18
+
19
+ try {
20
+ // Health check
21
+ if (url.pathname === "/health" && req.method === "GET") {
22
+ const response = Response.json({
23
+ status: "ok",
24
+ timestamp: new Date().toISOString(),
25
+ });
26
+ logger(req, response, Date.now() - start);
27
+ return response;
28
+ }
29
+
30
+ // Match routes
31
+ const response = match_route(url.pathname, req.method);
32
+ if (response) {
33
+ logger(req, response, Date.now() - start);
34
+ return response;
35
+ }
36
+
37
+ // 404 Not Found
38
+ const notFoundResponse = Response.json(
39
+ { error: "Not Found" },
40
+ { status: 404 }
41
+ );
42
+ logger(req, notFoundResponse, Date.now() - start);
43
+ return notFoundResponse;
44
+ } catch (error) {
45
+ return errorHandler(error, req);
46
+ }
47
+ },
48
+ });
49
+
50
+ console.log(`🚀 Server running on http://localhost:${server.port}`);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Simple router for Bun native server
3
+ * Add your routes here
4
+ */
5
+ export function router(pathname: string, method: string): Response | null {
6
+ // GET /
7
+ if (pathname === "/" && method === "GET") {
8
+ return Response.json({
9
+ message: "Welcome to your Bun backend!",
10
+ docs: "/docs",
11
+ });
12
+ }
13
+
14
+ // Add more routes here
15
+ // Example:
16
+ // if (pathname === "/users" && method === "GET") {
17
+ // return Response.json({ users: [] });
18
+ // }
19
+
20
+ return null; // No route matched
21
+ }
@@ -0,0 +1,2 @@
1
+ // Add your TypeScript types and interfaces here
2
+ export {};
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "my-backend-app",
3
+ "version": "1.0.0",
4
+ "description": "Production-ready backend with Express and TypeScript",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "bun --watch src/index.ts",
8
+ "start": "bun src/index.ts",
9
+ "build": "bun build src/index.ts --outdir dist --target bun",
10
+ "type-check": "tsc --noEmit"
11
+ },
12
+ "dependencies": {
13
+ "express": "^4.18.2",
14
+ "dotenv": "^16.3.1"
15
+ },
16
+ "devDependencies": {
17
+ "@types/bun": "latest",
18
+ "@types/express": "^4.17.21",
19
+ "typescript": "^5.3.3"
20
+ }
21
+ }
@@ -0,0 +1,12 @@
1
+ import express from "express";
2
+
3
+ const router = express.Router();
4
+
5
+ router.get("/", (req, res) => {
6
+ res.json({
7
+ message: "Welcome to your Bun backend!",
8
+ docs: "/docs",
9
+ });
10
+ });
11
+
12
+ export default router;
@@ -0,0 +1,2 @@
1
+ // Add your TypeScript types and interfaces here
2
+ export {};
@@ -0,0 +1,3 @@
1
+ # Server Configuration
2
+ PORT=8000
3
+ NODE_ENV=development
@@ -0,0 +1,31 @@
1
+ # My Backend App
2
+
3
+ Production-ready Bun backend with TypeScript and Hono.
4
+
5
+ ## Getting Started
6
+
7
+ ```bash
8
+ # Install dependencies
9
+ bun install
10
+
11
+ # Copy environment variables
12
+ cp .env.example .env
13
+
14
+ # Run development server
15
+ bun run dev
16
+
17
+ # Build for production
18
+ bun run build
19
+
20
+ # Run production server
21
+ bun run start
22
+ ```
23
+
24
+ ## API Endpoints
25
+
26
+ - `GET /` - Welcome message
27
+ - `GET /health` - Health check
28
+
29
+ ## Documentation
30
+
31
+ Visit `/docs` for API documentation (if Swagger/Scalar is installed).
@@ -0,0 +1,8 @@
1
+ import { load_env } from "../utils/env.js";
2
+
3
+ load_env();
4
+
5
+ export const config = {
6
+ port: parseInt(process.env.PORT || "8000", 10),
7
+ nodeEnv: process.env.NODE_ENV || "development",
8
+ } as const;
@@ -0,0 +1,26 @@
1
+ import { Hono } from "hono";
2
+ import { logger as loggerMiddleware } from "./middleware/logger.js";
3
+ import { errorHandler } from "./middleware/error.js";
4
+ import routes from "./routes/index.js";
5
+ import { config } from "./config/index.js";
6
+
7
+ const app = new Hono();
8
+
9
+ // Middleware
10
+ app.use("*", loggerMiddleware);
11
+ app.onError(errorHandler);
12
+
13
+ // Routes
14
+ app.route("/", routes);
15
+
16
+ // Health check
17
+ app.get("/health", (c) => {
18
+ return c.json({ status: "ok", timestamp: new Date().toISOString() });
19
+ });
20
+
21
+ console.log(`🚀 Server running on http://localhost:${config.port}`);
22
+
23
+ export default {
24
+ port: config.port,
25
+ fetch: app.fetch,
26
+ };
@@ -0,0 +1,13 @@
1
+ import type { ErrorHandler } from "hono";
2
+
3
+ export const errorHandler: ErrorHandler = (err, c) => {
4
+ console.error(`Error: ${err.message}`, err);
5
+
6
+ return c.json(
7
+ {
8
+ error: err.message || "Internal Server Error",
9
+ status: err.status || 500,
10
+ },
11
+ err.status || 500
12
+ );
13
+ };
@@ -0,0 +1,8 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+
3
+ export const logger: MiddlewareHandler = async (c, next) => {
4
+ const start = Date.now();
5
+ await next();
6
+ const ms = Date.now() - start;
7
+ console.log(`${c.req.method} ${c.req.url} - ${c.res.status} (${ms}ms)`);
8
+ };
@@ -0,0 +1,5 @@
1
+ import { config as dotenvConfig } from "dotenv";
2
+
3
+ export function load_env(): void {
4
+ dotenvConfig();
5
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ESNext"],
7
+ "types": ["bun-types"],
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "outDir": "./dist",
16
+ "rootDir": "./src"
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist"]
20
+ }
@@ -0,0 +1,3 @@
1
+ # Server Configuration
2
+ PORT=8000
3
+ NODE_ENV=development
@@ -0,0 +1,31 @@
1
+ # My Backend App
2
+
3
+ Production-ready Bun backend with TypeScript and Hono.
4
+
5
+ ## Getting Started
6
+
7
+ ```bash
8
+ # Install dependencies
9
+ bun install
10
+
11
+ # Copy environment variables
12
+ cp .env.example .env
13
+
14
+ # Run development server
15
+ bun run dev
16
+
17
+ # Build for production
18
+ bun run build
19
+
20
+ # Run production server
21
+ bun run start
22
+ ```
23
+
24
+ ## API Endpoints
25
+
26
+ - `GET /` - Welcome message
27
+ - `GET /health` - Health check
28
+
29
+ ## Documentation
30
+
31
+ Visit `/docs` for API documentation (if Swagger/Scalar is installed).
@@ -0,0 +1,8 @@
1
+ import { load_env } from "../utils/env.js";
2
+
3
+ load_env();
4
+
5
+ export const config = {
6
+ port: parseInt(process.env.PORT || "8000", 10),
7
+ nodeEnv: process.env.NODE_ENV || "development",
8
+ } as const;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Error handler for Bun native server
3
+ */
4
+ export function errorHandler(error: unknown, req: Request): Response {
5
+ console.error(`Error: ${error instanceof Error ? error.message : "Unknown error"}`, error);
6
+
7
+ const status = error instanceof Error && "status" in error
8
+ ? (error as Error & { status: number }).status
9
+ : 500;
10
+
11
+ const message = error instanceof Error ? error.message : "Internal Server Error";
12
+
13
+ return Response.json(
14
+ {
15
+ error: message,
16
+ status,
17
+ },
18
+ { status }
19
+ );
20
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Simple logger middleware for Bun native server
3
+ */
4
+ export function logger(req: Request, res: Response, duration: number): void {
5
+ console.log(`${req.method} ${new URL(req.url).pathname} - ${res.status} (${duration}ms)`);
6
+ }
@@ -0,0 +1,5 @@
1
+ import { config as dotenvConfig } from "dotenv";
2
+
3
+ export function load_env(): void {
4
+ dotenvConfig();
5
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ESNext"],
7
+ "types": ["bun-types"],
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "outDir": "./dist",
16
+ "rootDir": "./src"
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist"]
20
+ }
@@ -0,0 +1,3 @@
1
+ # Server Configuration
2
+ PORT=8000
3
+ NODE_ENV=development
@@ -0,0 +1,31 @@
1
+ # My Backend App
2
+
3
+ Production-ready Bun backend with TypeScript and Hono.
4
+
5
+ ## Getting Started
6
+
7
+ ```bash
8
+ # Install dependencies
9
+ bun install
10
+
11
+ # Copy environment variables
12
+ cp .env.example .env
13
+
14
+ # Run development server
15
+ bun run dev
16
+
17
+ # Build for production
18
+ bun run build
19
+
20
+ # Run production server
21
+ bun run start
22
+ ```
23
+
24
+ ## API Endpoints
25
+
26
+ - `GET /` - Welcome message
27
+ - `GET /health` - Health check
28
+
29
+ ## Documentation
30
+
31
+ Visit `/docs` for API documentation (if Swagger/Scalar is installed).
@@ -0,0 +1,8 @@
1
+ import { load_env } from "../utils/env.js";
2
+
3
+ load_env();
4
+
5
+ export const config = {
6
+ port: parseInt(process.env.PORT || "8000", 10),
7
+ nodeEnv: process.env.NODE_ENV || "development",
8
+ } as const;
@@ -0,0 +1,27 @@
1
+ import express from "express";
2
+ import { logger as loggerMiddleware } from "./middleware/logger.js";
3
+ import { errorHandler } from "./middleware/error.js";
4
+ import routes from "./routes/index.js";
5
+ import { config } from "./config/index.js";
6
+
7
+ const app = express();
8
+
9
+ // Middleware
10
+ app.use(express.json());
11
+ app.use(express.urlencoded({ extended: true }));
12
+ app.use(loggerMiddleware);
13
+
14
+ // Routes
15
+ app.use("/", routes);
16
+
17
+ // Health check
18
+ app.get("/health", (req, res) => {
19
+ res.json({ status: "ok", timestamp: new Date().toISOString() });
20
+ });
21
+
22
+ // Error handler (must be last)
23
+ app.use(errorHandler);
24
+
25
+ app.listen(config.port, () => {
26
+ console.log(`🚀 Server running on http://localhost:${config.port}`);
27
+ });
@@ -0,0 +1,15 @@
1
+ import type { Request, Response, NextFunction } from "express";
2
+
3
+ export const errorHandler = (
4
+ err: Error & { status?: number },
5
+ req: Request,
6
+ res: Response,
7
+ next: NextFunction
8
+ ) => {
9
+ console.error(`Error: ${err.message}`, err);
10
+
11
+ res.status(err.status || 500).json({
12
+ error: err.message || "Internal Server Error",
13
+ status: err.status || 500,
14
+ });
15
+ };
@@ -0,0 +1,12 @@
1
+ import type { Request, Response, NextFunction } from "express";
2
+
3
+ export const logger = (req: Request, res: Response, next: NextFunction) => {
4
+ const start = Date.now();
5
+
6
+ res.on("finish", () => {
7
+ const ms = Date.now() - start;
8
+ console.log(`${req.method} ${req.url} - ${res.statusCode} (${ms}ms)`);
9
+ });
10
+
11
+ next();
12
+ };
@@ -0,0 +1,5 @@
1
+ import { config as dotenvConfig } from "dotenv";
2
+
3
+ export function load_env(): void {
4
+ dotenvConfig();
5
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ESNext"],
7
+ "types": ["bun-types"],
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "outDir": "./dist",
16
+ "rootDir": "./src"
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist"]
20
+ }