reepoe 1.1.5 → 1.1.7
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/bin/reepoe.js +24 -18
- package/package.json +1 -1
package/bin/reepoe.js
CHANGED
|
@@ -94,32 +94,36 @@ MORE INFO:
|
|
|
94
94
|
|
|
95
95
|
async function makeQuery(query) {
|
|
96
96
|
const axios = require('axios');
|
|
97
|
-
const configPath = path.join(process.cwd(), 'reepoe.config.json');
|
|
98
|
-
|
|
99
|
-
// Read config to get port
|
|
100
|
-
let port = 8000;
|
|
101
|
-
if (fs.existsSync(configPath)) {
|
|
102
|
-
try {
|
|
103
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
104
|
-
port = config.api?.port || 8000;
|
|
105
|
-
} catch (e) {
|
|
106
|
-
// Use default port
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
97
|
|
|
110
98
|
// Load activation to get user email and API URL
|
|
111
99
|
let userEmail = null;
|
|
112
|
-
let apiBase =
|
|
100
|
+
let apiBase = null;
|
|
113
101
|
const activationPath = path.join(os.homedir(), '.reepoe', 'activation.json');
|
|
102
|
+
|
|
114
103
|
if (fs.existsSync(activationPath)) {
|
|
115
104
|
try {
|
|
116
105
|
const activation = JSON.parse(fs.readFileSync(activationPath, 'utf8'));
|
|
117
106
|
userEmail = activation.email;
|
|
118
|
-
|
|
119
|
-
apiBase = activation.api_base || `http://localhost:${port}`;
|
|
107
|
+
apiBase = activation.api_base;
|
|
120
108
|
} catch (e) {
|
|
121
|
-
|
|
109
|
+
console.error('❌ Failed to load activation. Run: reepoe-start');
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// If no API base from activation, try localhost
|
|
115
|
+
if (!apiBase) {
|
|
116
|
+
const configPath = path.join(process.cwd(), 'reepoe.config.json');
|
|
117
|
+
let port = 8000;
|
|
118
|
+
if (fs.existsSync(configPath)) {
|
|
119
|
+
try {
|
|
120
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
121
|
+
port = config.api?.port || 8000;
|
|
122
|
+
} catch (e) {
|
|
123
|
+
// Use default port
|
|
124
|
+
}
|
|
122
125
|
}
|
|
126
|
+
apiBase = `http://localhost:${port}`;
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
const url = `${apiBase}/query`;
|
|
@@ -130,11 +134,13 @@ async function makeQuery(query) {
|
|
|
130
134
|
if (userEmail) {
|
|
131
135
|
requestBody.user_email = userEmail;
|
|
132
136
|
}
|
|
133
|
-
const response = await axios.post(url, requestBody);
|
|
137
|
+
const response = await axios.post(url, requestBody, { timeout: 60000 });
|
|
134
138
|
console.log(response.data.response || response.data);
|
|
135
139
|
} catch (error) {
|
|
136
140
|
if (error.code === 'ECONNREFUSED') {
|
|
137
|
-
console.error('❌
|
|
141
|
+
console.error('❌ Cannot connect to ReePoe API');
|
|
142
|
+
console.error(` Tried: ${apiBase}`);
|
|
143
|
+
console.error(' Run: reepoe-start');
|
|
138
144
|
} else {
|
|
139
145
|
console.error(`❌ Query failed: ${error.message}`);
|
|
140
146
|
}
|