postgrebase-installer 0.0.3
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 +87 -0
- package/bin/postgrebase +124 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# PostgreBase
|
|
2
|
+
|
|
3
|
+
🚀 AI原生的无代码API开发平台 — 支持 PostgreSQL、MySQL、SQLite
|
|
4
|
+
|
|
5
|
+
AI-Native No-Code API Platform with built-in MCP server, supporting PostgreSQL, MySQL, and SQLite.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g postgrebase-installer
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# SQLite (local development)
|
|
17
|
+
postgrebase serve --dataDsn "sqlite://./data.db"
|
|
18
|
+
|
|
19
|
+
# PostgreSQL (production)
|
|
20
|
+
postgrebase serve --dataDsn "postgres://user:pass@localhost:5432/db?sslmode=disable"
|
|
21
|
+
|
|
22
|
+
# MySQL
|
|
23
|
+
postgrebase serve --dataDsn "mysql://user:pass@tcp(localhost:3306)/db"
|
|
24
|
+
|
|
25
|
+
# With Redis cache
|
|
26
|
+
postgrebase serve --dataDsn "postgres://..." --redisDsn "redis://localhost:6379/0"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- 🗄️ **Multi-Database**: PostgreSQL, MySQL, SQLite support
|
|
32
|
+
- 🤖 **MCP Server**: Built-in Model Context Protocol server for AI tools
|
|
33
|
+
- ⚡ **REST API**: Instant RESTful API for your collections
|
|
34
|
+
- 🔄 **Realtime**: Server-Sent Events (SSE) subscriptions
|
|
35
|
+
- 🎛️ **Admin UI**: Built-in admin dashboard
|
|
36
|
+
- 🔐 **Auth**: Built-in authentication with JWT tokens
|
|
37
|
+
- 📁 **File Storage**: Local and S3-compatible storage
|
|
38
|
+
- 🚀 **High Performance**: Designed for clustered environments
|
|
39
|
+
|
|
40
|
+
## MCP (Model Context Protocol)
|
|
41
|
+
|
|
42
|
+
PostgreBase includes a built-in MCP server for AI tools like Claude Desktop, Cursor, and Windsurf:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Start MCP server (stdio mode)
|
|
46
|
+
postgrebase mcp --dataDsn "sqlite://./dev.db" --mcp-no-auth
|
|
47
|
+
|
|
48
|
+
# With authentication
|
|
49
|
+
postgrebase mcp --dataDsn "postgres://..." --mcp-token "YOUR_TOKEN"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Claude Desktop Configuration
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"postgrebase": {
|
|
58
|
+
"command": "postgrebase",
|
|
59
|
+
"args": ["mcp", "--dataDsn", "sqlite:///path/to/dev.db", "--mcp-no-auth"]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Configuration
|
|
66
|
+
|
|
67
|
+
| Flag | Description | Example |
|
|
68
|
+
|------|-------------|---------|
|
|
69
|
+
| `--dataDsn` | Database connection string | `postgres://user:pass@host:5432/db` |
|
|
70
|
+
| `--redisDsn` | Redis connection string (optional) | `redis://localhost:6379/0` |
|
|
71
|
+
| `--dir` | Data directory for file uploads | `./pb_data` |
|
|
72
|
+
| `--debug` | Enable debug mode | _(flag)_ |
|
|
73
|
+
|
|
74
|
+
## More Information
|
|
75
|
+
|
|
76
|
+
- **GitHub**: [github.com/zhenruyan/postgrebase](https://github.com/zhenruyan/postgrebase)
|
|
77
|
+
- **Documentation**: [README](https://github.com/zhenruyan/postgrebase/blob/main/README.md)
|
|
78
|
+
|
|
79
|
+
## Uninstall
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm uninstall -g postgrebase-installer
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT — Based on [PocketBase](https://pocketbase.io) by [Gani Georgiev](https://github.com/ganigeorgiev)
|
package/bin/postgrebase
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Wrapper script that resolves and executes the platform-specific binary.
|
|
4
|
+
// When installed via `npm i -g postgrebase-installer`, this script finds the
|
|
5
|
+
// correct binary from the platform-specific optional dependency package.
|
|
6
|
+
|
|
7
|
+
const { execFileSync } = require('child_process');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
|
|
11
|
+
// Map npm os/cpu to package name
|
|
12
|
+
const PLATFORM_MAP = {
|
|
13
|
+
'linux-x64-glibc': 'postgrebase-installer-linux-x64',
|
|
14
|
+
'linux-arm64-glibc': 'postgrebase-installer-linux-arm64',
|
|
15
|
+
'linux-x64-musl': 'postgrebase-installer-linux-musl-x64',
|
|
16
|
+
'darwin-x64': 'postgrebase-installer-darwin-x64',
|
|
17
|
+
'darwin-arm64': 'postgrebase-installer-darwin-arm64',
|
|
18
|
+
'win32-x64': 'postgrebase-installer-win32-x64',
|
|
19
|
+
'win32-arm64': 'postgrebase-installer-win32-arm64',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function detectPlatform() {
|
|
23
|
+
const os = process.platform; // 'linux', 'darwin', 'win32'
|
|
24
|
+
const arch = process.arch; // 'x64', 'arm64'
|
|
25
|
+
|
|
26
|
+
if (os === 'linux') {
|
|
27
|
+
// Detect libc: musl or glibc
|
|
28
|
+
const isMusl = (() => {
|
|
29
|
+
try {
|
|
30
|
+
// Check for Alpine's musl
|
|
31
|
+
if (fs.existsSync('/etc/alpine-release')) return true;
|
|
32
|
+
// Check ldd output for musl
|
|
33
|
+
const { execSync } = require('child_process');
|
|
34
|
+
const output = execSync('ldd --version 2>&1 || true', { encoding: 'utf8' });
|
|
35
|
+
return output.includes('musl');
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
})();
|
|
40
|
+
|
|
41
|
+
return `${os}-${arch}-${isMusl ? 'musl' : 'glibc'}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return `${os}-${arch}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function findBinary() {
|
|
48
|
+
const platform = detectPlatform();
|
|
49
|
+
const packageName = PLATFORM_MAP[platform];
|
|
50
|
+
|
|
51
|
+
if (!packageName) {
|
|
52
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
53
|
+
console.error(`Supported platforms: ${Object.keys(PLATFORM_MAP).join(', ')}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const searchDirs = [];
|
|
58
|
+
const addSearchDir = (dir) => {
|
|
59
|
+
if (dir && !searchDirs.includes(dir)) {
|
|
60
|
+
searchDirs.push(dir);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
addSearchDir(path.dirname(require.resolve(`${packageName}/package.json`)));
|
|
66
|
+
} catch {
|
|
67
|
+
// Keep explicit fallbacks below for unusual npm layouts.
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// npm usually installs dependencies under this package. Some global installs
|
|
71
|
+
// or package managers may hoist them as siblings, so check both layouts.
|
|
72
|
+
addSearchDir(path.join(__dirname, '..', 'node_modules', packageName));
|
|
73
|
+
addSearchDir(path.join(__dirname, '..', '..', packageName));
|
|
74
|
+
|
|
75
|
+
for (const pkgDir of searchDirs) {
|
|
76
|
+
const binName = process.platform === 'win32' ? 'postgrebase.exe' : 'postgrebase';
|
|
77
|
+
const binPath = path.join(pkgDir, 'bin', binName);
|
|
78
|
+
|
|
79
|
+
if (fs.existsSync(binPath)) {
|
|
80
|
+
return binPath;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Fallback: check if there's a binary directly in the main package's bin/
|
|
85
|
+
const fallbackBinName = (() => {
|
|
86
|
+
const suffix = process.platform === 'win32' ? '.exe' : '';
|
|
87
|
+
const osMap = { linux: 'linux', darwin: 'darwin', win32: 'windows' };
|
|
88
|
+
const archMap = { x64: 'amd64', arm64: 'arm64' };
|
|
89
|
+
return `postgrebase-${osMap[process.platform]}-${archMap[process.arch]}${suffix}`;
|
|
90
|
+
})();
|
|
91
|
+
|
|
92
|
+
const fallbackPath = path.join(__dirname, fallbackBinName);
|
|
93
|
+
if (fs.existsSync(fallbackPath)) {
|
|
94
|
+
return fallbackPath;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
console.error(`Could not find PostgreBase binary for platform: ${detectPlatform()}`);
|
|
98
|
+
console.error(`Searched for package: ${packageName}`);
|
|
99
|
+
console.error(`Searched in: ${searchDirs.join(', ')}`);
|
|
100
|
+
console.error('');
|
|
101
|
+
console.error('If you installed globally, try reinstalling:');
|
|
102
|
+
console.error(' npm install -g postgrebase-installer');
|
|
103
|
+
console.error('');
|
|
104
|
+
console.error('If the problem persists, install via go install instead:');
|
|
105
|
+
console.error(' go install github.com/zhenruyan/postgrebase/build@latest');
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Main
|
|
110
|
+
const binaryPath = findBinary();
|
|
111
|
+
const args = process.argv.slice(2);
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
execFileSync(binaryPath, args, { stdio: 'inherit' });
|
|
115
|
+
} catch (err) {
|
|
116
|
+
// Forward the exit code
|
|
117
|
+
if (err.status !== undefined) {
|
|
118
|
+
process.exit(err.status);
|
|
119
|
+
}
|
|
120
|
+
if (err.code) {
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "postgrebase-installer",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "AI-Native No-Code API Platform with PostgreSQL/MySQL/SQLite support",
|
|
5
|
+
"bin": {
|
|
6
|
+
"postgrebase": "bin/postgrebase"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"api",
|
|
14
|
+
"backend",
|
|
15
|
+
"postgresql",
|
|
16
|
+
"mysql",
|
|
17
|
+
"sqlite",
|
|
18
|
+
"rest-api",
|
|
19
|
+
"mcp",
|
|
20
|
+
"ai",
|
|
21
|
+
"no-code",
|
|
22
|
+
"pocketbase"
|
|
23
|
+
],
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/zhenruyan/postgrebase.git",
|
|
29
|
+
"directory": "npm"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=14"
|
|
33
|
+
},
|
|
34
|
+
"optionalDependencies": {
|
|
35
|
+
"postgrebase-installer-linux-x64": "0.0.3",
|
|
36
|
+
"postgrebase-installer-linux-arm64": "0.0.3",
|
|
37
|
+
"postgrebase-installer-linux-musl-x64": "0.0.3",
|
|
38
|
+
"postgrebase-installer-darwin-x64": "0.0.3",
|
|
39
|
+
"postgrebase-installer-darwin-arm64": "0.0.3",
|
|
40
|
+
"postgrebase-installer-win32-x64": "0.0.3",
|
|
41
|
+
"postgrebase-installer-win32-arm64": "0.0.3"
|
|
42
|
+
}
|
|
43
|
+
}
|