@gravito/scaffold 1.0.0-beta.1 → 1.1.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.
- package/dist/index.cjs +2385 -419
- package/dist/index.d.cts +159 -9
- package/dist/index.d.ts +159 -9
- package/dist/index.js +2380 -419
- package/package.json +8 -5
- package/templates/features/otel/.env.example +2 -0
- package/templates/features/otel/config/telemetry.ts +10 -0
- package/templates/features/otel/docker-compose.yml +15 -0
- package/templates/features/otel/package.json +7 -0
- package/templates/features/redis/.env.example +7 -0
- package/templates/features/redis/config/cache.ts +14 -0
- package/templates/features/redis/config/queue.ts +13 -0
- package/templates/features/redis/docker-compose.yml +17 -0
- package/templates/features/redis/package.json +5 -0
- package/templates/overlays/core/.env.example +14 -0
- package/templates/overlays/core/config/cache.ts +26 -0
- package/templates/overlays/core/config/database.ts +38 -0
- package/templates/overlays/core/config/queue.ts +31 -0
- package/templates/overlays/core/package.json +5 -0
- package/templates/overlays/enterprise/.env.example +26 -0
- package/templates/overlays/enterprise/config/cache.ts +31 -0
- package/templates/overlays/enterprise/config/database.ts +34 -0
- package/templates/overlays/enterprise/config/logging.ts +32 -0
- package/templates/overlays/enterprise/config/queue.ts +31 -0
- package/templates/overlays/enterprise/config/security.ts +20 -0
- package/templates/overlays/enterprise/docker-compose.yml +32 -0
- package/templates/overlays/enterprise/package.json +7 -0
- package/templates/overlays/scale/.env.example +22 -0
- package/templates/overlays/scale/config/cache.ts +31 -0
- package/templates/overlays/scale/config/database.ts +34 -0
- package/templates/overlays/scale/config/queue.ts +34 -0
- package/templates/overlays/scale/docker-compose.yml +32 -0
- package/templates/overlays/scale/package.json +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravito/scaffold",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Project scaffolding engine for Gravito - Generate enterprise-grade architecture templates",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
"build": "bun run build.ts",
|
|
18
18
|
"dev": "bun run --watch src/index.ts",
|
|
19
19
|
"test": "bun test",
|
|
20
|
-
"typecheck": "tsc --noEmit"
|
|
20
|
+
"typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
|
|
21
|
+
"test:coverage": "bun test --coverage --coverage-threshold=80",
|
|
22
|
+
"test:ci": "bun test --coverage --coverage-threshold=80"
|
|
21
23
|
},
|
|
22
24
|
"files": [
|
|
23
25
|
"dist",
|
|
@@ -32,10 +34,11 @@
|
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"tsup": "^8.5.1",
|
|
35
|
-
"typescript": "^5.9.3"
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"bun-types": "latest"
|
|
36
39
|
},
|
|
37
40
|
"peerDependencies": {
|
|
38
|
-
"gravito
|
|
41
|
+
"@gravito/core": "workspace:*"
|
|
39
42
|
},
|
|
40
43
|
"author": "Carl Lee <carllee0520@gmail.com>",
|
|
41
44
|
"license": "MIT",
|
|
@@ -45,4 +48,4 @@
|
|
|
45
48
|
"url": "git+https://github.com/gravito-framework/gravito.git",
|
|
46
49
|
"directory": "packages/scaffold"
|
|
47
50
|
}
|
|
48
|
-
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from '@gravito/core/telemetry'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
enabled: process.env.OTEL_ENABLED !== 'false',
|
|
5
|
+
service_name: process.env.APP_NAME || 'gravito-app',
|
|
6
|
+
exporter: {
|
|
7
|
+
type: 'otlp', // or 'console'
|
|
8
|
+
endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
|
|
9
|
+
},
|
|
10
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
services:
|
|
2
|
+
gravito.jaeger:
|
|
3
|
+
image: jaegertracing/all-in-one:latest
|
|
4
|
+
ports:
|
|
5
|
+
- "16686:16686" # Web UI
|
|
6
|
+
- "4317:4317" # OTLP gRPC
|
|
7
|
+
- "4318:4318" # OTLP HTTP
|
|
8
|
+
environment:
|
|
9
|
+
- COLLECTOR_OTLP_ENABLED=true
|
|
10
|
+
networks:
|
|
11
|
+
- gravito
|
|
12
|
+
|
|
13
|
+
networks:
|
|
14
|
+
gravito:
|
|
15
|
+
driver: bridge
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines cache stores and default cache driver.
|
|
5
|
+
* This configuration is used by @gravito/stasis cache orbit.
|
|
6
|
+
*
|
|
7
|
+
* Supported drivers: 'memory', 'file', 'null', 'redis'
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
default: process.env.CACHE_DRIVER || 'memory',
|
|
11
|
+
stores: {
|
|
12
|
+
memory: {
|
|
13
|
+
driver: 'memory',
|
|
14
|
+
maxItems: 10_000,
|
|
15
|
+
},
|
|
16
|
+
file: {
|
|
17
|
+
driver: 'file',
|
|
18
|
+
path: process.env.CACHE_PATH || 'storage/framework/cache',
|
|
19
|
+
},
|
|
20
|
+
redis: {
|
|
21
|
+
driver: 'redis',
|
|
22
|
+
connection: process.env.REDIS_CACHE_CONNECTION || 'default',
|
|
23
|
+
prefix: process.env.REDIS_CACHE_PREFIX || 'cache:',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
} as const
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines database connections and default connection driver.
|
|
5
|
+
* This configuration is used by @gravito/atlas ORM.
|
|
6
|
+
*
|
|
7
|
+
* Supported drivers: 'postgres', 'mysql', 'mariadb', 'sqlite', 'mongodb', 'redis'
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
default: process.env.DB_CONNECTION || 'sqlite',
|
|
11
|
+
connections: {
|
|
12
|
+
sqlite: {
|
|
13
|
+
driver: 'sqlite',
|
|
14
|
+
database: process.env.DB_DATABASE || 'database/database.sqlite',
|
|
15
|
+
},
|
|
16
|
+
postgres: {
|
|
17
|
+
driver: 'postgres',
|
|
18
|
+
host: process.env.DB_HOST || '127.0.0.1',
|
|
19
|
+
port: parseInt(process.env.DB_PORT || '5432', 10),
|
|
20
|
+
database: process.env.DB_DATABASE || 'gravito',
|
|
21
|
+
username: process.env.DB_USERNAME || 'postgres',
|
|
22
|
+
password: process.env.DB_PASSWORD || '',
|
|
23
|
+
charset: 'utf8',
|
|
24
|
+
search_path: 'public',
|
|
25
|
+
sslmode: process.env.DB_SSLMODE || 'prefer',
|
|
26
|
+
},
|
|
27
|
+
mysql: {
|
|
28
|
+
driver: 'mysql',
|
|
29
|
+
host: process.env.DB_HOST || '127.0.0.1',
|
|
30
|
+
port: parseInt(process.env.DB_PORT || '3306', 10),
|
|
31
|
+
database: process.env.DB_DATABASE || 'gravito',
|
|
32
|
+
username: process.env.DB_USERNAME || 'root',
|
|
33
|
+
password: process.env.DB_PASSWORD || '',
|
|
34
|
+
charset: 'utf8mb4',
|
|
35
|
+
collation: 'utf8mb4_unicode_ci',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
} as const
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines queue connections and default queue driver.
|
|
5
|
+
* This configuration is used by @gravito/stream queue system.
|
|
6
|
+
*
|
|
7
|
+
* Supported drivers: 'memory', 'database', 'redis', 'kafka', 'sqs', 'rabbitmq', 'nats'
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
default: process.env.QUEUE_CONNECTION || 'sync',
|
|
11
|
+
connections: {
|
|
12
|
+
sync: {
|
|
13
|
+
driver: 'sync',
|
|
14
|
+
},
|
|
15
|
+
memory: {
|
|
16
|
+
driver: 'memory',
|
|
17
|
+
},
|
|
18
|
+
database: {
|
|
19
|
+
driver: 'database',
|
|
20
|
+
table: process.env.QUEUE_TABLE || 'jobs',
|
|
21
|
+
},
|
|
22
|
+
redis: {
|
|
23
|
+
driver: 'redis',
|
|
24
|
+
host: process.env.REDIS_HOST || '127.0.0.1',
|
|
25
|
+
port: parseInt(process.env.REDIS_PORT || '6379', 10),
|
|
26
|
+
password: process.env.REDIS_PASSWORD,
|
|
27
|
+
db: parseInt(process.env.REDIS_DB || '0', 10),
|
|
28
|
+
prefix: process.env.REDIS_PREFIX || 'queue:',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
} as const
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
APP_NAME=Gravito
|
|
2
|
+
APP_ENV=local
|
|
3
|
+
APP_KEY=
|
|
4
|
+
APP_DEBUG=true
|
|
5
|
+
APP_URL=http://localhost:3000
|
|
6
|
+
|
|
7
|
+
LOG_LEVEL=debug
|
|
8
|
+
LOG_CHANNEL=stack
|
|
9
|
+
|
|
10
|
+
DB_CONNECTION=pgsql
|
|
11
|
+
DB_HOST=127.0.0.1
|
|
12
|
+
DB_PORT=5432
|
|
13
|
+
DB_DATABASE=gravito
|
|
14
|
+
DB_USERNAME=gravito
|
|
15
|
+
DB_PASSWORD=secret
|
|
16
|
+
|
|
17
|
+
CACHE_DRIVER=redis
|
|
18
|
+
QUEUE_CONNECTION=redis
|
|
19
|
+
SESSION_DRIVER=redis
|
|
20
|
+
|
|
21
|
+
REDIS_HOST=127.0.0.1
|
|
22
|
+
REDIS_PASSWORD=null
|
|
23
|
+
REDIS_PORT=6379
|
|
24
|
+
|
|
25
|
+
# Security
|
|
26
|
+
CORS_ALLOWED_ORIGINS=http://localhost:3000
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines cache stores and default cache driver.
|
|
5
|
+
* This configuration is used by @gravito/stasis cache orbit.
|
|
6
|
+
*
|
|
7
|
+
* Enterprise profile: Configured for production with Redis as default.
|
|
8
|
+
*
|
|
9
|
+
* Supported drivers: 'memory', 'file', 'null', 'redis'
|
|
10
|
+
*/
|
|
11
|
+
export default {
|
|
12
|
+
default: process.env.CACHE_DRIVER || 'redis',
|
|
13
|
+
stores: {
|
|
14
|
+
// Redis - Redis 快取(生產環境推薦)
|
|
15
|
+
redis: {
|
|
16
|
+
driver: 'redis',
|
|
17
|
+
connection: process.env.REDIS_CACHE_CONNECTION || 'default',
|
|
18
|
+
prefix: process.env.REDIS_CACHE_PREFIX || 'cache:',
|
|
19
|
+
},
|
|
20
|
+
// Memory - 記憶體快取(開發/測試環境)
|
|
21
|
+
memory: {
|
|
22
|
+
driver: 'memory',
|
|
23
|
+
maxItems: 10_000,
|
|
24
|
+
},
|
|
25
|
+
// File - 檔案快取
|
|
26
|
+
file: {
|
|
27
|
+
driver: 'file',
|
|
28
|
+
path: process.env.CACHE_PATH || 'storage/framework/cache',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
} as const
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines database connections and default connection driver.
|
|
5
|
+
* This configuration is used by @gravito/atlas ORM.
|
|
6
|
+
*
|
|
7
|
+
* Enterprise profile: Configured for production with PostgreSQL as default.
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
default: process.env.DB_CONNECTION || 'postgres',
|
|
11
|
+
connections: {
|
|
12
|
+
postgres: {
|
|
13
|
+
driver: 'postgres',
|
|
14
|
+
host: process.env.DB_HOST || '127.0.0.1',
|
|
15
|
+
port: parseInt(process.env.DB_PORT || '5432', 10),
|
|
16
|
+
database: process.env.DB_DATABASE || 'gravito',
|
|
17
|
+
username: process.env.DB_USERNAME || 'postgres',
|
|
18
|
+
password: process.env.DB_PASSWORD || '',
|
|
19
|
+
charset: 'utf8',
|
|
20
|
+
search_path: 'public',
|
|
21
|
+
sslmode: process.env.DB_SSLMODE || 'prefer',
|
|
22
|
+
},
|
|
23
|
+
mysql: {
|
|
24
|
+
driver: 'mysql',
|
|
25
|
+
host: process.env.DB_HOST || '127.0.0.1',
|
|
26
|
+
port: parseInt(process.env.DB_PORT || '3306', 10),
|
|
27
|
+
database: process.env.DB_DATABASE || 'gravito',
|
|
28
|
+
username: process.env.DB_USERNAME || 'root',
|
|
29
|
+
password: process.env.DB_PASSWORD || '',
|
|
30
|
+
charset: 'utf8mb4',
|
|
31
|
+
collation: 'utf8mb4_unicode_ci',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
} as const
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineConfig } from '@gravito/core/logging'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
default: process.env.LOG_CHANNEL || 'stack',
|
|
5
|
+
channels: {
|
|
6
|
+
stack: {
|
|
7
|
+
driver: 'stack',
|
|
8
|
+
channels: ['daily', 'stdout'],
|
|
9
|
+
ignore_exceptions: false,
|
|
10
|
+
},
|
|
11
|
+
single: {
|
|
12
|
+
driver: 'single',
|
|
13
|
+
path: 'storage/logs/gravito.log',
|
|
14
|
+
level: process.env.LOG_LEVEL || 'debug',
|
|
15
|
+
},
|
|
16
|
+
daily: {
|
|
17
|
+
driver: 'daily',
|
|
18
|
+
path: 'storage/logs/gravito.log',
|
|
19
|
+
level: process.env.LOG_LEVEL || 'debug',
|
|
20
|
+
days: 14,
|
|
21
|
+
},
|
|
22
|
+
stdout: {
|
|
23
|
+
driver: 'monolog',
|
|
24
|
+
handler: 'Monolog\\Handler\\StreamHandler',
|
|
25
|
+
with: {
|
|
26
|
+
stream: 'php://stdout',
|
|
27
|
+
},
|
|
28
|
+
level: process.env.LOG_LEVEL || 'debug',
|
|
29
|
+
formatter: 'json', // Enterprise defaults to structured JSON logging
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines queue connections and default queue driver.
|
|
5
|
+
* This configuration is used by @gravito/stream queue system.
|
|
6
|
+
*
|
|
7
|
+
* Enterprise profile: Configured for production with Redis as default.
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
default: process.env.QUEUE_CONNECTION || 'redis',
|
|
11
|
+
connections: {
|
|
12
|
+
redis: {
|
|
13
|
+
driver: 'redis',
|
|
14
|
+
host: process.env.REDIS_HOST || '127.0.0.1',
|
|
15
|
+
port: parseInt(process.env.REDIS_PORT || '6379', 10),
|
|
16
|
+
password: process.env.REDIS_PASSWORD,
|
|
17
|
+
db: parseInt(process.env.REDIS_DB || '0', 10),
|
|
18
|
+
prefix: process.env.REDIS_PREFIX || 'queue:',
|
|
19
|
+
},
|
|
20
|
+
database: {
|
|
21
|
+
driver: 'database',
|
|
22
|
+
table: process.env.QUEUE_TABLE || 'jobs',
|
|
23
|
+
},
|
|
24
|
+
kafka: {
|
|
25
|
+
driver: 'kafka',
|
|
26
|
+
brokers: (process.env.KAFKA_BROKERS || 'localhost:9092').split(','),
|
|
27
|
+
consumerGroupId: process.env.KAFKA_CONSUMER_GROUP_ID || 'gravito-workers',
|
|
28
|
+
clientId: process.env.KAFKA_CLIENT_ID || 'gravito',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
} as const
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from '@gravito/core/security'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
headers: {
|
|
5
|
+
'X-Content-Type-Options': 'nosniff',
|
|
6
|
+
'X-Frame-Options': 'SAMEORIGIN',
|
|
7
|
+
'X-XSS-Protection': '1; mode=block',
|
|
8
|
+
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
|
|
9
|
+
'Content-Security-Policy':
|
|
10
|
+
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:;",
|
|
11
|
+
},
|
|
12
|
+
cors: {
|
|
13
|
+
allowed_methods: ['*'],
|
|
14
|
+
allowed_origins: ['*'], // Configure this in production
|
|
15
|
+
allowed_headers: ['*'],
|
|
16
|
+
exposed_headers: [],
|
|
17
|
+
max_age: 0,
|
|
18
|
+
supports_credentials: false,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
services:
|
|
2
|
+
gravito.db:
|
|
3
|
+
image: postgres:15-alpine
|
|
4
|
+
environment:
|
|
5
|
+
POSTGRES_DB: ${DB_DATABASE:-gravito}
|
|
6
|
+
POSTGRES_USER: ${DB_USERNAME:-gravito}
|
|
7
|
+
POSTGRES_PASSWORD: ${DB_PASSWORD:-secret}
|
|
8
|
+
ports:
|
|
9
|
+
- '${DB_PORT:-5432}:5432'
|
|
10
|
+
volumes:
|
|
11
|
+
- gravito-db:/var/lib/postgresql/data
|
|
12
|
+
networks:
|
|
13
|
+
- gravito
|
|
14
|
+
|
|
15
|
+
gravito.redis:
|
|
16
|
+
image: redis:alpine
|
|
17
|
+
ports:
|
|
18
|
+
- '${REDIS_PORT:-6379}:6379'
|
|
19
|
+
volumes:
|
|
20
|
+
- gravito-redis:/data
|
|
21
|
+
networks:
|
|
22
|
+
- gravito
|
|
23
|
+
|
|
24
|
+
networks:
|
|
25
|
+
gravito:
|
|
26
|
+
driver: bridge
|
|
27
|
+
|
|
28
|
+
volumes:
|
|
29
|
+
gravito-db:
|
|
30
|
+
driver: local
|
|
31
|
+
gravito-redis:
|
|
32
|
+
driver: local
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
APP_NAME=Gravito
|
|
2
|
+
APP_ENV=local
|
|
3
|
+
APP_KEY=
|
|
4
|
+
APP_DEBUG=true
|
|
5
|
+
APP_URL=http://localhost:3000
|
|
6
|
+
|
|
7
|
+
LOG_LEVEL=debug
|
|
8
|
+
|
|
9
|
+
DB_CONNECTION=pgsql
|
|
10
|
+
DB_HOST=127.0.0.1
|
|
11
|
+
DB_PORT=5432
|
|
12
|
+
DB_DATABASE=gravito
|
|
13
|
+
DB_USERNAME=gravito
|
|
14
|
+
DB_PASSWORD=secret
|
|
15
|
+
|
|
16
|
+
CACHE_DRIVER=redis
|
|
17
|
+
QUEUE_CONNECTION=redis
|
|
18
|
+
SESSION_DRIVER=redis
|
|
19
|
+
|
|
20
|
+
REDIS_HOST=127.0.0.1
|
|
21
|
+
REDIS_PASSWORD=null
|
|
22
|
+
REDIS_PORT=6379
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines cache stores and default cache driver.
|
|
5
|
+
* This configuration is used by @gravito/stasis cache orbit.
|
|
6
|
+
*
|
|
7
|
+
* Scale profile: Configured for high-scale scenarios with Redis as default.
|
|
8
|
+
*
|
|
9
|
+
* Supported drivers: 'memory', 'file', 'null', 'redis'
|
|
10
|
+
*/
|
|
11
|
+
export default {
|
|
12
|
+
default: process.env.CACHE_DRIVER || 'redis',
|
|
13
|
+
stores: {
|
|
14
|
+
// Redis - Redis 快取(生產環境推薦)
|
|
15
|
+
redis: {
|
|
16
|
+
driver: 'redis',
|
|
17
|
+
connection: process.env.REDIS_CACHE_CONNECTION || 'default',
|
|
18
|
+
prefix: process.env.REDIS_CACHE_PREFIX || 'cache:',
|
|
19
|
+
},
|
|
20
|
+
// Memory - 記憶體快取(開發/測試環境)
|
|
21
|
+
memory: {
|
|
22
|
+
driver: 'memory',
|
|
23
|
+
maxItems: 10_000,
|
|
24
|
+
},
|
|
25
|
+
// File - 檔案快取
|
|
26
|
+
file: {
|
|
27
|
+
driver: 'file',
|
|
28
|
+
path: process.env.CACHE_PATH || 'storage/framework/cache',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
} as const
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines database connections and default connection driver.
|
|
5
|
+
* This configuration is used by @gravito/atlas ORM.
|
|
6
|
+
*
|
|
7
|
+
* Scale profile: Configured for high-scale scenarios with PostgreSQL as default.
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
default: process.env.DB_CONNECTION || 'postgres',
|
|
11
|
+
connections: {
|
|
12
|
+
postgres: {
|
|
13
|
+
driver: 'postgres',
|
|
14
|
+
host: process.env.DB_HOST || '127.0.0.1',
|
|
15
|
+
port: parseInt(process.env.DB_PORT || '5432', 10),
|
|
16
|
+
database: process.env.DB_DATABASE || 'gravito',
|
|
17
|
+
username: process.env.DB_USERNAME || 'postgres',
|
|
18
|
+
password: process.env.DB_PASSWORD || '',
|
|
19
|
+
charset: 'utf8',
|
|
20
|
+
search_path: 'public',
|
|
21
|
+
sslmode: process.env.DB_SSLMODE || 'prefer',
|
|
22
|
+
},
|
|
23
|
+
mysql: {
|
|
24
|
+
driver: 'mysql',
|
|
25
|
+
host: process.env.DB_HOST || '127.0.0.1',
|
|
26
|
+
port: parseInt(process.env.DB_PORT || '3306', 10),
|
|
27
|
+
database: process.env.DB_DATABASE || 'gravito',
|
|
28
|
+
username: process.env.DB_USERNAME || 'root',
|
|
29
|
+
password: process.env.DB_PASSWORD || '',
|
|
30
|
+
charset: 'utf8mb4',
|
|
31
|
+
collation: 'utf8mb4_unicode_ci',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
} as const
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines queue connections and default queue driver.
|
|
5
|
+
* This configuration is used by @gravito/stream queue system.
|
|
6
|
+
*
|
|
7
|
+
* Scale profile: Configured for high-scale scenarios with Redis and Kafka support.
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
default: process.env.QUEUE_CONNECTION || 'redis',
|
|
11
|
+
connections: {
|
|
12
|
+
redis: {
|
|
13
|
+
driver: 'redis',
|
|
14
|
+
host: process.env.REDIS_HOST || '127.0.0.1',
|
|
15
|
+
port: parseInt(process.env.REDIS_PORT || '6379', 10),
|
|
16
|
+
password: process.env.REDIS_PASSWORD,
|
|
17
|
+
db: parseInt(process.env.REDIS_DB || '0', 10),
|
|
18
|
+
prefix: process.env.REDIS_PREFIX || 'queue:',
|
|
19
|
+
},
|
|
20
|
+
kafka: {
|
|
21
|
+
driver: 'kafka',
|
|
22
|
+
brokers: (process.env.KAFKA_BROKERS || 'localhost:9092').split(','),
|
|
23
|
+
consumerGroupId: process.env.KAFKA_CONSUMER_GROUP_ID || 'gravito-workers',
|
|
24
|
+
clientId: process.env.KAFKA_CLIENT_ID || 'gravito',
|
|
25
|
+
},
|
|
26
|
+
database: {
|
|
27
|
+
driver: 'database',
|
|
28
|
+
table: process.env.QUEUE_TABLE || 'jobs',
|
|
29
|
+
},
|
|
30
|
+
sync: {
|
|
31
|
+
driver: 'sync',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
} as const
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
services:
|
|
2
|
+
gravito.db:
|
|
3
|
+
image: postgres:15-alpine
|
|
4
|
+
environment:
|
|
5
|
+
POSTGRES_DB: ${DB_DATABASE:-gravito}
|
|
6
|
+
POSTGRES_USER: ${DB_USERNAME:-gravito}
|
|
7
|
+
POSTGRES_PASSWORD: ${DB_PASSWORD:-secret}
|
|
8
|
+
ports:
|
|
9
|
+
- '${DB_PORT:-5432}:5432'
|
|
10
|
+
volumes:
|
|
11
|
+
- gravito-db:/var/lib/postgresql/data
|
|
12
|
+
networks:
|
|
13
|
+
- gravito
|
|
14
|
+
|
|
15
|
+
gravito.redis:
|
|
16
|
+
image: redis:alpine
|
|
17
|
+
ports:
|
|
18
|
+
- '${REDIS_PORT:-6379}:6379'
|
|
19
|
+
volumes:
|
|
20
|
+
- gravito-redis:/data
|
|
21
|
+
networks:
|
|
22
|
+
- gravito
|
|
23
|
+
|
|
24
|
+
networks:
|
|
25
|
+
gravito:
|
|
26
|
+
driver: bridge
|
|
27
|
+
|
|
28
|
+
volumes:
|
|
29
|
+
gravito-db:
|
|
30
|
+
driver: local
|
|
31
|
+
gravito-redis:
|
|
32
|
+
driver: local
|