@liorandb/db 1.0.6 → 1.0.8
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/cli/index.js +1 -1
- package/dist/config/database.js +6 -1
- package/dist/server.js +26 -13
- package/dist/utils/cli.js +35 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -78,7 +78,7 @@ function safeParse(obj) {
|
|
|
78
78
|
async function handleUserCommand(cmd) {
|
|
79
79
|
const users = await (0, database_1.getAuthCollection)();
|
|
80
80
|
if (cmd.startsWith("user.create")) {
|
|
81
|
-
const args = cmd.match(/\("(.+?)"
|
|
81
|
+
const args = cmd.match(/\(\s*"(.+?)"\s*,\s*"(.+?)"\s*\)/);
|
|
82
82
|
if (!args)
|
|
83
83
|
return console.error("❌ Invalid syntax");
|
|
84
84
|
const [, username, password] = args;
|
package/dist/config/database.js
CHANGED
|
@@ -4,7 +4,12 @@ exports.manager = void 0;
|
|
|
4
4
|
exports.getAuthCollection = getAuthCollection;
|
|
5
5
|
// src/config/database.ts
|
|
6
6
|
const core_1 = require("@liorandb/core");
|
|
7
|
-
|
|
7
|
+
const cli_1 = require("../utils/cli");
|
|
8
|
+
const cli = (0, cli_1.parseCLIArgs)();
|
|
9
|
+
exports.manager = new core_1.LioranManager({
|
|
10
|
+
rootPath: cli.rootPath || "./lioran-data",
|
|
11
|
+
encryptionKey: cli.encryptionKey || "default-encryption-key",
|
|
12
|
+
});
|
|
8
13
|
async function getAuthCollection() {
|
|
9
14
|
const db = await exports.manager.db("_auth");
|
|
10
15
|
await db.createCollection("users").catch(() => { });
|
package/dist/server.js
CHANGED
|
@@ -5,24 +5,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
// src/server.ts
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
8
9
|
const app_1 = __importDefault(require("./app"));
|
|
10
|
+
const cli_1 = require("./utils/cli");
|
|
11
|
+
const cli = (0, cli_1.parseCLIArgs)();
|
|
12
|
+
console.log("⚙ Runtime Config:");
|
|
13
|
+
console.log(`📁 DB Root Path : ${cli.rootPath || "./lioran-data"}`);
|
|
14
|
+
console.log(`🔐 Encryption : ${cli.encryptionKey ? "Enabled" : "Disabled"}`);
|
|
9
15
|
const PORT = 4000;
|
|
16
|
+
function printHostAddresses(port) {
|
|
17
|
+
const urls = new Set();
|
|
18
|
+
// Localhost
|
|
19
|
+
urls.add(`http://localhost:${port}`);
|
|
20
|
+
urls.add(`http://127.0.0.1:${port}`);
|
|
21
|
+
// Network interfaces
|
|
22
|
+
const nets = os_1.default.networkInterfaces();
|
|
23
|
+
for (const name of Object.keys(nets)) {
|
|
24
|
+
for (const net of nets[name] || []) {
|
|
25
|
+
if (net.family === "IPv4" && !net.internal) {
|
|
26
|
+
urls.add(`http://${net.address}:${port}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
console.log("🌐 Available Host URLs:");
|
|
31
|
+
for (const url of urls) {
|
|
32
|
+
console.log(` → ${url}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
10
35
|
app_1.default.listen(PORT, "0.0.0.0", () => {
|
|
11
36
|
console.log("======================================");
|
|
12
37
|
console.log("🚀 LioranDB Host is LIVE");
|
|
13
38
|
console.log(`📡 Listening on port: ${PORT}`);
|
|
14
|
-
|
|
15
|
-
console.log(`🌐 Host Address: localhost:4000`);
|
|
16
|
-
const os = require("os");
|
|
17
|
-
const networkInterfaces = os.networkInterfaces();
|
|
18
|
-
for (const interfaceName in networkInterfaces) {
|
|
19
|
-
const interfaceInfo = networkInterfaces[interfaceName];
|
|
20
|
-
for (const addressInfo of interfaceInfo) {
|
|
21
|
-
if (addressInfo.family === "IPv4" && !addressInfo.internal) {
|
|
22
|
-
console.log(`🌐 Host Address: ${addressInfo.address}:4000`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
// console.log(`🧠 Mode: ${process.env.NODE_ENV || "development"}`);
|
|
39
|
+
printHostAddresses(PORT);
|
|
27
40
|
console.log("======================================");
|
|
28
41
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseCLIArgs = parseCLIArgs;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function parseCLIArgs() {
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
let rootPath;
|
|
12
|
+
let encryptionKey;
|
|
13
|
+
for (let i = 0; i < args.length; i++) {
|
|
14
|
+
const arg = args[i];
|
|
15
|
+
if (arg === "--root") {
|
|
16
|
+
rootPath = args[++i];
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (arg === "-ed") {
|
|
20
|
+
encryptionKey = args[++i];
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (arg === "-ef") {
|
|
24
|
+
const file = args[++i];
|
|
25
|
+
const fullPath = path_1.default.resolve(file);
|
|
26
|
+
if (!fs_1.default.existsSync(fullPath)) {
|
|
27
|
+
console.error(`❌ Encryption key file not found: ${fullPath}`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
encryptionKey = fs_1.default.readFileSync(fullPath, "utf8").trim();
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { rootPath, encryptionKey };
|
|
35
|
+
}
|