skillstogether 0.1.0 → 0.1.1
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 +0 -13
- package/dist/index.js +5 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -145,19 +145,6 @@ pnpm unlink --global
|
|
|
145
145
|
node packages/cli/dist/index.js --help
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
### Environment Variables
|
|
149
|
-
|
|
150
|
-
| Variable | Default | Description |
|
|
151
|
-
| --------------------- | ----------------------- | -------------------- |
|
|
152
|
-
| `CLI_API_URL` | `http://localhost:3000` | API server URL |
|
|
153
|
-
|
|
154
|
-
Example:
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
# Use a different API URL
|
|
158
|
-
CLI_API_URL=http://localhost:3000 node dist/index.js auth login
|
|
159
|
-
```
|
|
160
|
-
|
|
161
148
|
### Testing the Full Flow
|
|
162
149
|
|
|
163
150
|
1. Start the Next.js dev server:
|
package/dist/index.js
CHANGED
|
@@ -49,16 +49,9 @@ function removeToken() {
|
|
|
49
49
|
delete config.token;
|
|
50
50
|
writeConfig(config);
|
|
51
51
|
}
|
|
52
|
+
var API_URL = "https://skillstogether.app";
|
|
52
53
|
function getApiUrl() {
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
function isInsecureApiUrl() {
|
|
56
|
-
try {
|
|
57
|
-
const parsed = new URL(getApiUrl());
|
|
58
|
-
return parsed.protocol === "http:" && parsed.hostname !== "localhost" && parsed.hostname !== "127.0.0.1";
|
|
59
|
-
} catch {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
54
|
+
return API_URL;
|
|
62
55
|
}
|
|
63
56
|
|
|
64
57
|
// src/lib/constants.ts
|
|
@@ -174,20 +167,12 @@ async function fetchWithSizeLimit(url, options = {}) {
|
|
|
174
167
|
}
|
|
175
168
|
|
|
176
169
|
// src/lib/api.ts
|
|
177
|
-
var insecureUrlWarned = false;
|
|
178
|
-
function warnInsecureApiUrlOnce() {
|
|
179
|
-
if (!insecureUrlWarned && isInsecureApiUrl()) {
|
|
180
|
-
insecureUrlWarned = true;
|
|
181
|
-
console.warn("Warning: CLI_API_URL is using HTTP. Use HTTPS in production.");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
170
|
function wrapFetchError(url, cause) {
|
|
185
171
|
const message = cause instanceof Error ? cause.message : "Unknown network error";
|
|
186
172
|
if (message === "fetch failed" || message.includes("ECONNREFUSED") || message.includes("ENOTFOUND") || message.includes("network")) {
|
|
187
|
-
return new Error(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
);
|
|
173
|
+
return new Error(`Cannot reach API at ${url}.`, {
|
|
174
|
+
cause: cause instanceof Error ? cause : void 0
|
|
175
|
+
});
|
|
191
176
|
}
|
|
192
177
|
return cause instanceof Error ? cause : new Error(String(cause));
|
|
193
178
|
}
|
|
@@ -196,7 +181,6 @@ async function apiGet(path, queryParams) {
|
|
|
196
181
|
if (!token) {
|
|
197
182
|
throw new Error("Not authenticated. Run 'auth login' first.");
|
|
198
183
|
}
|
|
199
|
-
warnInsecureApiUrlOnce();
|
|
200
184
|
const apiUrl = getApiUrl();
|
|
201
185
|
const url = new URL(`${apiUrl}/api${path}`);
|
|
202
186
|
if (queryParams) {
|
|
@@ -230,7 +214,6 @@ async function apiPost(path, body) {
|
|
|
230
214
|
if (!token) {
|
|
231
215
|
throw new Error("Not authenticated. Run 'auth login' first.");
|
|
232
216
|
}
|
|
233
|
-
warnInsecureApiUrlOnce();
|
|
234
217
|
const apiUrl = getApiUrl();
|
|
235
218
|
const url = `${apiUrl}/api${path}`;
|
|
236
219
|
let response;
|