@hivehub/rulebook 1.2.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/LICENSE +191 -0
- package/README.md +539 -0
- package/dist/agents/claude-code.d.ts +69 -0
- package/dist/agents/claude-code.d.ts.map +1 -0
- package/dist/agents/claude-code.js +180 -0
- package/dist/agents/claude-code.js.map +1 -0
- package/dist/agents/cursor-agent.d.ts +184 -0
- package/dist/agents/cursor-agent.d.ts.map +1 -0
- package/dist/agents/cursor-agent.js +299 -0
- package/dist/agents/cursor-agent.js.map +1 -0
- package/dist/agents/gemini-cli.d.ts +69 -0
- package/dist/agents/gemini-cli.d.ts.map +1 -0
- package/dist/agents/gemini-cli.js +180 -0
- package/dist/agents/gemini-cli.js.map +1 -0
- package/dist/cli/commands.d.ts +57 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +1370 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/docs-prompts.d.ts +3 -0
- package/dist/cli/docs-prompts.d.ts.map +1 -0
- package/dist/cli/docs-prompts.js +45 -0
- package/dist/cli/docs-prompts.js.map +1 -0
- package/dist/cli/prompts.d.ts +6 -0
- package/dist/cli/prompts.d.ts.map +1 -0
- package/dist/cli/prompts.js +376 -0
- package/dist/cli/prompts.js.map +1 -0
- package/dist/core/agent-manager.d.ts +89 -0
- package/dist/core/agent-manager.d.ts.map +1 -0
- package/dist/core/agent-manager.js +546 -0
- package/dist/core/agent-manager.js.map +1 -0
- package/dist/core/auto-fixer.d.ts +14 -0
- package/dist/core/auto-fixer.d.ts.map +1 -0
- package/dist/core/auto-fixer.js +207 -0
- package/dist/core/auto-fixer.js.map +1 -0
- package/dist/core/changelog-generator.d.ts +44 -0
- package/dist/core/changelog-generator.d.ts.map +1 -0
- package/dist/core/changelog-generator.js +222 -0
- package/dist/core/changelog-generator.js.map +1 -0
- package/dist/core/cli-bridge.d.ts +113 -0
- package/dist/core/cli-bridge.d.ts.map +1 -0
- package/dist/core/cli-bridge.js +1094 -0
- package/dist/core/cli-bridge.js.map +1 -0
- package/dist/core/config-manager.d.ts +65 -0
- package/dist/core/config-manager.d.ts.map +1 -0
- package/dist/core/config-manager.js +266 -0
- package/dist/core/config-manager.js.map +1 -0
- package/dist/core/coverage-checker.d.ts +14 -0
- package/dist/core/coverage-checker.d.ts.map +1 -0
- package/dist/core/coverage-checker.js +176 -0
- package/dist/core/coverage-checker.js.map +1 -0
- package/dist/core/custom-templates.d.ts +27 -0
- package/dist/core/custom-templates.d.ts.map +1 -0
- package/dist/core/custom-templates.js +122 -0
- package/dist/core/custom-templates.js.map +1 -0
- package/dist/core/dependency-checker.d.ts +21 -0
- package/dist/core/dependency-checker.d.ts.map +1 -0
- package/dist/core/dependency-checker.js +247 -0
- package/dist/core/dependency-checker.js.map +1 -0
- package/dist/core/detector.d.ts +3 -0
- package/dist/core/detector.d.ts.map +1 -0
- package/dist/core/detector.js +1443 -0
- package/dist/core/detector.js.map +1 -0
- package/dist/core/docs-generator.d.ts +9 -0
- package/dist/core/docs-generator.d.ts.map +1 -0
- package/dist/core/docs-generator.js +531 -0
- package/dist/core/docs-generator.js.map +1 -0
- package/dist/core/generator.d.ts +16 -0
- package/dist/core/generator.d.ts.map +1 -0
- package/dist/core/generator.js +561 -0
- package/dist/core/generator.js.map +1 -0
- package/dist/core/gitignore-generator.d.ts +13 -0
- package/dist/core/gitignore-generator.d.ts.map +1 -0
- package/dist/core/gitignore-generator.js +307 -0
- package/dist/core/gitignore-generator.js.map +1 -0
- package/dist/core/health-scorer.d.ts +22 -0
- package/dist/core/health-scorer.d.ts.map +1 -0
- package/dist/core/health-scorer.js +395 -0
- package/dist/core/health-scorer.js.map +1 -0
- package/dist/core/logger.d.ts +116 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +289 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/merger.d.ts +6 -0
- package/dist/core/merger.d.ts.map +1 -0
- package/dist/core/merger.js +131 -0
- package/dist/core/merger.js.map +1 -0
- package/dist/core/migrator.d.ts +19 -0
- package/dist/core/migrator.d.ts.map +1 -0
- package/dist/core/migrator.js +102 -0
- package/dist/core/migrator.js.map +1 -0
- package/dist/core/minimal-scaffolder.d.ts +8 -0
- package/dist/core/minimal-scaffolder.d.ts.map +1 -0
- package/dist/core/minimal-scaffolder.js +51 -0
- package/dist/core/minimal-scaffolder.js.map +1 -0
- package/dist/core/modern-console-new.d.ts +81 -0
- package/dist/core/modern-console-new.d.ts.map +1 -0
- package/dist/core/modern-console-new.js +340 -0
- package/dist/core/modern-console-new.js.map +1 -0
- package/dist/core/modern-console.d.ts +99 -0
- package/dist/core/modern-console.d.ts.map +1 -0
- package/dist/core/modern-console.js +568 -0
- package/dist/core/modern-console.js.map +1 -0
- package/dist/core/openspec-manager.d.ts +133 -0
- package/dist/core/openspec-manager.d.ts.map +1 -0
- package/dist/core/openspec-manager.js +605 -0
- package/dist/core/openspec-manager.js.map +1 -0
- package/dist/core/openspec-migrator.d.ts +27 -0
- package/dist/core/openspec-migrator.d.ts.map +1 -0
- package/dist/core/openspec-migrator.js +255 -0
- package/dist/core/openspec-migrator.js.map +1 -0
- package/dist/core/task-manager.d.ts +65 -0
- package/dist/core/task-manager.d.ts.map +1 -0
- package/dist/core/task-manager.js +318 -0
- package/dist/core/task-manager.js.map +1 -0
- package/dist/core/test-task-manager.d.ts +49 -0
- package/dist/core/test-task-manager.d.ts.map +1 -0
- package/dist/core/test-task-manager.js +121 -0
- package/dist/core/test-task-manager.js.map +1 -0
- package/dist/core/validator.d.ts +21 -0
- package/dist/core/validator.d.ts.map +1 -0
- package/dist/core/validator.js +177 -0
- package/dist/core/validator.js.map +1 -0
- package/dist/core/version-bumper.d.ts +19 -0
- package/dist/core/version-bumper.d.ts.map +1 -0
- package/dist/core/version-bumper.js +180 -0
- package/dist/core/version-bumper.js.map +1 -0
- package/dist/core/watcher.d.ts +9 -0
- package/dist/core/watcher.d.ts.map +1 -0
- package/dist/core/watcher.js +22 -0
- package/dist/core/watcher.js.map +1 -0
- package/dist/core/workflow-generator.d.ts +10 -0
- package/dist/core/workflow-generator.d.ts.map +1 -0
- package/dist/core/workflow-generator.js +279 -0
- package/dist/core/workflow-generator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +159 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/handlers/archive-task.d.ts +17 -0
- package/dist/mcp/handlers/archive-task.d.ts.map +1 -0
- package/dist/mcp/handlers/archive-task.js +36 -0
- package/dist/mcp/handlers/archive-task.js.map +1 -0
- package/dist/mcp/handlers/create-task.d.ts +17 -0
- package/dist/mcp/handlers/create-task.d.ts.map +1 -0
- package/dist/mcp/handlers/create-task.js +56 -0
- package/dist/mcp/handlers/create-task.js.map +1 -0
- package/dist/mcp/handlers/list-tasks.d.ts +22 -0
- package/dist/mcp/handlers/list-tasks.d.ts.map +1 -0
- package/dist/mcp/handlers/list-tasks.js +42 -0
- package/dist/mcp/handlers/list-tasks.js.map +1 -0
- package/dist/mcp/handlers/show-task.d.ts +25 -0
- package/dist/mcp/handlers/show-task.d.ts.map +1 -0
- package/dist/mcp/handlers/show-task.js +43 -0
- package/dist/mcp/handlers/show-task.js.map +1 -0
- package/dist/mcp/handlers/update-task.d.ts +17 -0
- package/dist/mcp/handlers/update-task.d.ts.map +1 -0
- package/dist/mcp/handlers/update-task.js +35 -0
- package/dist/mcp/handlers/update-task.js.map +1 -0
- package/dist/mcp/handlers/validate-task.d.ts +15 -0
- package/dist/mcp/handlers/validate-task.d.ts.map +1 -0
- package/dist/mcp/handlers/validate-task.js +27 -0
- package/dist/mcp/handlers/validate-task.js.map +1 -0
- package/dist/mcp/rulebook-config.d.ts +22 -0
- package/dist/mcp/rulebook-config.d.ts.map +1 -0
- package/dist/mcp/rulebook-config.js +65 -0
- package/dist/mcp/rulebook-config.js.map +1 -0
- package/dist/mcp/rulebook-server.d.ts +4 -0
- package/dist/mcp/rulebook-server.d.ts.map +1 -0
- package/dist/mcp/rulebook-server.js +246 -0
- package/dist/mcp/rulebook-server.js.map +1 -0
- package/dist/types.d.ts +190 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/file-system.d.ts +9 -0
- package/dist/utils/file-system.d.ts.map +1 -0
- package/dist/utils/file-system.js +51 -0
- package/dist/utils/file-system.js.map +1 -0
- package/dist/utils/git-hooks.d.ts +8 -0
- package/dist/utils/git-hooks.d.ts.map +1 -0
- package/dist/utils/git-hooks.js +440 -0
- package/dist/utils/git-hooks.js.map +1 -0
- package/dist/utils/rulesignore.d.ts +9 -0
- package/dist/utils/rulesignore.d.ts.map +1 -0
- package/dist/utils/rulesignore.js +42 -0
- package/dist/utils/rulesignore.js.map +1 -0
- package/package.json +106 -0
- package/templates/cli/AIDER.md +49 -0
- package/templates/cli/AMAZON_Q.md +25 -0
- package/templates/cli/AUGGIE.md +32 -0
- package/templates/cli/CLAUDE.md +32 -0
- package/templates/cli/CLAUDE_CODE.md +35 -0
- package/templates/cli/CLINE.md +32 -0
- package/templates/cli/CODEBUDDY.md +20 -0
- package/templates/cli/CODEIUM.md +20 -0
- package/templates/cli/CODEX.md +21 -0
- package/templates/cli/CONTINUE.md +34 -0
- package/templates/cli/CURSOR_CLI.md +28 -0
- package/templates/cli/FACTORY.md +18 -0
- package/templates/cli/GEMINI.md +35 -0
- package/templates/cli/KILOCODE.md +18 -0
- package/templates/cli/OPENCODE.md +18 -0
- package/templates/cli/_GENERIC_TEMPLATE.md +29 -0
- package/templates/commands/rulebook-task-apply.md +67 -0
- package/templates/commands/rulebook-task-archive.md +70 -0
- package/templates/commands/rulebook-task-create.md +93 -0
- package/templates/commands/rulebook-task-list.md +42 -0
- package/templates/commands/rulebook-task-show.md +52 -0
- package/templates/commands/rulebook-task-validate.md +53 -0
- package/templates/core/AGENT_AUTOMATION.md +184 -0
- package/templates/core/DAG.md +304 -0
- package/templates/core/DOCUMENTATION_RULES.md +37 -0
- package/templates/core/QUALITY_ENFORCEMENT.md +68 -0
- package/templates/core/RULEBOOK.md +1874 -0
- package/templates/frameworks/ANGULAR.md +36 -0
- package/templates/frameworks/DJANGO.md +83 -0
- package/templates/frameworks/ELECTRON.md +147 -0
- package/templates/frameworks/FLASK.md +38 -0
- package/templates/frameworks/FLUTTER.md +55 -0
- package/templates/frameworks/JQUERY.md +32 -0
- package/templates/frameworks/LARAVEL.md +38 -0
- package/templates/frameworks/NESTJS.md +43 -0
- package/templates/frameworks/NEXTJS.md +127 -0
- package/templates/frameworks/NUXT.md +40 -0
- package/templates/frameworks/RAILS.md +66 -0
- package/templates/frameworks/REACT.md +38 -0
- package/templates/frameworks/REACT_NATIVE.md +47 -0
- package/templates/frameworks/SPRING.md +39 -0
- package/templates/frameworks/SYMFONY.md +36 -0
- package/templates/frameworks/VUE.md +36 -0
- package/templates/frameworks/ZEND.md +35 -0
- package/templates/git/CI_CD_PATTERNS.md +661 -0
- package/templates/git/GITHUB_ACTIONS.md +728 -0
- package/templates/git/GITLAB_CI.md +730 -0
- package/templates/git/GIT_WORKFLOW.md +1157 -0
- package/templates/git/SECRETS_MANAGEMENT.md +585 -0
- package/templates/hooks/COMMIT_MSG.md +530 -0
- package/templates/hooks/POST_CHECKOUT.md +546 -0
- package/templates/hooks/PREPARE_COMMIT_MSG.md +619 -0
- package/templates/hooks/PRE_COMMIT.md +414 -0
- package/templates/hooks/PRE_PUSH.md +601 -0
- package/templates/hooks/csharp-pre-commit.sh +23 -0
- package/templates/hooks/csharp-pre-push.sh +23 -0
- package/templates/hooks/dart-pre-commit.sh +30 -0
- package/templates/hooks/dart-pre-push.sh +25 -0
- package/templates/hooks/elixir-pre-commit.sh +32 -0
- package/templates/hooks/elixir-pre-push.sh +31 -0
- package/templates/hooks/erlang-pre-commit.sh +30 -0
- package/templates/hooks/erlang-pre-push.sh +37 -0
- package/templates/hooks/go-pre-commit.sh +40 -0
- package/templates/hooks/go-pre-push.sh +31 -0
- package/templates/hooks/haskell-pre-commit.sh +41 -0
- package/templates/hooks/haskell-pre-push.sh +37 -0
- package/templates/hooks/java-pre-commit.sh +34 -0
- package/templates/hooks/java-pre-push.sh +24 -0
- package/templates/hooks/kotlin-pre-commit.sh +32 -0
- package/templates/hooks/kotlin-pre-push.sh +16 -0
- package/templates/hooks/php-pre-commit.sh +36 -0
- package/templates/hooks/php-pre-push.sh +26 -0
- package/templates/hooks/python-pre-commit.sh +51 -0
- package/templates/hooks/python-pre-push.sh +25 -0
- package/templates/hooks/ruby-pre-commit.sh +33 -0
- package/templates/hooks/ruby-pre-push.sh +32 -0
- package/templates/hooks/rust-pre-commit.sh +30 -0
- package/templates/hooks/rust-pre-push.sh +30 -0
- package/templates/hooks/scala-pre-commit.sh +32 -0
- package/templates/hooks/scala-pre-push.sh +24 -0
- package/templates/hooks/swift-pre-commit.sh +25 -0
- package/templates/hooks/swift-pre-push.sh +23 -0
- package/templates/hooks/typescript-pre-commit.sh +37 -0
- package/templates/hooks/typescript-pre-push.sh +36 -0
- package/templates/ides/COPILOT.md +37 -0
- package/templates/ides/CURSOR.md +43 -0
- package/templates/ides/JETBRAINS_AI.md +35 -0
- package/templates/ides/REPLIT.md +36 -0
- package/templates/ides/TABNINE.md +29 -0
- package/templates/ides/VSCODE.md +40 -0
- package/templates/ides/WINDSURF.md +36 -0
- package/templates/ides/ZED.md +32 -0
- package/templates/languages/ADA.md +58 -0
- package/templates/languages/C.md +333 -0
- package/templates/languages/CPP.md +743 -0
- package/templates/languages/CSHARP.md +417 -0
- package/templates/languages/DART.md +332 -0
- package/templates/languages/ELIXIR.md +454 -0
- package/templates/languages/ERLANG.md +361 -0
- package/templates/languages/GO.md +645 -0
- package/templates/languages/HASKELL.md +177 -0
- package/templates/languages/JAVA.md +607 -0
- package/templates/languages/JAVASCRIPT.md +631 -0
- package/templates/languages/JULIA.md +97 -0
- package/templates/languages/KOTLIN.md +511 -0
- package/templates/languages/LISP.md +100 -0
- package/templates/languages/LUA.md +74 -0
- package/templates/languages/OBJECTIVEC.md +90 -0
- package/templates/languages/PHP.md +416 -0
- package/templates/languages/PYTHON.md +682 -0
- package/templates/languages/R.md +350 -0
- package/templates/languages/RUBY.md +421 -0
- package/templates/languages/RUST.md +477 -0
- package/templates/languages/SAS.md +73 -0
- package/templates/languages/SCALA.md +348 -0
- package/templates/languages/SOLIDITY.md +580 -0
- package/templates/languages/SQL.md +137 -0
- package/templates/languages/SWIFT.md +466 -0
- package/templates/languages/TYPESCRIPT.md +591 -0
- package/templates/languages/ZIG.md +265 -0
- package/templates/modules/ATLASSIAN.md +255 -0
- package/templates/modules/CONTEXT7.md +54 -0
- package/templates/modules/FIGMA.md +267 -0
- package/templates/modules/GITHUB_MCP.md +64 -0
- package/templates/modules/GRAFANA.md +328 -0
- package/templates/modules/NOTION.md +247 -0
- package/templates/modules/PLAYWRIGHT.md +90 -0
- package/templates/modules/RULEBOOK_MCP.md +156 -0
- package/templates/modules/SERENA.md +337 -0
- package/templates/modules/SUPABASE.md +223 -0
- package/templates/modules/SYNAP.md +69 -0
- package/templates/modules/VECTORIZER.md +63 -0
- package/templates/services/AZURE_BLOB.md +184 -0
- package/templates/services/CASSANDRA.md +239 -0
- package/templates/services/DYNAMODB.md +308 -0
- package/templates/services/ELASTICSEARCH.md +347 -0
- package/templates/services/GCS.md +178 -0
- package/templates/services/INFLUXDB.md +265 -0
- package/templates/services/KAFKA.md +341 -0
- package/templates/services/MARIADB.md +183 -0
- package/templates/services/MEMCACHED.md +242 -0
- package/templates/services/MINIO.md +201 -0
- package/templates/services/MONGODB.md +268 -0
- package/templates/services/MYSQL.md +358 -0
- package/templates/services/NEO4J.md +247 -0
- package/templates/services/ORACLE.md +290 -0
- package/templates/services/POSTGRESQL.md +326 -0
- package/templates/services/RABBITMQ.md +286 -0
- package/templates/services/REDIS.md +292 -0
- package/templates/services/S3.md +298 -0
- package/templates/services/SQLITE.md +294 -0
- package/templates/services/SQLSERVER.md +294 -0
- package/templates/workflows/codespell.yml +31 -0
- package/templates/workflows/cpp-lint.yml +47 -0
- package/templates/workflows/cpp-publish.yml +119 -0
- package/templates/workflows/cpp-test.yml +77 -0
- package/templates/workflows/dotnet-lint.yml +29 -0
- package/templates/workflows/dotnet-publish.yml +40 -0
- package/templates/workflows/dotnet-test.yml +41 -0
- package/templates/workflows/elixir-lint.yml +45 -0
- package/templates/workflows/elixir-publish.yml +49 -0
- package/templates/workflows/elixir-test.yml +54 -0
- package/templates/workflows/erlang-lint.yml +47 -0
- package/templates/workflows/erlang-test.yml +62 -0
- package/templates/workflows/go-lint.yml +39 -0
- package/templates/workflows/go-publish.yml +95 -0
- package/templates/workflows/go-test.yml +59 -0
- package/templates/workflows/java-lint.yml +60 -0
- package/templates/workflows/java-publish.yml +120 -0
- package/templates/workflows/java-test.yml +85 -0
- package/templates/workflows/kotlin-lint.yml +34 -0
- package/templates/workflows/kotlin-publish.yml +56 -0
- package/templates/workflows/kotlin-test.yml +48 -0
- package/templates/workflows/php-lint.yml +39 -0
- package/templates/workflows/php-publish.yml +50 -0
- package/templates/workflows/php-test.yml +54 -0
- package/templates/workflows/python-lint.yml +47 -0
- package/templates/workflows/python-publish.yml +91 -0
- package/templates/workflows/python-test.yml +59 -0
- package/templates/workflows/rust-lint.yml +54 -0
- package/templates/workflows/rust-publish.yml +66 -0
- package/templates/workflows/rust-test.yml +75 -0
- package/templates/workflows/solidity-lint.yml +41 -0
- package/templates/workflows/solidity-test.yml +47 -0
- package/templates/workflows/swift-lint.yml +32 -0
- package/templates/workflows/swift-publish.yml +58 -0
- package/templates/workflows/swift-test.yml +44 -0
- package/templates/workflows/typescript-lint.yml +61 -0
- package/templates/workflows/typescript-publish.yml +60 -0
- package/templates/workflows/typescript-test.yml +73 -0
- package/templates/workflows/zig-lint.yml +27 -0
- package/templates/workflows/zig-test.yml +40 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
<!-- MARIADB:START -->
|
|
2
|
+
# MariaDB Database Instructions
|
|
3
|
+
|
|
4
|
+
**CRITICAL**: Use MariaDB for MySQL-compatible relational database with enhanced features, performance improvements, and open-source licensing.
|
|
5
|
+
|
|
6
|
+
## Core Features
|
|
7
|
+
|
|
8
|
+
### Connection
|
|
9
|
+
```typescript
|
|
10
|
+
// Using mysql2 (compatible with MySQL)
|
|
11
|
+
import mysql from 'mysql2/promise'
|
|
12
|
+
|
|
13
|
+
const pool = mysql.createPool({
|
|
14
|
+
host: process.env.DB_HOST || 'localhost',
|
|
15
|
+
port: parseInt(process.env.DB_PORT || '3306'),
|
|
16
|
+
database: process.env.DB_NAME || 'myapp',
|
|
17
|
+
user: process.env.DB_USER,
|
|
18
|
+
password: process.env.DB_PASSWORD,
|
|
19
|
+
waitForConnections: true,
|
|
20
|
+
connectionLimit: 10,
|
|
21
|
+
queueLimit: 0,
|
|
22
|
+
enableKeepAlive: true,
|
|
23
|
+
keepAliveInitialDelay: 0,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// Using Prisma
|
|
27
|
+
import { PrismaClient } from '@prisma/client'
|
|
28
|
+
const prisma = new PrismaClient()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Basic Queries
|
|
32
|
+
```typescript
|
|
33
|
+
// SELECT
|
|
34
|
+
const [rows] = await pool.execute('SELECT * FROM users WHERE id = ?', [userId])
|
|
35
|
+
const users = rows as User[]
|
|
36
|
+
|
|
37
|
+
// INSERT
|
|
38
|
+
const [result] = await pool.execute(
|
|
39
|
+
'INSERT INTO users (name, email) VALUES (?, ?)',
|
|
40
|
+
['John Doe', 'john@example.com']
|
|
41
|
+
)
|
|
42
|
+
const insertId = (result as any).insertId
|
|
43
|
+
|
|
44
|
+
// UPDATE
|
|
45
|
+
const [result] = await pool.execute(
|
|
46
|
+
'UPDATE users SET name = ? WHERE id = ?',
|
|
47
|
+
['Jane Doe', userId]
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
// DELETE
|
|
51
|
+
await pool.execute('DELETE FROM users WHERE id = ?', [userId])
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Advanced Features
|
|
55
|
+
```typescript
|
|
56
|
+
// JSON operations (MariaDB 10.2.7+)
|
|
57
|
+
const [rows] = await pool.execute(
|
|
58
|
+
"SELECT * FROM products WHERE JSON_EXTRACT(metadata, '$.category') = ?",
|
|
59
|
+
['electronics']
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
// Window functions (MariaDB 10.2+)
|
|
63
|
+
const [rows] = await pool.execute(`
|
|
64
|
+
SELECT
|
|
65
|
+
name,
|
|
66
|
+
salary,
|
|
67
|
+
ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) as rank
|
|
68
|
+
FROM employees
|
|
69
|
+
`)
|
|
70
|
+
|
|
71
|
+
// Common Table Expressions (CTE) (MariaDB 10.2+)
|
|
72
|
+
const [rows] = await pool.execute(`
|
|
73
|
+
WITH RECURSIVE cte AS (
|
|
74
|
+
SELECT id, name, parent_id FROM categories WHERE parent_id IS NULL
|
|
75
|
+
UNION ALL
|
|
76
|
+
SELECT c.id, c.name, c.parent_id FROM categories c
|
|
77
|
+
INNER JOIN cte ON c.parent_id = cte.id
|
|
78
|
+
)
|
|
79
|
+
SELECT * FROM cte
|
|
80
|
+
`)
|
|
81
|
+
|
|
82
|
+
// Sequences (MariaDB 10.3+)
|
|
83
|
+
await pool.execute('CREATE SEQUENCE user_id_seq START WITH 1 INCREMENT BY 1')
|
|
84
|
+
const [result] = await pool.execute('SELECT NEXT VALUE FOR user_id_seq')
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Common Patterns
|
|
88
|
+
|
|
89
|
+
### Connection Pooling
|
|
90
|
+
```typescript
|
|
91
|
+
let pool: mysql.Pool | null = null
|
|
92
|
+
|
|
93
|
+
export function getPool(): mysql.Pool {
|
|
94
|
+
if (!pool) {
|
|
95
|
+
pool = mysql.createPool({
|
|
96
|
+
// ... config
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
return pool
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Graceful shutdown
|
|
103
|
+
process.on('SIGINT', async () => {
|
|
104
|
+
if (pool) {
|
|
105
|
+
await pool.end()
|
|
106
|
+
}
|
|
107
|
+
process.exit(0)
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Error Handling
|
|
112
|
+
```typescript
|
|
113
|
+
try {
|
|
114
|
+
const [rows] = await pool.execute('SELECT * FROM users WHERE id = ?', [userId])
|
|
115
|
+
if ((rows as any[]).length === 0) {
|
|
116
|
+
throw new Error('User not found')
|
|
117
|
+
}
|
|
118
|
+
return rows[0]
|
|
119
|
+
} catch (error: any) {
|
|
120
|
+
if (error.code === 'ER_DUP_ENTRY') {
|
|
121
|
+
throw new Error('Duplicate entry')
|
|
122
|
+
}
|
|
123
|
+
throw error
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Best Practices
|
|
128
|
+
|
|
129
|
+
✅ **DO:**
|
|
130
|
+
- Use connection pooling (10-20 connections)
|
|
131
|
+
- Always use parameterized queries (?)
|
|
132
|
+
- Use transactions for multi-step operations
|
|
133
|
+
- Create indexes on frequently queried columns
|
|
134
|
+
- Use InnoDB engine (ACID compliance)
|
|
135
|
+
- Set appropriate charset (utf8mb4)
|
|
136
|
+
- Monitor slow query log
|
|
137
|
+
- Use prepared statements
|
|
138
|
+
|
|
139
|
+
❌ **DON'T:**
|
|
140
|
+
- Use string concatenation for queries
|
|
141
|
+
- Create too many connections
|
|
142
|
+
- Skip error handling
|
|
143
|
+
- Use MyISAM engine
|
|
144
|
+
- Hardcode connection strings
|
|
145
|
+
- Ignore query performance
|
|
146
|
+
|
|
147
|
+
## Configuration
|
|
148
|
+
|
|
149
|
+
### Environment Variables
|
|
150
|
+
```bash
|
|
151
|
+
DB_HOST=localhost
|
|
152
|
+
DB_PORT=3306
|
|
153
|
+
DB_NAME=myapp
|
|
154
|
+
DB_USER=myuser
|
|
155
|
+
DB_PASSWORD=securepassword
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Docker Compose
|
|
159
|
+
```yaml
|
|
160
|
+
services:
|
|
161
|
+
mariadb:
|
|
162
|
+
image: mariadb:11
|
|
163
|
+
environment:
|
|
164
|
+
MYSQL_DATABASE: myapp
|
|
165
|
+
MYSQL_USER: myuser
|
|
166
|
+
MYSQL_PASSWORD: securepassword
|
|
167
|
+
MYSQL_ROOT_PASSWORD: rootpassword
|
|
168
|
+
ports:
|
|
169
|
+
- "3306:3306"
|
|
170
|
+
volumes:
|
|
171
|
+
- mariadb_data:/var/lib/mysql
|
|
172
|
+
healthcheck:
|
|
173
|
+
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
|
174
|
+
interval: 10s
|
|
175
|
+
timeout: 5s
|
|
176
|
+
retries: 5
|
|
177
|
+
|
|
178
|
+
volumes:
|
|
179
|
+
mariadb_data:
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
<!-- MARIADB:END -->
|
|
183
|
+
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<!-- MEMCACHED:START -->
|
|
2
|
+
# Memcached Cache Instructions
|
|
3
|
+
|
|
4
|
+
**CRITICAL**: Use Memcached for simple, high-performance distributed caching with minimal overhead.
|
|
5
|
+
|
|
6
|
+
## Core Features
|
|
7
|
+
|
|
8
|
+
### Connection
|
|
9
|
+
```typescript
|
|
10
|
+
// Using memcached (Node.js)
|
|
11
|
+
import Memcached from 'memcached'
|
|
12
|
+
|
|
13
|
+
const memcached = new Memcached(process.env.MEMCACHED_SERVERS || 'localhost:11211', {
|
|
14
|
+
maxKeySize: 250,
|
|
15
|
+
maxExpiration: 2592000, // 30 days
|
|
16
|
+
maxValue: 1048576, // 1MB
|
|
17
|
+
poolSize: 10,
|
|
18
|
+
reconnect: true,
|
|
19
|
+
timeout: 5000,
|
|
20
|
+
retries: 3,
|
|
21
|
+
retry: 1000,
|
|
22
|
+
remove: true,
|
|
23
|
+
idle: 5000,
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Basic Operations
|
|
28
|
+
```typescript
|
|
29
|
+
// Set
|
|
30
|
+
memcached.set('user:1', { name: 'John', email: 'john@example.com' }, 3600, (err) => {
|
|
31
|
+
// Expires in 1 hour
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Get
|
|
35
|
+
memcached.get('user:1', (err, data) => {
|
|
36
|
+
console.log(data)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// Delete
|
|
40
|
+
memcached.del('user:1', (err) => {
|
|
41
|
+
// Deleted
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// Replace (only if key exists)
|
|
45
|
+
memcached.replace('user:1', newData, 3600, (err) => {
|
|
46
|
+
// Replaced
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// Add (only if key doesn't exist)
|
|
50
|
+
memcached.add('user:1', data, 3600, (err) => {
|
|
51
|
+
// Added
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Advanced Operations
|
|
56
|
+
```typescript
|
|
57
|
+
// Multiple gets
|
|
58
|
+
memcached.getMulti(['user:1', 'user:2', 'user:3'], (err, data) => {
|
|
59
|
+
// Returns object with keys as properties
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// Increment/Decrement
|
|
63
|
+
memcached.incr('counter', 1, (err, value) => {
|
|
64
|
+
// Incremented
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
memcached.decr('counter', 1, (err, value) => {
|
|
68
|
+
// Decremented
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// Touch (update expiration)
|
|
72
|
+
memcached.touch('user:1', 7200, (err) => {
|
|
73
|
+
// Expiration updated to 2 hours
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
// Stats
|
|
77
|
+
memcached.stats((err, stats) => {
|
|
78
|
+
console.log(stats)
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Common Patterns
|
|
83
|
+
|
|
84
|
+
### Caching with Promises
|
|
85
|
+
```typescript
|
|
86
|
+
function getCached(key: string): Promise<any> {
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
memcached.get(key, (err, data) => {
|
|
89
|
+
if (err) reject(err)
|
|
90
|
+
else resolve(data)
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function setCached(key: string, value: any, ttl: number): Promise<void> {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
memcached.set(key, value, ttl, (err) => {
|
|
98
|
+
if (err) reject(err)
|
|
99
|
+
else resolve()
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Usage
|
|
105
|
+
async function getCachedUser(userId: string) {
|
|
106
|
+
const cached = await getCached(`user:${userId}`)
|
|
107
|
+
if (cached) {
|
|
108
|
+
return cached
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const user = await fetchUserFromDatabase(userId)
|
|
112
|
+
await setCached(`user:${userId}`, user, 3600)
|
|
113
|
+
return user
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Cache-Aside Pattern
|
|
118
|
+
```typescript
|
|
119
|
+
async function getWithCache(key: string, fetchFn: () => Promise<any>, ttl: number) {
|
|
120
|
+
try {
|
|
121
|
+
const cached = await getCached(key)
|
|
122
|
+
if (cached) {
|
|
123
|
+
return cached
|
|
124
|
+
}
|
|
125
|
+
} catch (err) {
|
|
126
|
+
// Cache miss or error, continue to fetch
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const data = await fetchFn()
|
|
130
|
+
try {
|
|
131
|
+
await setCached(key, data, ttl)
|
|
132
|
+
} catch (err) {
|
|
133
|
+
// Cache set failed, but we have the data
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return data
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Rate Limiting
|
|
141
|
+
```typescript
|
|
142
|
+
async function checkRateLimit(identifier: string, limit: number, window: number): Promise<boolean> {
|
|
143
|
+
const key = `ratelimit:${identifier}`
|
|
144
|
+
|
|
145
|
+
return new Promise((resolve) => {
|
|
146
|
+
memcached.incr(key, 1, (err, value) => {
|
|
147
|
+
if (err || value === false) {
|
|
148
|
+
// Key doesn't exist, create it
|
|
149
|
+
memcached.set(key, 1, window, () => {
|
|
150
|
+
resolve(true)
|
|
151
|
+
})
|
|
152
|
+
} else if (value > limit) {
|
|
153
|
+
resolve(false)
|
|
154
|
+
} else {
|
|
155
|
+
if (value === 1) {
|
|
156
|
+
// First increment, set expiration
|
|
157
|
+
memcached.touch(key, window, () => {})
|
|
158
|
+
}
|
|
159
|
+
resolve(true)
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Best Practices
|
|
167
|
+
|
|
168
|
+
✅ **DO:**
|
|
169
|
+
- Use connection pooling
|
|
170
|
+
- Set appropriate TTL for cached data
|
|
171
|
+
- Handle cache misses gracefully
|
|
172
|
+
- Use consistent key naming conventions
|
|
173
|
+
- Monitor cache hit rates
|
|
174
|
+
- Use multiple servers for redundancy
|
|
175
|
+
- Compress large values before storing
|
|
176
|
+
- Implement cache warming strategies
|
|
177
|
+
- Use appropriate data serialization
|
|
178
|
+
- Monitor memory usage
|
|
179
|
+
|
|
180
|
+
❌ **DON'T:**
|
|
181
|
+
- Store large values (> 1MB, use external storage)
|
|
182
|
+
- Use Memcached as primary database
|
|
183
|
+
- Store sensitive data without encryption
|
|
184
|
+
- Skip error handling
|
|
185
|
+
- Ignore connection failures
|
|
186
|
+
- Hardcode server addresses
|
|
187
|
+
- Use blocking operations
|
|
188
|
+
- Store complex nested objects (flatten when possible)
|
|
189
|
+
- Ignore eviction policies
|
|
190
|
+
- Skip monitoring
|
|
191
|
+
|
|
192
|
+
## Configuration
|
|
193
|
+
|
|
194
|
+
### Environment Variables
|
|
195
|
+
```bash
|
|
196
|
+
MEMCACHED_SERVERS=localhost:11211
|
|
197
|
+
MEMCACHED_SERVERS=server1:11211,server2:11211,server3:11211
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Docker Compose
|
|
201
|
+
```yaml
|
|
202
|
+
services:
|
|
203
|
+
memcached:
|
|
204
|
+
image: memcached:1.6-alpine
|
|
205
|
+
ports:
|
|
206
|
+
- "11211:11211"
|
|
207
|
+
command: ["-m", "64", "-I", "1m"] # 64MB memory, 1MB max item size
|
|
208
|
+
healthcheck:
|
|
209
|
+
test: ["CMD", "nc", "-z", "localhost", "11211"]
|
|
210
|
+
interval: 10s
|
|
211
|
+
timeout: 5s
|
|
212
|
+
retries: 5
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Integration with Development
|
|
216
|
+
|
|
217
|
+
### Testing
|
|
218
|
+
```typescript
|
|
219
|
+
// Use test Memcached instance
|
|
220
|
+
const testMemcached = new Memcached('localhost:11212') // Different port
|
|
221
|
+
|
|
222
|
+
// Clean up after tests
|
|
223
|
+
afterEach((done) => {
|
|
224
|
+
testMemcached.flush((err) => {
|
|
225
|
+
done()
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Health Checks
|
|
231
|
+
```typescript
|
|
232
|
+
function checkMemcachedHealth(): Promise<boolean> {
|
|
233
|
+
return new Promise((resolve) => {
|
|
234
|
+
memcached.stats((err) => {
|
|
235
|
+
resolve(!err)
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
<!-- MEMCACHED:END -->
|
|
242
|
+
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
<!-- MINIO:START -->
|
|
2
|
+
# MinIO S3-Compatible Storage Instructions
|
|
3
|
+
|
|
4
|
+
**CRITICAL**: Use MinIO for S3-compatible object storage, self-hosted file storage, and development/testing with S3 APIs.
|
|
5
|
+
|
|
6
|
+
## Core Features
|
|
7
|
+
|
|
8
|
+
### Connection
|
|
9
|
+
```typescript
|
|
10
|
+
// Using @aws-sdk/client-s3 (S3-compatible)
|
|
11
|
+
import { S3Client, PutObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3'
|
|
12
|
+
|
|
13
|
+
const s3Client = new S3Client({
|
|
14
|
+
endpoint: process.env.MINIO_ENDPOINT || 'http://localhost:9000',
|
|
15
|
+
region: process.env.MINIO_REGION || 'us-east-1',
|
|
16
|
+
credentials: {
|
|
17
|
+
accessKeyId: process.env.MINIO_ACCESS_KEY || 'minioadmin',
|
|
18
|
+
secretAccessKey: process.env.MINIO_SECRET_KEY || 'minioadmin',
|
|
19
|
+
},
|
|
20
|
+
forcePathStyle: true, // Required for MinIO
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// Using minio-js
|
|
24
|
+
import * as MinIO from 'minio'
|
|
25
|
+
|
|
26
|
+
const minioClient = new MinIO.Client({
|
|
27
|
+
endPoint: process.env.MINIO_ENDPOINT?.replace('http://', '').replace('https://', '') || 'localhost',
|
|
28
|
+
port: parseInt(process.env.MINIO_PORT || '9000'),
|
|
29
|
+
useSSL: process.env.MINIO_USE_SSL === 'true',
|
|
30
|
+
accessKey: process.env.MINIO_ACCESS_KEY || 'minioadmin',
|
|
31
|
+
secretKey: process.env.MINIO_SECRET_KEY || 'minioadmin',
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Basic Operations
|
|
36
|
+
```typescript
|
|
37
|
+
// Using S3 SDK
|
|
38
|
+
// Create bucket
|
|
39
|
+
await s3Client.send(new CreateBucketCommand({
|
|
40
|
+
Bucket: 'my-bucket',
|
|
41
|
+
}))
|
|
42
|
+
|
|
43
|
+
// Upload file
|
|
44
|
+
await s3Client.send(new PutObjectCommand({
|
|
45
|
+
Bucket: 'my-bucket',
|
|
46
|
+
Key: 'path/to/file.jpg',
|
|
47
|
+
Body: fileBuffer,
|
|
48
|
+
ContentType: 'image/jpeg',
|
|
49
|
+
}))
|
|
50
|
+
|
|
51
|
+
// Download file
|
|
52
|
+
const response = await s3Client.send(new GetObjectCommand({
|
|
53
|
+
Bucket: 'my-bucket',
|
|
54
|
+
Key: 'path/to/file.jpg',
|
|
55
|
+
}))
|
|
56
|
+
const fileContent = await response.Body?.transformToByteArray()
|
|
57
|
+
|
|
58
|
+
// Using MinIO SDK
|
|
59
|
+
// Upload file
|
|
60
|
+
await minioClient.putObject('my-bucket', 'path/to/file.jpg', fileBuffer, fileBuffer.length, {
|
|
61
|
+
'Content-Type': 'image/jpeg',
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
// Download file
|
|
65
|
+
const dataStream = await minioClient.getObject('my-bucket', 'path/to/file.jpg')
|
|
66
|
+
const chunks: Buffer[] = []
|
|
67
|
+
for await (const chunk of dataStream) {
|
|
68
|
+
chunks.push(chunk)
|
|
69
|
+
}
|
|
70
|
+
const fileContent = Buffer.concat(chunks)
|
|
71
|
+
|
|
72
|
+
// List objects
|
|
73
|
+
const objectsStream = minioClient.listObjects('my-bucket', 'prefix/', true)
|
|
74
|
+
for await (const obj of objectsStream) {
|
|
75
|
+
console.log(obj.name, obj.size)
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Advanced Features
|
|
80
|
+
```typescript
|
|
81
|
+
// Presigned URL (S3 SDK)
|
|
82
|
+
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
|
|
83
|
+
|
|
84
|
+
const command = new PutObjectCommand({
|
|
85
|
+
Bucket: 'my-bucket',
|
|
86
|
+
Key: 'uploads/file.jpg',
|
|
87
|
+
ContentType: 'image/jpeg',
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const presignedUrl = await getSignedUrl(s3Client, command, { expiresIn: 3600 })
|
|
91
|
+
|
|
92
|
+
// Presigned URL (MinIO SDK)
|
|
93
|
+
const url = await minioClient.presignedPutObject('my-bucket', 'uploads/file.jpg', 3600)
|
|
94
|
+
|
|
95
|
+
// Bucket policies
|
|
96
|
+
const policy = {
|
|
97
|
+
Version: '2012-10-17',
|
|
98
|
+
Statement: [
|
|
99
|
+
{
|
|
100
|
+
Effect: 'Allow',
|
|
101
|
+
Principal: { AWS: ['*'] },
|
|
102
|
+
Action: ['s3:GetObject'],
|
|
103
|
+
Resource: ['arn:aws:s3:::my-bucket/*'],
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
await minioClient.setBucketPolicy('my-bucket', JSON.stringify(policy))
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Common Patterns
|
|
112
|
+
|
|
113
|
+
### File Upload Handler
|
|
114
|
+
```typescript
|
|
115
|
+
async function uploadFile(file: Buffer, filename: string, userId: string) {
|
|
116
|
+
const key = `users/${userId}/${Date.now()}-${filename}`
|
|
117
|
+
|
|
118
|
+
await s3Client.send(new PutObjectCommand({
|
|
119
|
+
Bucket: process.env.MINIO_BUCKET,
|
|
120
|
+
Key: key,
|
|
121
|
+
Body: file,
|
|
122
|
+
ContentType: getContentType(filename),
|
|
123
|
+
Metadata: {
|
|
124
|
+
userId,
|
|
125
|
+
originalName: filename,
|
|
126
|
+
},
|
|
127
|
+
}))
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
key,
|
|
131
|
+
url: `${process.env.MINIO_ENDPOINT}/${process.env.MINIO_BUCKET}/${key}`,
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Best Practices
|
|
137
|
+
|
|
138
|
+
✅ **DO:**
|
|
139
|
+
- Use S3-compatible APIs for portability
|
|
140
|
+
- Set appropriate content types
|
|
141
|
+
- Use presigned URLs for client uploads
|
|
142
|
+
- Implement proper error handling
|
|
143
|
+
- Use bucket policies for access control
|
|
144
|
+
- Enable versioning for important data
|
|
145
|
+
- Monitor storage usage
|
|
146
|
+
- Use lifecycle policies
|
|
147
|
+
- Implement retry logic
|
|
148
|
+
- Use TLS in production
|
|
149
|
+
|
|
150
|
+
❌ **DON'T:**
|
|
151
|
+
- Store sensitive data without encryption
|
|
152
|
+
- Use default credentials in production
|
|
153
|
+
- Hardcode endpoint URLs
|
|
154
|
+
- Ignore error handling
|
|
155
|
+
- Skip content-type validation
|
|
156
|
+
- Ignore access policies
|
|
157
|
+
- Skip monitoring
|
|
158
|
+
- Use HTTP in production
|
|
159
|
+
- Ignore storage limits
|
|
160
|
+
- Store large files without chunking
|
|
161
|
+
|
|
162
|
+
## Configuration
|
|
163
|
+
|
|
164
|
+
### Environment Variables
|
|
165
|
+
```bash
|
|
166
|
+
MINIO_ENDPOINT=http://localhost:9000
|
|
167
|
+
MINIO_ENDPOINT=https://minio.example.com
|
|
168
|
+
MINIO_PORT=9000
|
|
169
|
+
MINIO_USE_SSL=false
|
|
170
|
+
MINIO_ACCESS_KEY=minioadmin
|
|
171
|
+
MINIO_SECRET_KEY=minioadmin
|
|
172
|
+
MINIO_BUCKET=my-bucket
|
|
173
|
+
MINIO_REGION=us-east-1
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Docker Compose
|
|
177
|
+
```yaml
|
|
178
|
+
services:
|
|
179
|
+
minio:
|
|
180
|
+
image: minio/minio:latest
|
|
181
|
+
ports:
|
|
182
|
+
- "9000:9000" # API
|
|
183
|
+
- "9001:9001" # Console
|
|
184
|
+
environment:
|
|
185
|
+
MINIO_ROOT_USER: minioadmin
|
|
186
|
+
MINIO_ROOT_PASSWORD: securepassword
|
|
187
|
+
command: server /data --console-address ":9001"
|
|
188
|
+
volumes:
|
|
189
|
+
- minio_data:/data
|
|
190
|
+
healthcheck:
|
|
191
|
+
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
|
192
|
+
interval: 30s
|
|
193
|
+
timeout: 20s
|
|
194
|
+
retries: 3
|
|
195
|
+
|
|
196
|
+
volumes:
|
|
197
|
+
minio_data:
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
<!-- MINIO:END -->
|
|
201
|
+
|