kybernus 2.3.0 → 3.0.0

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 (171) hide show
  1. package/README.md +15 -6
  2. package/add-features/auth/java-spring/AuthController.java +54 -0
  3. package/add-features/auth/java-spring/AuthService.java +85 -0
  4. package/add-features/auth/java-spring/INSTRUCTIONS.md +119 -0
  5. package/add-features/auth/java-spring/dto/LoginRequest.java +22 -0
  6. package/add-features/auth/java-spring/dto/RegisterRequest.java +22 -0
  7. package/add-features/auth/java-spring/security/JwtRequestFilter.java +45 -0
  8. package/add-features/auth/java-spring/security/JwtUtil.java +59 -0
  9. package/add-features/auth/java-spring/security/SecurityConfig.java +39 -0
  10. package/add-features/auth/nestjs/INSTRUCTIONS.md +112 -0
  11. package/add-features/auth/nestjs/auth.controller.ts +27 -0
  12. package/add-features/auth/nestjs/auth.module.ts +20 -0
  13. package/add-features/auth/nestjs/auth.service.ts +81 -0
  14. package/add-features/auth/nestjs/dto/login.dto.ts +4 -0
  15. package/add-features/auth/nestjs/dto/register.dto.ts +4 -0
  16. package/add-features/auth/nestjs/jwt-auth.guard.ts +17 -0
  17. package/add-features/auth/nestjs/jwt.strategy.ts +24 -0
  18. package/add-features/auth/nextjs/INSTRUCTIONS.md +97 -0
  19. package/add-features/auth/nextjs/jwt.ts +21 -0
  20. package/add-features/auth/nextjs/middleware.ts +37 -0
  21. package/add-features/auth/nextjs/routes/login.ts +43 -0
  22. package/add-features/auth/nextjs/routes/register.ts +50 -0
  23. package/add-features/auth/nextjs/session.ts +28 -0
  24. package/add-features/auth/nodejs-express/INSTRUCTIONS.md +109 -0
  25. package/add-features/auth/nodejs-express/auth.controller.ts +59 -0
  26. package/add-features/auth/nodejs-express/auth.middleware.ts +38 -0
  27. package/add-features/auth/nodejs-express/auth.routes.ts +15 -0
  28. package/add-features/auth/nodejs-express/auth.service.ts +73 -0
  29. package/add-features/auth/nodejs-express/jwt.config.ts +17 -0
  30. package/add-features/auth/python-fastapi/INSTRUCTIONS.md +100 -0
  31. package/add-features/auth/python-fastapi/router.py +26 -0
  32. package/add-features/auth/python-fastapi/schemas.py +25 -0
  33. package/add-features/auth/python-fastapi/security.py +37 -0
  34. package/add-features/auth/python-fastapi/service.py +61 -0
  35. package/add-features/deploy/dockerfiles/Dockerfile.java +22 -0
  36. package/add-features/deploy/dockerfiles/Dockerfile.nextjs +32 -0
  37. package/add-features/deploy/dockerfiles/Dockerfile.nodejs +25 -0
  38. package/add-features/deploy/dockerfiles/Dockerfile.python +17 -0
  39. package/add-features/deploy/fly/INSTRUCTIONS.md +39 -0
  40. package/add-features/deploy/fly/java-spring.toml +21 -0
  41. package/add-features/deploy/fly/nextjs.toml +16 -0
  42. package/add-features/deploy/fly/nodejs.toml +21 -0
  43. package/add-features/deploy/fly/python-fastapi.toml +21 -0
  44. package/add-features/deploy/railway/INSTRUCTIONS.md +38 -0
  45. package/add-features/deploy/railway/java-spring.toml +16 -0
  46. package/add-features/deploy/railway/nextjs.toml +14 -0
  47. package/add-features/deploy/railway/nodejs.toml +14 -0
  48. package/add-features/deploy/railway/python-fastapi.toml +13 -0
  49. package/add-features/deploy/render/INSTRUCTIONS.md +35 -0
  50. package/add-features/deploy/render/java-spring.yaml +14 -0
  51. package/add-features/deploy/render/nextjs.yaml +17 -0
  52. package/add-features/deploy/render/nodejs.yaml +15 -0
  53. package/add-features/deploy/render/python-fastapi.yaml +13 -0
  54. package/add-features/deploy/vercel/INSTRUCTIONS.md +40 -0
  55. package/add-features/deploy/vercel/nextjs.json +16 -0
  56. package/add-features/deploy/vercel/nodejs-express.json +21 -0
  57. package/add-features/deploy/vercel/python-fastapi.json +21 -0
  58. package/add-features/husky/INSTRUCTIONS.md +52 -0
  59. package/add-features/husky/commit-msg +4 -0
  60. package/add-features/husky/commitlint.config.js +3 -0
  61. package/add-features/husky/pre-commit +4 -0
  62. package/add-features/redis/.env.snippet +1 -0
  63. package/add-features/redis/INSTRUCTIONS.md +64 -0
  64. package/add-features/redis/docker-compose.snippet.yml +18 -0
  65. package/add-features/redis/java-spring.java +27 -0
  66. package/add-features/redis/nextjs.ts +23 -0
  67. package/add-features/redis/nodejs.ts +14 -0
  68. package/add-features/redis/python.py +22 -0
  69. package/add-features/swagger/INSTRUCTIONS.md +53 -0
  70. package/add-features/swagger/java-spring.java +34 -0
  71. package/add-features/swagger/nestjs.ts +16 -0
  72. package/add-features/swagger/nextjs-route.ts +11 -0
  73. package/add-features/swagger/nextjs-swagger.ts +17 -0
  74. package/add-features/swagger/nodejs-express.ts +30 -0
  75. package/add-features/swagger/python-fastapi.py +21 -0
  76. package/add-features/websocket/INSTRUCTIONS.md +63 -0
  77. package/add-features/websocket/java-spring.java +60 -0
  78. package/add-features/websocket/nestjs.ts +38 -0
  79. package/add-features/websocket/nodejs-express.ts +38 -0
  80. package/add-features/websocket/python-fastapi.py +41 -0
  81. package/dist/cli/commands/add.d.ts +11 -0
  82. package/dist/cli/commands/add.d.ts.map +1 -0
  83. package/dist/cli/commands/add.js +102 -0
  84. package/dist/cli/commands/add.js.map +1 -0
  85. package/dist/cli/commands/auth.d.ts +11 -0
  86. package/dist/cli/commands/auth.d.ts.map +1 -0
  87. package/dist/cli/commands/auth.js +71 -0
  88. package/dist/cli/commands/auth.js.map +1 -0
  89. package/dist/cli/commands/deploy.d.ts +10 -0
  90. package/dist/cli/commands/deploy.d.ts.map +1 -0
  91. package/dist/cli/commands/deploy.js +110 -0
  92. package/dist/cli/commands/deploy.js.map +1 -0
  93. package/dist/cli/commands/doctor.d.ts +3 -0
  94. package/dist/cli/commands/doctor.d.ts.map +1 -0
  95. package/dist/cli/commands/doctor.js +110 -0
  96. package/dist/cli/commands/doctor.js.map +1 -0
  97. package/dist/cli/commands/init.d.ts +1 -0
  98. package/dist/cli/commands/init.d.ts.map +1 -1
  99. package/dist/cli/commands/init.js +1 -0
  100. package/dist/cli/commands/init.js.map +1 -1
  101. package/dist/cli/prompts/wizard.d.ts +1 -0
  102. package/dist/cli/prompts/wizard.d.ts.map +1 -1
  103. package/dist/cli/prompts/wizard.js +44 -18
  104. package/dist/cli/prompts/wizard.js.map +1 -1
  105. package/dist/cli/utils/cli-helpers.d.ts +43 -0
  106. package/dist/cli/utils/cli-helpers.d.ts.map +1 -0
  107. package/dist/cli/utils/cli-helpers.js +107 -0
  108. package/dist/cli/utils/cli-helpers.js.map +1 -0
  109. package/dist/core/ai/prompts/documentation-prompts.d.ts.map +1 -1
  110. package/dist/core/ai/prompts/documentation-prompts.js +6 -0
  111. package/dist/core/ai/prompts/documentation-prompts.js.map +1 -1
  112. package/dist/core/deploy/deploy-generator.d.ts +18 -0
  113. package/dist/core/deploy/deploy-generator.d.ts.map +1 -0
  114. package/dist/core/deploy/deploy-generator.js +155 -0
  115. package/dist/core/deploy/deploy-generator.js.map +1 -0
  116. package/dist/core/features/feature-generator.d.ts +26 -0
  117. package/dist/core/features/feature-generator.d.ts.map +1 -0
  118. package/dist/core/features/feature-generator.js +376 -0
  119. package/dist/core/features/feature-generator.js.map +1 -0
  120. package/dist/core/generator/project.d.ts.map +1 -1
  121. package/dist/core/generator/project.js +48 -3
  122. package/dist/core/generator/project.js.map +1 -1
  123. package/dist/core/templates/engine.d.ts.map +1 -1
  124. package/dist/core/templates/engine.js +4 -0
  125. package/dist/core/templates/engine.js.map +1 -1
  126. package/dist/index.js +11 -2
  127. package/dist/index.js.map +1 -1
  128. package/dist/models/config.d.ts +2 -1
  129. package/dist/models/config.d.ts.map +1 -1
  130. package/package.json +15 -3
  131. package/templates/n8n/ai-assistant/.env.example.hbs +14 -0
  132. package/templates/n8n/ai-assistant/.gitignore.hbs +6 -0
  133. package/templates/n8n/ai-assistant/Dockerfile.hbs +17 -0
  134. package/templates/n8n/ai-assistant/README.md.hbs +11 -0
  135. package/templates/n8n/ai-assistant/SETUP.md.hbs +60 -0
  136. package/templates/n8n/ai-assistant/docker-compose.yml.hbs +60 -0
  137. package/templates/n8n/ai-assistant/workflows/ai-assistant.json.hbs +32 -0
  138. package/templates/n8n/ai-assistant/workflows/auto-backup.json.hbs +43 -0
  139. package/templates/n8n/ai-assistant/workflows/global-error-handler.json.hbs +28 -0
  140. package/templates/n8n/crm-tracker/.env.example.hbs +14 -0
  141. package/templates/n8n/crm-tracker/.gitignore.hbs +6 -0
  142. package/templates/n8n/crm-tracker/Dockerfile.hbs +17 -0
  143. package/templates/n8n/crm-tracker/README.md.hbs +11 -0
  144. package/templates/n8n/crm-tracker/SETUP.md.hbs +59 -0
  145. package/templates/n8n/crm-tracker/docker-compose.yml.hbs +60 -0
  146. package/templates/n8n/crm-tracker/workflows/auto-backup.json.hbs +43 -0
  147. package/templates/n8n/crm-tracker/workflows/crm-enrichment.json.hbs +46 -0
  148. package/templates/n8n/crm-tracker/workflows/global-error-handler.json.hbs +28 -0
  149. package/templates/n8n/default/.env.example.hbs +14 -0
  150. package/templates/n8n/default/.gitignore.hbs +6 -0
  151. package/templates/n8n/default/Dockerfile.hbs +17 -0
  152. package/templates/n8n/default/README.md.hbs +51 -0
  153. package/templates/n8n/default/SETUP.md.hbs +52 -0
  154. package/templates/n8n/default/docker-compose.yml.hbs +60 -0
  155. package/templates/n8n/default/workflows/auto-backup.json.hbs +38 -0
  156. package/templates/n8n/default/workflows/global-error-handler.json.hbs +28 -0
  157. package/templates/n8n/system-monitor/.env.example.hbs +14 -0
  158. package/templates/n8n/system-monitor/.gitignore.hbs +6 -0
  159. package/templates/n8n/system-monitor/Dockerfile.hbs +17 -0
  160. package/templates/n8n/system-monitor/README.md.hbs +11 -0
  161. package/templates/n8n/system-monitor/SETUP.md.hbs +59 -0
  162. package/templates/n8n/system-monitor/docker-compose.yml.hbs +60 -0
  163. package/templates/n8n/system-monitor/workflows/auto-backup.json.hbs +43 -0
  164. package/templates/n8n/system-monitor/workflows/global-error-handler.json.hbs +28 -0
  165. package/templates/n8n/system-monitor/workflows/health-check.json.hbs +66 -0
  166. package/templates/nodejs-express/clean/package.json.hbs +4 -4
  167. package/templates/nodejs-express/hexagonal/package.json.hbs +4 -4
  168. package/templates/nodejs-express/mvc/package.json.hbs +4 -4
  169. /package/templates/nestjs/hexagonal/prisma/{schema.prisma → schema.prisma.hbs} +0 -0
  170. /package/templates/nodejs-express/clean/prisma/{schema.prisma → schema.prisma.hbs} +0 -0
  171. /package/templates/nodejs-express/hexagonal/prisma/{schema.prisma → schema.prisma.hbs} +0 -0
@@ -0,0 +1,35 @@
1
+ # 🚀 Deploy to Render
2
+
3
+ Your deployment configuration has been generated for **Render**.
4
+
5
+ ## 📁 Files generated
6
+
7
+ - `render.yaml` — Render Blueprint (Infrastructure as Code)
8
+
9
+ ## 🔑 1. Set Environment Variables
10
+
11
+ The `render.yaml` marks sensitive variables as `sync: false`, meaning you need to set them manually:
12
+
13
+ 1. Go to [dashboard.render.com](https://dashboard.render.com) → Your Service → **Environment**
14
+ 2. Add each variable:
15
+
16
+ | Variable | Description |
17
+ |---|---|
18
+ | `DATABASE_URL` | Your database connection string |
19
+ | `JWT_SECRET` | A strong, random secret (auto-generated if `generateValue: true`) |
20
+
21
+ > 💡 Render can also **provision a Postgres database** — create a new **PostgreSQL** service and connect it.
22
+
23
+ ## ⚡ 2. Deploy
24
+
25
+ **Option A — Blueprint (recommended — uses `render.yaml`):**
26
+ 1. Go to [dashboard.render.com](https://dashboard.render.com) → **New → Blueprint**
27
+ 2. Connect your GitHub repo — Render reads `render.yaml` and sets everything up automatically
28
+
29
+ **Option B — Manual Service:**
30
+ 1. Go to **New → Web Service**
31
+ 2. Connect your GitHub repo and fill in build/start commands from `render.yaml`
32
+
33
+ ## 📖 More Info
34
+ - [Render Docs](https://render.com/docs)
35
+ - [render.yaml Reference](https://render.com/docs/blueprint-spec)
@@ -0,0 +1,14 @@
1
+ services:
2
+ - type: web
3
+ name: my-spring-app
4
+ runtime: docker
5
+ plan: free
6
+ dockerfilePath: ./Dockerfile
7
+ branch: main
8
+ envVars:
9
+ - key: DATABASE_URL
10
+ sync: false
11
+ - key: JWT_SECRET
12
+ generateValue: true
13
+ - key: SPRING_PROFILES_ACTIVE
14
+ value: prod
@@ -0,0 +1,17 @@
1
+ services:
2
+ - type: web
3
+ name: my-nextjs-app
4
+ runtime: node
5
+ plan: free
6
+ buildCommand: npm install && npm run build
7
+ startCommand: npm start
8
+ branch: main
9
+ envVars:
10
+ - key: NODE_ENV
11
+ value: production
12
+ - key: DATABASE_URL
13
+ sync: false
14
+ - key: JWT_SECRET
15
+ generateValue: true
16
+ - key: NEXTAUTH_URL
17
+ sync: false
@@ -0,0 +1,15 @@
1
+ services:
2
+ - type: web
3
+ name: my-node-app
4
+ runtime: node
5
+ plan: free
6
+ buildCommand: npm install && npm run build
7
+ startCommand: npm start
8
+ branch: main
9
+ envVars:
10
+ - key: NODE_ENV
11
+ value: production
12
+ - key: DATABASE_URL
13
+ sync: false
14
+ - key: JWT_SECRET
15
+ generateValue: true
@@ -0,0 +1,13 @@
1
+ services:
2
+ - type: web
3
+ name: my-fastapi-app
4
+ runtime: python
5
+ plan: free
6
+ buildCommand: pip install -r requirements.txt
7
+ startCommand: uvicorn app.main:app --host 0.0.0.0 --port $PORT
8
+ branch: main
9
+ envVars:
10
+ - key: DATABASE_URL
11
+ sync: false
12
+ - key: JWT_SECRET
13
+ generateValue: true
@@ -0,0 +1,40 @@
1
+ # 🚀 Deploy to Vercel
2
+
3
+ Your deployment configuration has been generated for **Vercel**.
4
+
5
+ ## 📁 Files generated
6
+
7
+ - `vercel.json` — Vercel project configuration
8
+
9
+ ## 🔑 1. Set Environment Variables
10
+
11
+ Before deploying, configure your environment variables in the **Vercel Dashboard**:
12
+
13
+ 1. Go to [vercel.com](https://vercel.com) → Your Project → **Settings → Environment Variables**
14
+ 2. Add each variable from your `.env` file:
15
+
16
+ | Variable | Description |
17
+ |---|---|
18
+ | `DATABASE_URL` | Your database connection string |
19
+ | `JWT_SECRET` | A strong, random secret for JWT signing |
20
+ | `NODE_ENV` | Set to `production` |
21
+
22
+ > 💡 Generate a strong JWT secret: `node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"`
23
+
24
+ ## ⚡ 2. Deploy
25
+
26
+ **Option A — GitHub Auto-Deploy (recommended):**
27
+ 1. Push your code to GitHub
28
+ 2. Go to [vercel.com](https://vercel.com) → **New Project** → Import your repo
29
+ 3. Vercel auto-detects the framework and deploys on every push to `main`
30
+
31
+ **Option B — Vercel CLI:**
32
+ ```bash
33
+ npm install -g vercel
34
+ vercel login
35
+ vercel --prod
36
+ ```
37
+
38
+ ## 📖 More Info
39
+ - [Vercel Docs](https://vercel.com/docs)
40
+ - [Environment Variables on Vercel](https://vercel.com/docs/environment-variables)
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": 2,
3
+ "name": "my-nextjs-app",
4
+ "builds": [
5
+ {
6
+ "src": "next.config.*",
7
+ "use": "@vercel/next"
8
+ }
9
+ ],
10
+ "env": {
11
+ "DATABASE_URL": "@database_url",
12
+ "JWT_SECRET": "@jwt_secret",
13
+ "NEXTAUTH_SECRET": "@nextauth_secret",
14
+ "NEXTAUTH_URL": "@nextauth_url"
15
+ }
16
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "version": 2,
3
+ "name": "my-express-api",
4
+ "builds": [
5
+ {
6
+ "src": "src/index.ts",
7
+ "use": "@vercel/node"
8
+ }
9
+ ],
10
+ "routes": [
11
+ {
12
+ "src": "/(.*)",
13
+ "dest": "src/index.ts"
14
+ }
15
+ ],
16
+ "env": {
17
+ "DATABASE_URL": "@database_url",
18
+ "JWT_SECRET": "@jwt_secret",
19
+ "NODE_ENV": "production"
20
+ }
21
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "version": 2,
3
+ "name": "my-fastapi-app",
4
+ "builds": [
5
+ {
6
+ "src": "app/main.py",
7
+ "use": "@vercel/python"
8
+ }
9
+ ],
10
+ "routes": [
11
+ {
12
+ "src": "/(.*)",
13
+ "dest": "app/main.py"
14
+ }
15
+ ],
16
+ "env": {
17
+ "DATABASE_URL": "@database_url",
18
+ "JWT_SECRET": "@jwt_secret",
19
+ "PYTHON_VERSION": "3.11"
20
+ }
21
+ }
@@ -0,0 +1,52 @@
1
+ # Husky + Commitlint
2
+
3
+ ## Files generated
4
+
5
+ - `.husky/pre-commit` — runs `lint-staged` before each commit
6
+ - `.husky/commit-msg` — validates commit message format
7
+ - `commitlint.config.js` — enforces [Conventional Commits](https://www.conventionalcommits.org/)
8
+
9
+ ## Install dependencies
10
+
11
+ ```bash
12
+ npm install -D husky lint-staged @commitlint/cli @commitlint/config-conventional
13
+ ```
14
+
15
+ ## Setup
16
+
17
+ ```bash
18
+ npx husky init
19
+ ```
20
+
21
+ Then copy the generated hook files to `.husky/`:
22
+ ```bash
23
+ cp .husky/pre-commit .husky/commit-msg ./
24
+ ```
25
+
26
+ Or, Kybernus already set this up — just run the init command above.
27
+
28
+ ---
29
+
30
+ ## Add lint-staged config to `package.json`
31
+
32
+ ```json
33
+ {
34
+ "lint-staged": {
35
+ "*.{ts,tsx,js,jsx}": ["eslint --fix", "prettier --write"],
36
+ "*.{json,md,yml}": ["prettier --write"]
37
+ }
38
+ }
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Commit message format
44
+
45
+ ```
46
+ feat: add new endpoint
47
+ fix: correct validation error
48
+ chore: update dependencies
49
+ docs: update README
50
+ ```
51
+
52
+ Valid types: `feat`, `fix`, `chore`, `docs`, `style`, `refactor`, `test`, `perf`, `ci`, `build`, `revert`
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx --no -- commitlint --edit "$1"
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['@commitlint/config-conventional'],
3
+ };
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
@@ -0,0 +1 @@
1
+ REDIS_URL=redis://localhost:6379
@@ -0,0 +1,64 @@
1
+ # Redis Cache
2
+
3
+ ## Files generated
4
+
5
+ - `redis.ts` or `redis.py` in the root of `src/`
6
+ - `docker-compose.snippet.yml` — add the `redis` service to your existing `docker-compose.yml`
7
+ - `.env.snippet` — add `REDIS_URL` to your `.env`
8
+
9
+ ## Install dependencies
10
+
11
+ ### Node.js (Express or NestJS)
12
+ ```bash
13
+ npm install redis
14
+ npm install -D @types/redis
15
+ ```
16
+
17
+ ### Python FastAPI
18
+ ```bash
19
+ pip install redis[asyncio]
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Integration
25
+
26
+ ### Node.js Express — add to `app.ts` / `index.ts`:
27
+ ```typescript
28
+ import { connectRedis } from './redis';
29
+
30
+ // Before starting the server:
31
+ await connectRedis();
32
+ ```
33
+
34
+ ### NestJS — add to `app.module.ts`:
35
+ ```typescript
36
+ // Option 1: Use the redis.ts file as a custom provider
37
+ // Option 2: Use @nestjs-modules/ioredis or nestjs-redis packages
38
+
39
+ import { connectRedis } from './redis';
40
+
41
+ // In bootstrap():
42
+ await connectRedis();
43
+ ```
44
+
45
+ ### Python FastAPI — add to `main.py`:
46
+ ```python
47
+ from redis import connect_redis, disconnect_redis
48
+
49
+ @app.on_event("startup")
50
+ async def startup():
51
+ await connect_redis()
52
+
53
+ @app.on_event("shutdown")
54
+ async def shutdown():
55
+ await disconnect_redis()
56
+ ```
57
+
58
+ ---
59
+
60
+ ## docker-compose
61
+
62
+ Add the redis service block from `docker-compose.snippet.yml` to your existing `docker-compose.yml` under `services:`.
63
+
64
+ Also make sure to merge the `redis_data` volume under the top-level `volumes:` key.
@@ -0,0 +1,18 @@
1
+ services:
2
+ # Faltou essa linha principal
3
+ redis:
4
+ image: redis:7-alpine
5
+ container_name: ${PROJECT_NAME:-app}-redis
6
+ ports:
7
+ - "6379:6379"
8
+ volumes:
9
+ - redis_data:/data
10
+ restart: unless-stopped
11
+ healthcheck:
12
+ test: [ "CMD", "redis-cli", "ping" ]
13
+ interval: 10s
14
+ timeout: 5s
15
+ retries: 5
16
+
17
+ volumes:
18
+ redis_data:
@@ -0,0 +1,27 @@
1
+ package com.example.config;
2
+
3
+ import org.springframework.context.annotation.Bean;
4
+ import org.springframework.context.annotation.Configuration;
5
+ import org.springframework.data.redis.connection.RedisConnectionFactory;
6
+ import org.springframework.data.redis.core.RedisTemplate;
7
+ import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
8
+ import org.springframework.data.redis.serializer.StringRedisSerializer;
9
+
10
+ /**
11
+ * Redis configuration using Spring Data Redis.
12
+ * Generated by: kybernus add redis
13
+ */
14
+ @Configuration
15
+ public class RedisConfig {
16
+
17
+ @Bean
18
+ public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
19
+ RedisTemplate<String, Object> template = new RedisTemplate<>();
20
+ template.setConnectionFactory(connectionFactory);
21
+ template.setKeySerializer(new StringRedisSerializer());
22
+ template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
23
+ template.setHashKeySerializer(new StringRedisSerializer());
24
+ template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
25
+ return template;
26
+ }
27
+ }
@@ -0,0 +1,23 @@
1
+ // Redis client for Next.js (server-side only)
2
+ // Use in Server Components, API routes, or Server Actions
3
+ // File generated by: kybernus add redis
4
+
5
+ import { createClient } from 'redis';
6
+
7
+ const globalForRedis = globalThis as unknown as {
8
+ redis: ReturnType<typeof createClient> | undefined;
9
+ };
10
+
11
+ export const redis =
12
+ globalForRedis.redis ??
13
+ createClient({
14
+ url: process.env.REDIS_URL || 'redis://localhost:6379',
15
+ });
16
+
17
+ if (process.env.NODE_ENV !== 'production') globalForRedis.redis = redis;
18
+
19
+ if (!redis.isOpen) {
20
+ redis.connect().catch(console.error);
21
+ }
22
+
23
+ export default redis;
@@ -0,0 +1,14 @@
1
+ import { createClient } from 'redis';
2
+
3
+ const client = createClient({
4
+ url: process.env.REDIS_URL || 'redis://localhost:6379',
5
+ });
6
+
7
+ client.on('error', (err) => console.error('Redis error:', err));
8
+ client.on('connect', () => console.log('✅ Redis connected'));
9
+
10
+ export async function connectRedis(): Promise<void> {
11
+ await client.connect();
12
+ }
13
+
14
+ export { client as redis };
@@ -0,0 +1,22 @@
1
+ import redis.asyncio as aioredis
2
+ from typing import Optional
3
+
4
+ redis: Optional[aioredis.Redis] = None
5
+
6
+
7
+ async def connect_redis() -> None:
8
+ global redis
9
+ redis_url = os.getenv("REDIS_URL", "redis://localhost:6379")
10
+ redis = await aioredis.from_url(redis_url, decode_responses=True)
11
+ print("✅ Redis connected")
12
+
13
+
14
+ async def disconnect_redis() -> None:
15
+ if redis:
16
+ await redis.close()
17
+
18
+
19
+ def get_redis() -> aioredis.Redis:
20
+ if redis is None:
21
+ raise RuntimeError("Redis is not connected. Call connect_redis() first.")
22
+ return redis
@@ -0,0 +1,53 @@
1
+ # Swagger / OpenAPI
2
+
3
+ ## Files generated
4
+
5
+ - `swagger.ts` or `swagger.py` in the root of `src/`
6
+
7
+ ## Install dependencies
8
+
9
+ ### Node.js Express
10
+ ```bash
11
+ npm install swagger-jsdoc swagger-ui-express
12
+ npm install -D @types/swagger-jsdoc @types/swagger-ui-express
13
+ ```
14
+
15
+ ### NestJS
16
+ ```bash
17
+ npm install @nestjs/swagger
18
+ ```
19
+
20
+ ### Python FastAPI
21
+ > FastAPI has OpenAPI/Swagger built-in — no extra packages needed!
22
+
23
+ ---
24
+
25
+ ## Integration
26
+
27
+ ### Node.js Express — add to `app.ts`:
28
+ ```typescript
29
+ import { setupSwagger } from './swagger';
30
+ // after app is created:
31
+ setupSwagger(app);
32
+ ```
33
+
34
+ ### NestJS — add to `main.ts`:
35
+ ```typescript
36
+ import { setupSwagger } from './swagger';
37
+ // after app is created, before app.listen():
38
+ setupSwagger(app);
39
+ ```
40
+
41
+ ### Python FastAPI — add to `main.py`:
42
+ ```python
43
+ from swagger import configure_swagger
44
+ configure_swagger(app)
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Docs URL
50
+
51
+ After starting the server, open:
52
+ - **Express / NestJS:** `http://localhost:3000/api/docs`
53
+ - **FastAPI:** `http://localhost:8000/api/docs`
@@ -0,0 +1,34 @@
1
+ package com.example.config;
2
+
3
+ import io.swagger.v3.oas.models.OpenAPI;
4
+ import io.swagger.v3.oas.models.info.Info;
5
+ import org.springdoc.core.models.GroupedOpenApi;
6
+ import org.springframework.context.annotation.Bean;
7
+ import org.springframework.context.annotation.Configuration;
8
+
9
+ /**
10
+ * Swagger / OpenAPI configuration using SpringDoc.
11
+ * Generated by: kybernus add swagger
12
+ *
13
+ * Docs available at: http://localhost:8080/swagger-ui.html
14
+ */
15
+ @Configuration
16
+ public class SwaggerConfig {
17
+
18
+ @Bean
19
+ public OpenAPI customOpenAPI() {
20
+ return new OpenAPI()
21
+ .info(new Info()
22
+ .title("API Documentation")
23
+ .version("1.0.0")
24
+ .description("Auto-generated API docs by Kybernus"));
25
+ }
26
+
27
+ @Bean
28
+ public GroupedOpenApi publicApi() {
29
+ return GroupedOpenApi.builder()
30
+ .group("public")
31
+ .pathsToMatch("/api/**")
32
+ .build();
33
+ }
34
+ }
@@ -0,0 +1,16 @@
1
+ import { INestApplication } from '@nestjs/common';
2
+ import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
3
+
4
+ export function setupSwagger(app: INestApplication): void {
5
+ const config = new DocumentBuilder()
6
+ .setTitle('API Documentation')
7
+ .setDescription('Auto-generated API docs by Kybernus')
8
+ .setVersion('1.0')
9
+ .addBearerAuth()
10
+ .build();
11
+
12
+ const document = SwaggerModule.createDocument(app, config);
13
+ SwaggerModule.setup('api/docs', app, document);
14
+
15
+ console.log(`📄 Swagger docs available at /api/docs`);
16
+ }
@@ -0,0 +1,11 @@
1
+ // Next.js API route to serve Swagger UI
2
+ // Place this file at: src/app/api/docs/route.ts
3
+ // File generated by: kybernus add swagger
4
+
5
+ import { getSwaggerSpec } from '../../../swagger';
6
+ import { NextResponse } from 'next/server';
7
+
8
+ export async function GET() {
9
+ const spec = getSwaggerSpec();
10
+ return NextResponse.json(spec);
11
+ }
@@ -0,0 +1,17 @@
1
+ // Next.js Swagger setup using next-swagger-doc
2
+ // File generated by: kybernus add swagger
3
+
4
+ import { createSwaggerSpec } from 'next-swagger-doc';
5
+
6
+ export const getSwaggerSpec = () =>
7
+ createSwaggerSpec({
8
+ apiFolder: 'src/app/api',
9
+ definition: {
10
+ openapi: '3.0.0',
11
+ info: {
12
+ title: 'API Documentation',
13
+ version: '1.0.0',
14
+ description: 'Auto-generated API docs by Kybernus',
15
+ },
16
+ },
17
+ });
@@ -0,0 +1,30 @@
1
+ import swaggerJsdoc from 'swagger-jsdoc';
2
+ import swaggerUi from 'swagger-ui-express';
3
+ import { Express } from 'express';
4
+
5
+ const options: swaggerJsdoc.Options = {
6
+ definition: {
7
+ openapi: '3.0.0',
8
+ info: {
9
+ title: 'API Documentation',
10
+ version: '1.0.0',
11
+ description: 'Auto-generated API docs by Kybernus',
12
+ },
13
+ servers: [
14
+ {
15
+ url: process.env.API_URL || 'http://localhost:3000',
16
+ description: 'Development server',
17
+ },
18
+ ],
19
+ },
20
+ apis: ['./src/**/*.ts'],
21
+ };
22
+
23
+ const swaggerSpec = swaggerJsdoc(options);
24
+
25
+ export function setupSwagger(app: Express): void {
26
+ app.use('/api/docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
27
+ app.get('/api/docs.json', (_, res) => res.json(swaggerSpec));
28
+
29
+ console.log(`📄 Swagger docs available at /api/docs`);
30
+ }
@@ -0,0 +1,21 @@
1
+ """
2
+ FastAPI has OpenAPI/Swagger built-in at /docs and /redoc.
3
+ This file provides a custom configuration to enhance those pages.
4
+
5
+ Apply by importing and calling configure_swagger(app) in your main.py.
6
+ """
7
+
8
+ from fastapi import FastAPI
9
+
10
+
11
+ def configure_swagger(app: FastAPI) -> None:
12
+ """Enhance the built-in FastAPI Swagger/OpenAPI docs."""
13
+ app.title = "API Documentation"
14
+ app.description = "Auto-generated API docs by Kybernus"
15
+ app.version = "1.0.0"
16
+ app.docs_url = "/api/docs"
17
+ app.redoc_url = "/api/redoc"
18
+ app.openapi_url = "/api/openapi.json"
19
+
20
+ print("📄 Swagger docs available at /api/docs")
21
+ print("📄 ReDoc available at /api/redoc")