go-duck-cli 1.0.8 → 1.1.1
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.
- package/README.md +30 -15
- package/generators/ai_docs.js +130 -0
- package/generators/broker.js +63 -0
- package/generators/config.js +149 -7
- package/generators/devops.js +210 -43
- package/generators/docs.js +23 -4
- package/generators/elasticsearch.js +263 -0
- package/generators/kratos.js +229 -41
- package/generators/metering.js +280 -48
- package/generators/migrations.js +92 -198
- package/generators/mqtt.js +2 -39
- package/generators/multitenancy.js +274 -71
- package/generators/nats.js +39 -0
- package/generators/outbox.js +171 -0
- package/generators/postgrest.js +7 -3
- package/generators/postman.js +405 -0
- package/generators/repository.js +27 -0
- package/generators/router.js +27 -0
- package/generators/security.js +95 -14
- package/generators/serverless.js +147 -0
- package/generators/storage.js +589 -0
- package/generators/swagger.js +84 -60
- package/generators/telemetry.js +23 -32
- package/generators/websocket.js +55 -21
- package/index.js +481 -116
- package/package.json +6 -4
- package/parser/gdl.js +163 -24
- package/templates/docs/index.html.hbs +5 -5
- package/templates/docs/layout.hbs +221 -62
- package/templates/docs/pages/audit.hbs +83 -35
- package/templates/docs/pages/cli.hbs +18 -0
- package/templates/docs/pages/configuration.hbs +241 -0
- package/templates/docs/pages/datadog.hbs +46 -0
- package/templates/docs/pages/elasticsearch.hbs +121 -0
- package/templates/docs/pages/federation.hbs +241 -0
- package/templates/docs/pages/gdl-advanced.hbs +91 -0
- package/templates/docs/pages/gdl-annotations.hbs +137 -0
- package/templates/docs/pages/gdl-entities.hbs +134 -0
- package/templates/docs/pages/gdl-relationships.hbs +80 -0
- package/templates/docs/pages/gdl.hbs +60 -204
- package/templates/docs/pages/graphql.hbs +58 -44
- package/templates/docs/pages/grpc.hbs +53 -90
- package/templates/docs/pages/hybrid-store.hbs +127 -0
- package/templates/docs/pages/index.hbs +418 -149
- package/templates/docs/pages/keycloak.hbs +43 -0
- package/templates/docs/pages/legend.hbs +116 -0
- package/templates/docs/pages/mosquitto.hbs +39 -0
- package/templates/docs/pages/multitenancy.hbs +139 -71
- package/templates/docs/pages/otel.hbs +40 -0
- package/templates/docs/pages/realtime.hbs +38 -12
- package/templates/docs/pages/redis.hbs +40 -0
- package/templates/docs/pages/rest.hbs +120 -202
- package/templates/docs/pages/saga.hbs +94 -0
- package/templates/docs/pages/security.hbs +150 -44
- package/templates/docs/pages/serverless.hbs +157 -0
- package/templates/docs/pages/storage.hbs +127 -0
- package/templates/docs/pages/wizard.hbs +683 -0
- package/templates/docs/triple_identity_registry.png +0 -0
- package/templates/go/controller.go.hbs +287 -283
- package/templates/go/entity.go.hbs +17 -15
- package/templates/go/main.go.hbs +47 -180
- package/templates/go/migrator.go.hbs +65 -0
- package/templates/go/router.go.hbs +272 -0
- package/templates/graphql/resolver.go.hbs +53 -34
- package/templates/graphql/schema.graphql.hbs +17 -5
- package/templates/kratos/service.go.hbs +169 -34
- package/templates/proto/entity.proto.hbs +10 -14
- package/test_nested.gdl +21 -0
- package/templates/docs/intro.mp4 +0 -0
- package/test_parser.js +0 -9
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
export const generateServerlessHandler = async (outputDir, config) => {
|
|
6
|
+
if (!config.serverless?.enabled) return;
|
|
7
|
+
|
|
8
|
+
console.log(chalk.blue(' Scaffolding Elite Serverless Adapter (Build-Tag Native)...'));
|
|
9
|
+
|
|
10
|
+
const handlerGo = `//go:build lambda
|
|
11
|
+
// +build lambda
|
|
12
|
+
|
|
13
|
+
package main
|
|
14
|
+
|
|
15
|
+
import (
|
|
16
|
+
"context"
|
|
17
|
+
"log"
|
|
18
|
+
|
|
19
|
+
"{{app_name}}/config"
|
|
20
|
+
"{{app_name}}/router"
|
|
21
|
+
"github.com/aws/aws-lambda-go/events"
|
|
22
|
+
"github.com/aws/aws-lambda-go/lambda"
|
|
23
|
+
ginadapter "github.com/awslabs/aws-lambda-go-api-proxy/gin"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
var ginLambda *ginadapter.GinLambda
|
|
27
|
+
|
|
28
|
+
func init() {
|
|
29
|
+
log.Println("🦆 [SERVERLESS-LAMBDA] Initializing GO-DUCK Elite Gateway...")
|
|
30
|
+
|
|
31
|
+
cfg, err := config.LoadConfig()
|
|
32
|
+
if err != nil {
|
|
33
|
+
log.Fatalf("🦆 [CRITICAL] Failed to load config: %v", err)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Initialize the shared GO-DUCK router
|
|
37
|
+
r := router.SetupRouter(cfg)
|
|
38
|
+
ginLambda = ginadapter.New(r)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func Handler(ctx context.Context, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
|
|
42
|
+
return ginLambda.ProxyWithContext(ctx, req)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
func main() {
|
|
46
|
+
lambda.Start(Handler)
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
await fs.writeFile(
|
|
51
|
+
path.join(outputDir, 'lambda_main.go'),
|
|
52
|
+
handlerGo.replace(/{{app_name}}/g, config.name)
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// --- Google Cloud Functions (HTTP Trigger) ---
|
|
57
|
+
const gcfHandlerGo = `//go:build gcf
|
|
58
|
+
// +build gcf
|
|
59
|
+
|
|
60
|
+
package entrypoint
|
|
61
|
+
|
|
62
|
+
import (
|
|
63
|
+
"net/http"
|
|
64
|
+
"sync"
|
|
65
|
+
"log"
|
|
66
|
+
|
|
67
|
+
"{{app_name}}/config"
|
|
68
|
+
"{{app_name}}/router"
|
|
69
|
+
"github.com/GoogleCloudPlatform/functions-framework-go/functions"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
var (
|
|
73
|
+
initialOnce sync.Once
|
|
74
|
+
h http.Handler
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
func init() {
|
|
78
|
+
functions.HTTP("GoDuckEntry", GoDuckEntry)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
func GoDuckEntry(w http.ResponseWriter, r *http.Request) {
|
|
82
|
+
initialOnce.Do(func() {
|
|
83
|
+
log.Println("🦆 [SERVERLESS-GCF] Initializing GO-DUCK Elite Gateway...")
|
|
84
|
+
cfg, err := config.LoadConfig()
|
|
85
|
+
if err != nil {
|
|
86
|
+
log.Fatalf("🦆 [CRITICAL] Failed to load config: %v", err)
|
|
87
|
+
}
|
|
88
|
+
h = router.SetupRouter(cfg)
|
|
89
|
+
})
|
|
90
|
+
h.ServeHTTP(w, r)
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
await fs.writeFile(
|
|
95
|
+
path.join(outputDir, 'gcf_handler.go'),
|
|
96
|
+
gcfHandlerGo.replace(/{{app_name}}/g, config.name)
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// --- Vercel Edge Serverless ---
|
|
100
|
+
const vercelHandlerGo = `package handler
|
|
101
|
+
|
|
102
|
+
import (
|
|
103
|
+
"net/http"
|
|
104
|
+
"sync"
|
|
105
|
+
"log"
|
|
106
|
+
|
|
107
|
+
"{{app_name}}/config"
|
|
108
|
+
"{{app_name}}/router"
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
var (
|
|
112
|
+
initialOnce sync.Once
|
|
113
|
+
h http.Handler
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
func Handler(w http.ResponseWriter, r *http.Request) {
|
|
117
|
+
initialOnce.Do(func() {
|
|
118
|
+
log.Println("🦆 [SERVERLESS-VERCEL] Initializing GO-DUCK Elite Gateway...")
|
|
119
|
+
cfg, err := config.LoadConfig()
|
|
120
|
+
if err != nil {
|
|
121
|
+
log.Fatalf("🦆 [CRITICAL] Failed to load config: %v", err)
|
|
122
|
+
}
|
|
123
|
+
h = router.SetupRouter(cfg)
|
|
124
|
+
})
|
|
125
|
+
h.ServeHTTP(w, r)
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
const vercelDir = path.join(outputDir, 'api');
|
|
130
|
+
await fs.ensureDir(vercelDir);
|
|
131
|
+
await fs.writeFile(
|
|
132
|
+
path.join(vercelDir, 'index.go'),
|
|
133
|
+
vercelHandlerGo.replace(/{{app_name}}/g, config.name)
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// Generate vercel.json for wildcard routing
|
|
137
|
+
const vercelJson = {
|
|
138
|
+
"version": 2,
|
|
139
|
+
"rewrites": [
|
|
140
|
+
{ "source": "/(.*)", "destination": "/api/index" }
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
await fs.writeJson(path.join(outputDir, 'vercel.json'), vercelJson, { spaces: 2 });
|
|
144
|
+
|
|
145
|
+
console.log(chalk.gray(' - Generated Global Serverless Handlers: lambda_main.go, gcf_handler.go, api/index.go (Vercel), vercel.json'));
|
|
146
|
+
};
|
|
147
|
+
|