axiodb 16.2.1 β 18.1.2
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 +25 -10
- package/cli/VERSION +1 -1
- package/cli/cmd/db_export.go +66 -0
- package/cli/cmd/db_import.go +84 -0
- package/cli/cmd/root.go +2 -0
- package/cli/internal/config/config.go +9 -0
- package/cli/pkg/httpclient/client.go +160 -0
- package/lib/Services/Indexation.operation.d.ts +3 -0
- package/lib/Services/Indexation.operation.js +32 -21
- package/lib/Services/Indexation.operation.js.map +1 -1
- package/lib/config/Interfaces/Operation/Indexation.operation.interface.d.ts +2 -0
- package/lib/server/config/server.d.ts +1 -1
- package/lib/server/config/server.js +22 -15
- package/lib/server/config/server.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,6 +134,7 @@ console.log(result.data.documents[0].message); // Hello, Developer! π
|
|
|
134
134
|
| Option | Type | Default | Description |
|
|
135
135
|
| --- | --- | --- | --- |
|
|
136
136
|
| `GUI` | `boolean` | `false` | Enable the web-based GUI dashboard at `localhost:27018` |
|
|
137
|
+
| `HTTP` | `boolean` | mirrors `GUI` | Enable the HTTP API server on port 27018 β auto-enables when GUI is on; `GUI: true` + `HTTP: false` throws an error |
|
|
137
138
|
| `RootName` | `string` | `"AxioDB"` | Name of the root folder database files are stored under |
|
|
138
139
|
| `CustomPath` | `string` | current working directory | Custom filesystem path for database storage |
|
|
139
140
|
| `TCP` | `boolean` | `false` | Enable the AxioDBCloud TCP server on port 27019 |
|
|
@@ -341,7 +342,7 @@ The rule: the `-e AXIODB_TLS_CERT_PATH=...` value must always match the *right-h
|
|
|
341
342
|
|
|
342
343
|
## π» AxioDB CLI β Command Line Interface
|
|
343
344
|
|
|
344
|
-
A Go-based CLI tool for interacting with AxioDB servers via the TCP protocol. Supports all database operations with both single-command and interactive REPL modes.
|
|
345
|
+
A Go-based CLI tool for interacting with AxioDB servers via the TCP protocol. Supports all database operations with both single-command and interactive REPL modes. Export and import databases via the HTTP API.
|
|
345
346
|
|
|
346
347
|
### Quick Install
|
|
347
348
|
|
|
@@ -399,14 +400,27 @@ axiodb -c axiodb://127.0.0.1:27019 -u admin -p admin connect
|
|
|
399
400
|
axiodb -c axiodb://127.0.0.1:27019 --tls --tls-cert ./cert.pem connect
|
|
400
401
|
```
|
|
401
402
|
|
|
403
|
+
**Export database (via HTTP API):**
|
|
404
|
+
```bash
|
|
405
|
+
axiodb export mydb --http-host localhost --http-port 27018 -u admin -p secret
|
|
406
|
+
# Saves mydb.tar.gz in current directory
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Import database (via HTTP API):**
|
|
410
|
+
```bash
|
|
411
|
+
axiodb import ./backups/mydb.tar.gz --http-host localhost --http-port 27018 -u admin -p secret
|
|
412
|
+
# Tab completes .tar.gz file paths
|
|
413
|
+
```
|
|
414
|
+
|
|
402
415
|
### Features
|
|
403
416
|
|
|
404
|
-
- **All
|
|
417
|
+
- **All 23 commands:** database, collection, document CRUD, aggregation, indexing, export, import
|
|
405
418
|
- **Interactive REPL:** MongoDB shell syntax (`use`, `show dbs`, `db.coll.find()`)
|
|
419
|
+
- **Export & Import:** backup/restore databases via HTTP API, tab-completes file paths
|
|
406
420
|
- **TLS support:** `--tls`, `--tls-cert`, `--tls-skip-verify`
|
|
407
|
-
- **Auth support:** `-u` / `-p` flags
|
|
421
|
+
- **Auth support:** `-u` / `-p` flags (TCP and HTTP)
|
|
408
422
|
- **JSON output:** `--output json` for scripting
|
|
409
|
-
- **Tab autocomplete** in REPL mode
|
|
423
|
+
- **Tab autocomplete** in REPL mode and file path completion
|
|
410
424
|
|
|
411
425
|
π **[Full CLI Documentation](https://github.com/nexoral/AxioDB/tree/main/cli)**
|
|
412
426
|
|
|
@@ -529,7 +543,7 @@ docker run -d \
|
|
|
529
543
|
--name axiodb-server \
|
|
530
544
|
-p 27018:27018 \
|
|
531
545
|
-p 27019:27019 \
|
|
532
|
-
-e
|
|
546
|
+
-e AXIODB_TCP_AUTH_ENABLED=true \
|
|
533
547
|
-v axiodb-data:/app \
|
|
534
548
|
theankansaha/axiodb
|
|
535
549
|
|
|
@@ -548,8 +562,9 @@ Every option below has a default matching the image's previous fixed behavior
|
|
|
548
562
|
| Variable | Default | Description |
|
|
549
563
|
| --- | --- | --- |
|
|
550
564
|
| `AXIODB_GUI` | `true` | Enable the HTTP Control Server / web GUI on port 27018 |
|
|
565
|
+
| `AXIODB_HTTP` | mirrors `AXIODB_GUI` | Enable the HTTP API server on port 27018 β auto-enables when GUI is on; `AXIODB_GUI=true` + `AXIODB_HTTP=false` is an error |
|
|
551
566
|
| `AXIODB_TCP` | `true` | Enable the AxioDBCloud TCP server on port 27019 |
|
|
552
|
-
| `
|
|
567
|
+
| `AXIODB_TCP_AUTH_ENABLED` | `true` | Require username/password authentication on TCP connections (same RBAC accounts as the GUI) |
|
|
553
568
|
| `AXIODB_TLS` | `false` | Encrypt TCP connections with TLS instead of plaintext (see [Advanced: TLS encryption](#advanced-tls-encryption)) |
|
|
554
569
|
| `AXIODB_TLS_CERT_PATH` | *(none)* | Path **inside the container** to a PEM cert file - required when `AXIODB_TLS=true`. Mount the real file in with `-v` first (see the TLS section above) |
|
|
555
570
|
| `AXIODB_TLS_KEY_PATH` | *(none)* | Path **inside the container** to the matching PEM private key - required when `AXIODB_TLS=true` |
|
|
@@ -566,7 +581,7 @@ docker run -d \
|
|
|
566
581
|
--name axiodb-server \
|
|
567
582
|
-p 27018:27018 \
|
|
568
583
|
-p 27019:27019 \
|
|
569
|
-
-e
|
|
584
|
+
-e AXIODB_TCP_AUTH_ENABLED=false \
|
|
570
585
|
-v axiodb-data:/app \
|
|
571
586
|
theankansaha/axiodb
|
|
572
587
|
```
|
|
@@ -585,7 +600,7 @@ services:
|
|
|
585
600
|
environment:
|
|
586
601
|
- AXIODB_GUI=true
|
|
587
602
|
- AXIODB_TCP=true
|
|
588
|
-
-
|
|
603
|
+
- AXIODB_TCP_AUTH_ENABLED=true
|
|
589
604
|
- AXIODB_ROOT_NAME=AxioDB
|
|
590
605
|
volumes:
|
|
591
606
|
- axiodb-data:/app
|
|
@@ -609,7 +624,7 @@ services:
|
|
|
609
624
|
environment:
|
|
610
625
|
- AXIODB_GUI=true
|
|
611
626
|
- AXIODB_TCP=true
|
|
612
|
-
-
|
|
627
|
+
- AXIODB_TCP_AUTH_ENABLED=true
|
|
613
628
|
- AXIODB_TLS=true
|
|
614
629
|
- AXIODB_TLS_CERT_PATH=/certs/cert.pem
|
|
615
630
|
- AXIODB_TLS_KEY_PATH=/certs/key.pem
|
|
@@ -665,7 +680,7 @@ that logged-in user's actual role, exactly like the HTTP Control Server. A View-
|
|
|
665
680
|
gets a real `403` on write tools; nothing is gated by a static container environment variable.
|
|
666
681
|
|
|
667
682
|
`AXIODB_MCP=true` only has RBAC to serve once it's actually seeded, which requires
|
|
668
|
-
`AXIODB_GUI=true` (the default) or `AXIODB_TCP=true` + `
|
|
683
|
+
`AXIODB_GUI=true` (the default) or `AXIODB_TCP=true` + `AXIODB_TCP_AUTH_ENABLED=true`.
|
|
669
684
|
|
|
670
685
|
Full tool catalogue, examples, and security notes: **[MCP Server docs](https://axiodb.in/mcp-server)**.
|
|
671
686
|
|
package/cli/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
18.1.2
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package cmd
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"os"
|
|
6
|
+
|
|
7
|
+
"github.com/nexoral/axiodb-cli/internal/config"
|
|
8
|
+
"github.com/spf13/cobra"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
var exportCmd = &cobra.Command{
|
|
12
|
+
Use: "export <dbname>",
|
|
13
|
+
Short: "Export a database to a .tar.gz file via HTTP",
|
|
14
|
+
Long: "Export an AxioDB database to a .tar.gz archive. Uses the HTTP API (port 27018), not TCP.",
|
|
15
|
+
Args: cobra.ExactArgs(1),
|
|
16
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
17
|
+
dbName := args[0]
|
|
18
|
+
cfg, err := config.FromFlags(cmd)
|
|
19
|
+
if err != nil {
|
|
20
|
+
return err
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if cfg.Username == "" || cfg.Password == "" {
|
|
24
|
+
return fmt.Errorf("username and password required for HTTP auth (-u, -p)")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
client := cfg.NewHTTPClient()
|
|
28
|
+
|
|
29
|
+
fmt.Fprintf(os.Stderr, "Logging in to %s:%d...\n", cfg.HTTPHost, cfg.HTTPPort)
|
|
30
|
+
if err := client.Login(cfg.Username, cfg.Password); err != nil {
|
|
31
|
+
return err
|
|
32
|
+
}
|
|
33
|
+
defer client.Logout()
|
|
34
|
+
|
|
35
|
+
fmt.Fprintf(os.Stderr, "Exporting %s...\n", dbName)
|
|
36
|
+
filename, size, err := client.Export(dbName)
|
|
37
|
+
if err != nil {
|
|
38
|
+
return err
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fmt.Fprintf(os.Stderr, "Exported %s (%s)\n", filename, formatBytes(size))
|
|
42
|
+
return nil
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func formatBytes(bytes int64) string {
|
|
47
|
+
const (
|
|
48
|
+
KB = 1024
|
|
49
|
+
MB = 1024 * KB
|
|
50
|
+
GB = 1024 * MB
|
|
51
|
+
)
|
|
52
|
+
switch {
|
|
53
|
+
case bytes >= GB:
|
|
54
|
+
return fmt.Sprintf("%.1f GB", float64(bytes)/float64(GB))
|
|
55
|
+
case bytes >= MB:
|
|
56
|
+
return fmt.Sprintf("%.1f MB", float64(bytes)/float64(MB))
|
|
57
|
+
case bytes >= KB:
|
|
58
|
+
return fmt.Sprintf("%.1f KB", float64(bytes)/float64(KB))
|
|
59
|
+
default:
|
|
60
|
+
return fmt.Sprintf("%d B", bytes)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
func init() {
|
|
65
|
+
rootCmd.AddCommand(exportCmd)
|
|
66
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
package cmd
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"strings"
|
|
8
|
+
|
|
9
|
+
"github.com/nexoral/axiodb-cli/internal/config"
|
|
10
|
+
"github.com/spf13/cobra"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
var importCmd = &cobra.Command{
|
|
14
|
+
Use: "import <file>",
|
|
15
|
+
Short: "Import a database from a .tar.gz file via HTTP",
|
|
16
|
+
Long: "Import an AxioDB database from a .tar.gz archive. Uses the HTTP API (port 27018), not TCP.",
|
|
17
|
+
Args: cobra.ExactArgs(1),
|
|
18
|
+
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
19
|
+
dir := "."
|
|
20
|
+
prefix := toComplete
|
|
21
|
+
|
|
22
|
+
if idx := strings.LastIndex(toComplete, "/"); idx >= 0 {
|
|
23
|
+
dir = toComplete[:idx+1]
|
|
24
|
+
prefix = toComplete[idx+1:]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
entries, err := os.ReadDir(dir)
|
|
28
|
+
if err != nil {
|
|
29
|
+
return nil, cobra.ShellCompDirectiveDefault
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var completions []string
|
|
33
|
+
for _, entry := range entries {
|
|
34
|
+
if entry.IsDir() {
|
|
35
|
+
continue
|
|
36
|
+
}
|
|
37
|
+
name := entry.Name()
|
|
38
|
+
if strings.HasPrefix(name, prefix) && strings.HasSuffix(name, ".tar.gz") {
|
|
39
|
+
completions = append(completions, filepath.Join(dir, name))
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return completions, cobra.ShellCompDirectiveNoFileComp
|
|
43
|
+
},
|
|
44
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
45
|
+
filePath := args[0]
|
|
46
|
+
cfg, err := config.FromFlags(cmd)
|
|
47
|
+
if err != nil {
|
|
48
|
+
return err
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if cfg.Username == "" || cfg.Password == "" {
|
|
52
|
+
return fmt.Errorf("username and password required for HTTP auth (-u, -p)")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
info, err := os.Stat(filePath)
|
|
56
|
+
if err != nil {
|
|
57
|
+
return fmt.Errorf("file not found: %s", filePath)
|
|
58
|
+
}
|
|
59
|
+
if info.IsDir() {
|
|
60
|
+
return fmt.Errorf("not a file: %s", filePath)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
client := cfg.NewHTTPClient()
|
|
64
|
+
|
|
65
|
+
fmt.Fprintf(os.Stderr, "Logging in to %s:%d...\n", cfg.HTTPHost, cfg.HTTPPort)
|
|
66
|
+
if err := client.Login(cfg.Username, cfg.Password); err != nil {
|
|
67
|
+
return err
|
|
68
|
+
}
|
|
69
|
+
defer client.Logout()
|
|
70
|
+
|
|
71
|
+
fmt.Fprintf(os.Stderr, "Importing %s...\n", filepath.Base(filePath))
|
|
72
|
+
dbName, err := client.Import(filePath)
|
|
73
|
+
if err != nil {
|
|
74
|
+
return err
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fmt.Fprintf(os.Stderr, "Imported database: %s\n", dbName)
|
|
78
|
+
return nil
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func init() {
|
|
83
|
+
rootCmd.AddCommand(importCmd)
|
|
84
|
+
}
|
package/cli/cmd/root.go
CHANGED
|
@@ -33,4 +33,6 @@ func init() {
|
|
|
33
33
|
rootCmd.PersistentFlags().Int("timeout", 30, "Request timeout in seconds")
|
|
34
34
|
rootCmd.PersistentFlags().String("db", "", "Database name")
|
|
35
35
|
rootCmd.PersistentFlags().String("collection", "", "Collection name")
|
|
36
|
+
rootCmd.PersistentFlags().String("http-host", "localhost", "HTTP server host (for export/import)")
|
|
37
|
+
rootCmd.PersistentFlags().Int("http-port", 27018, "HTTP server port (for export/import)")
|
|
36
38
|
}
|
|
@@ -6,6 +6,7 @@ import (
|
|
|
6
6
|
"strings"
|
|
7
7
|
"time"
|
|
8
8
|
|
|
9
|
+
"github.com/nexoral/axiodb-cli/pkg/httpclient"
|
|
9
10
|
"github.com/nexoral/axiodb-cli/pkg/protocol"
|
|
10
11
|
"github.com/spf13/cobra"
|
|
11
12
|
)
|
|
@@ -23,6 +24,8 @@ type Config struct {
|
|
|
23
24
|
Timeout int
|
|
24
25
|
DB string
|
|
25
26
|
Collection string
|
|
27
|
+
HTTPHost string
|
|
28
|
+
HTTPPort int
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
func FromFlags(cmd *cobra.Command) (*Config, error) {
|
|
@@ -40,6 +43,8 @@ func FromFlags(cmd *cobra.Command) (*Config, error) {
|
|
|
40
43
|
cfg.Timeout, _ = cmd.Flags().GetInt("timeout")
|
|
41
44
|
cfg.DB, _ = cmd.Flags().GetString("db")
|
|
42
45
|
cfg.Collection, _ = cmd.Flags().GetString("collection")
|
|
46
|
+
cfg.HTTPHost, _ = cmd.Flags().GetString("http-host")
|
|
47
|
+
cfg.HTTPPort, _ = cmd.Flags().GetInt("http-port")
|
|
43
48
|
|
|
44
49
|
if cfg.ConnString != "" {
|
|
45
50
|
host, port, err := parseConnectionString(cfg.ConnString)
|
|
@@ -109,3 +114,7 @@ func GetCollectionContext(cmd *cobra.Command) string {
|
|
|
109
114
|
coll, _ := cmd.Flags().GetString("collection")
|
|
110
115
|
return coll
|
|
111
116
|
}
|
|
117
|
+
|
|
118
|
+
func (c *Config) NewHTTPClient() *httpclient.HTTPClient {
|
|
119
|
+
return httpclient.New(c.HTTPHost, c.HTTPPort, time.Duration(c.Timeout)*time.Second)
|
|
120
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
package httpclient
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"fmt"
|
|
7
|
+
"io"
|
|
8
|
+
"mime/multipart"
|
|
9
|
+
"net/http"
|
|
10
|
+
"net/http/cookiejar"
|
|
11
|
+
"os"
|
|
12
|
+
"path/filepath"
|
|
13
|
+
"strings"
|
|
14
|
+
"time"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
type HTTPClient struct {
|
|
18
|
+
baseURL string
|
|
19
|
+
httpClient *http.Client
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func New(host string, port int, timeout time.Duration) *HTTPClient {
|
|
23
|
+
jar, _ := cookiejar.New(nil)
|
|
24
|
+
return &HTTPClient{
|
|
25
|
+
baseURL: fmt.Sprintf("http://%s:%d", host, port),
|
|
26
|
+
httpClient: &http.Client{
|
|
27
|
+
Timeout: timeout,
|
|
28
|
+
Jar: jar,
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func (c *HTTPClient) Login(username, password string) error {
|
|
34
|
+
body, _ := json.Marshal(map[string]string{
|
|
35
|
+
"username": username,
|
|
36
|
+
"password": password,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
resp, err := c.httpClient.Post(c.baseURL+"/api/auth/login", "application/json", bytes.NewReader(body))
|
|
40
|
+
if err != nil {
|
|
41
|
+
return fmt.Errorf("login request failed: %w", err)
|
|
42
|
+
}
|
|
43
|
+
defer resp.Body.Close()
|
|
44
|
+
|
|
45
|
+
if resp.StatusCode == http.StatusOK {
|
|
46
|
+
return nil
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var errResp struct {
|
|
50
|
+
Message string `json:"message"`
|
|
51
|
+
}
|
|
52
|
+
json.NewDecoder(resp.Body).Decode(&errResp)
|
|
53
|
+
msg := errResp.Message
|
|
54
|
+
if msg == "" {
|
|
55
|
+
msg = resp.Status
|
|
56
|
+
}
|
|
57
|
+
return fmt.Errorf("login failed: %s", msg)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
func (c *HTTPClient) Logout() error {
|
|
61
|
+
resp, err := c.httpClient.Post(c.baseURL+"/api/auth/logout", "application/json", nil)
|
|
62
|
+
if err != nil {
|
|
63
|
+
return err
|
|
64
|
+
}
|
|
65
|
+
defer resp.Body.Close()
|
|
66
|
+
return nil
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
func (c *HTTPClient) Export(dbName string) (string, int64, error) {
|
|
70
|
+
url := fmt.Sprintf("%s/api/db/export-database/?dbName=%s", c.baseURL, dbName)
|
|
71
|
+
resp, err := c.httpClient.Get(url)
|
|
72
|
+
if err != nil {
|
|
73
|
+
return "", 0, fmt.Errorf("export request failed: %w", err)
|
|
74
|
+
}
|
|
75
|
+
defer resp.Body.Close()
|
|
76
|
+
|
|
77
|
+
if resp.StatusCode != http.StatusOK {
|
|
78
|
+
var errResp struct {
|
|
79
|
+
Message string `json:"message"`
|
|
80
|
+
}
|
|
81
|
+
json.NewDecoder(resp.Body).Decode(&errResp)
|
|
82
|
+
msg := errResp.Message
|
|
83
|
+
if msg == "" {
|
|
84
|
+
msg = resp.Status
|
|
85
|
+
}
|
|
86
|
+
return "", 0, fmt.Errorf("export failed: %s", msg)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
filename := dbName + ".tar.gz"
|
|
90
|
+
if cd := resp.Header.Get("Content-Disposition"); cd != "" {
|
|
91
|
+
if idx := strings.Index(cd, "filename="); idx >= 0 {
|
|
92
|
+
name := cd[idx+9:]
|
|
93
|
+
name = strings.Trim(name, "\"")
|
|
94
|
+
if name != "" {
|
|
95
|
+
filename = filepath.Base(name)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
out, err := os.Create(filename)
|
|
101
|
+
if err != nil {
|
|
102
|
+
return "", 0, fmt.Errorf("create file: %w", err)
|
|
103
|
+
}
|
|
104
|
+
defer out.Close()
|
|
105
|
+
|
|
106
|
+
written, err := io.Copy(out, resp.Body)
|
|
107
|
+
if err != nil {
|
|
108
|
+
os.Remove(filename)
|
|
109
|
+
return "", 0, fmt.Errorf("write file: %w", err)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return filename, written, nil
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
func (c *HTTPClient) Import(filePath string) (string, error) {
|
|
116
|
+
file, err := os.Open(filePath)
|
|
117
|
+
if err != nil {
|
|
118
|
+
return "", fmt.Errorf("open file: %w", err)
|
|
119
|
+
}
|
|
120
|
+
defer file.Close()
|
|
121
|
+
|
|
122
|
+
var body bytes.Buffer
|
|
123
|
+
writer := multipart.NewWriter(&body)
|
|
124
|
+
part, err := writer.CreateFormFile("file", filepath.Base(filePath))
|
|
125
|
+
if err != nil {
|
|
126
|
+
return "", fmt.Errorf("create form file: %w", err)
|
|
127
|
+
}
|
|
128
|
+
if _, err := io.Copy(part, file); err != nil {
|
|
129
|
+
return "", fmt.Errorf("write form data: %w", err)
|
|
130
|
+
}
|
|
131
|
+
writer.Close()
|
|
132
|
+
|
|
133
|
+
resp, err := c.httpClient.Post(
|
|
134
|
+
c.baseURL+"/api/db/import-database/",
|
|
135
|
+
writer.FormDataContentType(),
|
|
136
|
+
&body,
|
|
137
|
+
)
|
|
138
|
+
if err != nil {
|
|
139
|
+
return "", fmt.Errorf("import request failed: %w", err)
|
|
140
|
+
}
|
|
141
|
+
defer resp.Body.Close()
|
|
142
|
+
|
|
143
|
+
var result struct {
|
|
144
|
+
Message string `json:"message"`
|
|
145
|
+
Database string `json:"database"`
|
|
146
|
+
}
|
|
147
|
+
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
|
148
|
+
return "", fmt.Errorf("parse response: %w", err)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if resp.StatusCode != http.StatusOK {
|
|
152
|
+
msg := result.Message
|
|
153
|
+
if msg == "" {
|
|
154
|
+
msg = fmt.Sprintf("HTTP %d", resp.StatusCode)
|
|
155
|
+
}
|
|
156
|
+
return "", fmt.Errorf("import failed: %s", msg)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return result.Database, nil
|
|
160
|
+
}
|
|
@@ -25,9 +25,12 @@ export declare class AxioDB {
|
|
|
25
25
|
private static _instance;
|
|
26
26
|
private DatabaseMap;
|
|
27
27
|
private GUI;
|
|
28
|
+
private HTTP;
|
|
28
29
|
private TCP;
|
|
29
30
|
private TCPAuth;
|
|
30
31
|
private TLS;
|
|
32
|
+
private ready;
|
|
33
|
+
private _initializing;
|
|
31
34
|
private TLSCertPath?;
|
|
32
35
|
private TLSKeyPath?;
|
|
33
36
|
constructor(options?: AxioDBOptions);
|
|
@@ -49,30 +49,30 @@ const LoginRateLimiter_service_1 = __importDefault(require("./Auth/LoginRateLimi
|
|
|
49
49
|
class AxioDB {
|
|
50
50
|
constructor(options = {}) {
|
|
51
51
|
this.GUI = Keys_1.General.DBMS_GUI_Enable;
|
|
52
|
+
this.HTTP = false;
|
|
52
53
|
this.TCP = false;
|
|
53
54
|
this.TCPAuth = false;
|
|
54
55
|
this.TLS = false;
|
|
56
|
+
this._initializing = false;
|
|
55
57
|
if (AxioDB._instance) {
|
|
56
58
|
throw new Error("Only one instance of AxioDB is allowed.");
|
|
57
59
|
}
|
|
58
60
|
AxioDB._instance = this;
|
|
59
61
|
const { GUI, RootName, CustomPath, TCP, TCPAuth, TLS, TLSCertPath, TLSKeyPath } = options;
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
this.TCP = TCP !== undefined ? TCP : false;
|
|
70
|
-
this.TCPAuth = TCPAuth !== undefined ? TCPAuth : false;
|
|
71
|
-
this.TLS = TLS !== undefined ? TLS : false;
|
|
62
|
+
this.RootName = RootName || Keys_1.General.DBMS_Name;
|
|
63
|
+
this.currentPATH = path_1.default.resolve(CustomPath || ".");
|
|
64
|
+
this.fileManager = new FileManager_1.default();
|
|
65
|
+
this.folderManager = new FolderManager_1.default();
|
|
66
|
+
this.Converter = new Converter_helper_1.default();
|
|
67
|
+
this.ResponseHelper = new response_helper_1.default();
|
|
68
|
+
this.DatabaseMap = new Map();
|
|
69
|
+
this.GUI = GUI !== undefined ? GUI : Keys_1.General.DBMS_GUI_Enable;
|
|
70
|
+
this.HTTP = options.HTTP !== undefined ? options.HTTP : (this.GUI ? true : false);
|
|
71
|
+
this.TCP = TCP !== undefined ? TCP : false;
|
|
72
|
+
this.TCPAuth = TCPAuth !== undefined ? TCPAuth : false;
|
|
73
|
+
this.TLS = TLS !== undefined ? TLS : false;
|
|
72
74
|
this.TLSCertPath = TLSCertPath;
|
|
73
75
|
this.TLSKeyPath = TLSKeyPath;
|
|
74
|
-
// Fail fast: never silently fall back to plaintext because a cert/key path was
|
|
75
|
-
// missing or unreadable - that would be a silent security downgrade.
|
|
76
76
|
if (this.TLS) {
|
|
77
77
|
if (!this.TLSCertPath || !this.TLSKeyPath) {
|
|
78
78
|
throw new Error("TLS: true requires both TLSCertPath and TLSKeyPath to be set.");
|
|
@@ -84,7 +84,11 @@ class AxioDB {
|
|
|
84
84
|
throw new Error(`TLSKeyPath does not exist: ${this.TLSKeyPath}`);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
this.
|
|
87
|
+
if (this.GUI && options.HTTP === false) {
|
|
88
|
+
throw new Error("GUI: true requires HTTP to be enabled. Set HTTP: true or remove the explicit HTTP: false.");
|
|
89
|
+
}
|
|
90
|
+
this._initializing = true;
|
|
91
|
+
this.ready = this.initializeRoot().finally(() => { this._initializing = false; });
|
|
88
92
|
}
|
|
89
93
|
/**
|
|
90
94
|
* Initializes the root directory for the AxioDB.
|
|
@@ -110,16 +114,15 @@ class AxioDB {
|
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
if (this.GUI || (this.TCP && this.TCPAuth)) {
|
|
113
|
-
yield new AuthSeeder_service_1.default(this).seedIfNeeded();
|
|
114
|
-
LoginRateLimiter_service_1.default.startCleanupSweep();
|
|
117
|
+
yield new AuthSeeder_service_1.default(this).seedIfNeeded();
|
|
118
|
+
LoginRateLimiter_service_1.default.startCleanupSweep();
|
|
115
119
|
}
|
|
116
|
-
if (this.
|
|
117
|
-
Console_helper_1.default.green("Starting AxioDB Control Server...");
|
|
118
|
-
(0, server_1.default)(this);
|
|
120
|
+
if (this.HTTP) {
|
|
121
|
+
Console_helper_1.default.green(this.GUI ? "Starting AxioDB Control Server..." : "Starting AxioDB HTTP API Server (API only, GUI disabled)...");
|
|
122
|
+
(0, server_1.default)(this, this.GUI);
|
|
119
123
|
}
|
|
120
124
|
if (this.TCP) {
|
|
121
125
|
Console_helper_1.default.green(this.TLS ? "Starting AxioDB TCP Server (TLS)..." : "Starting AxioDB TCP Server...");
|
|
122
|
-
// Start the TCP Server with the AxioDB instance
|
|
123
126
|
const tlsOptions = this.TLS
|
|
124
127
|
? { certPath: this.TLSCertPath, keyPath: this.TLSKeyPath }
|
|
125
128
|
: undefined;
|
|
@@ -143,6 +146,8 @@ class AxioDB {
|
|
|
143
146
|
*/
|
|
144
147
|
createDB(DBName) {
|
|
145
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
if (!this._initializing)
|
|
150
|
+
yield this.ready;
|
|
146
151
|
const dbPath = path_1.default.join(this.currentPATH, DBName);
|
|
147
152
|
// Check if the database already exists
|
|
148
153
|
const exists = yield this.folderManager.DirectoryExists(dbPath);
|
|
@@ -173,6 +178,8 @@ class AxioDB {
|
|
|
173
178
|
*/
|
|
174
179
|
getInstanceInfo() {
|
|
175
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
if (!this._initializing)
|
|
182
|
+
yield this.ready;
|
|
176
183
|
const totalDatabases = yield this.folderManager.ListDirectory(path_1.default.resolve(this.currentPATH));
|
|
177
184
|
// First
|
|
178
185
|
const totalSize = yield this.folderManager.GetDirectorySize(path_1.default.resolve(this.currentPATH));
|
|
@@ -212,6 +219,8 @@ class AxioDB {
|
|
|
212
219
|
*/
|
|
213
220
|
isDatabaseExists(DBName) {
|
|
214
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
if (!this._initializing)
|
|
223
|
+
yield this.ready;
|
|
215
224
|
const dbPath = path_1.default.join(this.currentPATH, DBName);
|
|
216
225
|
const exists = yield this.folderManager.DirectoryExists(dbPath);
|
|
217
226
|
return exists.statusCode === StatusCode_1.StatusCodes.OK;
|
|
@@ -231,6 +240,8 @@ class AxioDB {
|
|
|
231
240
|
*/
|
|
232
241
|
deleteDatabase(DBName) {
|
|
233
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
+
if (!this._initializing)
|
|
244
|
+
yield this.ready;
|
|
234
245
|
const dbPath = path_1.default.join(this.currentPATH, DBName);
|
|
235
246
|
const exists = yield this.folderManager.DirectoryExists(dbPath);
|
|
236
247
|
if (exists.statusCode === StatusCode_1.StatusCodes.OK) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Indexation.operation.js","sourceRoot":"","sources":["../../source/Services/Indexation.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;;AAEvD,mBAAmB;AACnB,mFAA2D;AAC3D,uFAA+D;AAC/D,8CAA8C;AAC9C,gDAAwB;AACxB,4CAAoB;AACpB,uFAAqD;AACrD,kDAAkD;AAElD,iBAAiB;AACjB,kFAAmD;AACnD,8EAA+C;AAC/C,0DAAwD;AACxD,gFAAuD;AAQvD,qEAAgE;AAEhE,kEAAyD;AACzD,mFAAmD;AACnD,4DAA8D;AAC9D,+FAA+D;AAE/D;;;;;;;;;;;;;GAaG;AACH;
|
|
1
|
+
{"version":3,"file":"Indexation.operation.js","sourceRoot":"","sources":["../../source/Services/Indexation.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;;AAEvD,mBAAmB;AACnB,m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UAAU,KAAK,wBAAW,CAAC,EAAE,EAAE,CAAC;gBACzC,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;gBACjD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,0BAA0B;gBAC3D,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAChC,aAAa,MAAM,uBAAuB,CAC3C,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,aAAa,MAAM,iBAAiB,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;KAAA;CACF"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DatabaseMap } from "./database.operation.interface";
|
|
2
2
|
export interface AxioDBOptions {
|
|
3
3
|
GUI?: boolean;
|
|
4
|
+
/** Enable HTTP API server on port 27018. Auto-enables when GUI: true. If GUI: true and HTTP: false, throws error at startup. */
|
|
5
|
+
HTTP?: boolean;
|
|
4
6
|
RootName?: string;
|
|
5
7
|
CustomPath?: string;
|
|
6
8
|
TCP?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AxioDB } from "../../Services/Indexation.operation";
|
|
2
|
-
export default function createAxioDBControlServer(AxioDBInstance: AxioDB): Promise<void>;
|
|
2
|
+
export default function createAxioDBControlServer(AxioDBInstance: AxioDB, guiEnabled?: boolean): Promise<void>;
|
|
@@ -24,8 +24,8 @@ const keys_1 = require("./keys");
|
|
|
24
24
|
const PortFreeChecker_1 = __importDefault(require("./PortFreeChecker"));
|
|
25
25
|
const Router_1 = __importDefault(require("../router/Router"));
|
|
26
26
|
const SessionStore_service_1 = __importDefault(require("../../Services/Auth/SessionStore.service"));
|
|
27
|
-
function createAxioDBControlServer(
|
|
28
|
-
return __awaiter(this,
|
|
27
|
+
function createAxioDBControlServer(AxioDBInstance_1) {
|
|
28
|
+
return __awaiter(this, arguments, void 0, function* (AxioDBInstance, guiEnabled = true) {
|
|
29
29
|
yield (0, PortFreeChecker_1.default)(keys_1.ServerKeys.PORT);
|
|
30
30
|
const AxioDBControlServer = (0, fastify_1.default)({
|
|
31
31
|
logger: false,
|
|
@@ -52,19 +52,26 @@ function createAxioDBControlServer(AxioDBInstance) {
|
|
|
52
52
|
done(err, undefined);
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
if (guiEnabled) {
|
|
56
|
+
yield AxioDBControlServer.register(static_1.default, {
|
|
57
|
+
root: keys_1.staticPath,
|
|
58
|
+
prefix: "/",
|
|
59
|
+
decorateReply: false,
|
|
60
|
+
});
|
|
61
|
+
AxioDBControlServer.get("/", (request, reply) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const indexPath = path_1.default.join(keys_1.staticPath, "index.html");
|
|
63
|
+
const stream = fs_1.default.createReadStream(indexPath);
|
|
64
|
+
return reply.type("text/html").send(stream);
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
AxioDBControlServer.get("/", (request, reply) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return reply.type("application/json").send({
|
|
70
|
+
message: "AxioDB HTTP API is running. GUI is disabled. Enable it with GUI: true.",
|
|
71
|
+
api: "/api/health",
|
|
72
|
+
});
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
68
75
|
AxioDBControlServer.register(Router_1.default, {
|
|
69
76
|
prefix: "/api",
|
|
70
77
|
AxioDBInstance,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../source/server/config/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAsD;AACtD,sDAA8B;AAC9B,yDAAwC;AACxC,6D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CAAC,IAAI,CAAC;gBAC7B,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;YACH,8BAAY,CAAC,iBAAiB,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,wDAAwD,iBAAU,CAAC,IAAI,EAAE,CAC1E,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axiodb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.1.2",
|
|
4
4
|
"description": "The Pure JavaScript Alternative to SQLite. Embedded NoSQL database for Node.js with MongoDB-style queries, zero native dependencies, built-in InMemoryCache, and web GUI. Perfect for desktop apps, CLI tools, and embedded systems. No compilation, no platform issuesβpure JavaScript from npm install to production.",
|
|
5
5
|
"main": "./lib/config/DB.js",
|
|
6
6
|
"types": "./lib/config/DB.d.ts",
|