@nordsym/apiclaw 1.5.9 โ 1.5.11
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/APILAYER_STATUS_2026-03-24.md +38 -0
- package/CHANGELOG-WHITELIST-V2.md +269 -0
- package/HIVR-INTEGRATION.md +281 -0
- package/HIVR-WHITELIST-STATUS.md +205 -0
- package/HIVR-WHITELIST.md +148 -0
- package/TERMINOLOGY-AUDIT.md +99 -0
- package/TERMINOLOGY-FIXED.md +74 -0
- package/VIDEO-DEMO-GUIDE.md +82 -0
- package/WHITELIST-ARCHITECTURE.md +379 -0
- package/api/discover.ts +71 -0
- package/api/health.ts +20 -0
- package/convex/http.d.ts.map +1 -1
- package/convex/http.js +8 -0
- package/convex/http.js.map +1 -1
- package/convex/http.ts +8 -0
- package/direct-test.mjs +51 -0
- package/dist/access-control.d.ts +45 -0
- package/dist/access-control.d.ts.map +1 -0
- package/dist/access-control.js +142 -0
- package/dist/access-control.js.map +1 -0
- package/dist/analytics.d.ts +4 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/analytics.js +1 -0
- package/dist/analytics.js.map +1 -1
- package/dist/cli/commands/mcp-install.d.ts.map +1 -1
- package/dist/cli/commands/mcp-install.js +55 -40
- package/dist/cli/commands/mcp-install.js.map +1 -1
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +148 -0
- package/dist/credentials.js.map +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +191 -82
- package/dist/discovery.js.map +1 -1
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +274 -0
- package/dist/execute.js.map +1 -1
- package/dist/hivr-whitelist.d.ts +18 -0
- package/dist/hivr-whitelist.d.ts.map +1 -0
- package/dist/hivr-whitelist.js +95 -0
- package/dist/hivr-whitelist.js.map +1 -0
- package/dist/http-api.d.ts.map +1 -1
- package/dist/http-api.js +17 -33
- package/dist/http-api.js.map +1 -1
- package/dist/http-server-minimal.d.ts +7 -0
- package/dist/http-server-minimal.d.ts.map +1 -0
- package/dist/http-server-minimal.js +126 -0
- package/dist/http-server-minimal.js.map +1 -0
- package/dist/product-whitelist.d.ts +37 -0
- package/dist/product-whitelist.d.ts.map +1 -0
- package/dist/product-whitelist.js +203 -0
- package/dist/product-whitelist.js.map +1 -0
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +1 -1
- package/dist/proxy.js.map +1 -1
- package/email-templates/README.md +104 -0
- package/email-templates/partnership-template.html +116 -0
- package/landing/next-env.d.ts +1 -0
- package/landing/pages/api/discover.ts +43 -0
- package/landing/pages/api/health.ts +20 -0
- package/landing/src/app/api/auth/magic-link/route.ts +1 -1
- package/landing/src/app/auth/verify/page.tsx +6 -0
- package/landing/src/app/dashboard/verify/page.tsx +6 -0
- package/landing/src/app/join/page.tsx +6 -0
- package/landing/src/app/layout.tsx +2 -2
- package/landing/src/app/login/page.tsx +1 -1
- package/landing/src/app/mou/[partnerId]/page.tsx +6 -0
- package/landing/src/app/page.tsx +39 -18
- package/landing/src/app/providers/dashboard/[apiId]/actions/[actionId]/edit/page.tsx +6 -0
- package/landing/src/app/providers/dashboard/[apiId]/actions/new/page.tsx +5 -0
- package/landing/src/app/providers/dashboard/[apiId]/actions/page.tsx +5 -0
- package/landing/src/app/providers/dashboard/[apiId]/direct-call/page.tsx +6 -1
- package/landing/src/app/providers/dashboard/[apiId]/page.tsx +5 -0
- package/landing/src/app/providers/dashboard/[apiId]/test/page.tsx +5 -0
- package/landing/src/app/providers/dashboard/layout.tsx +6 -6
- package/landing/src/app/providers/dashboard/login/page.tsx +1 -1
- package/landing/src/app/providers/dashboard/page.tsx +1 -1
- package/landing/src/app/providers/dashboard/verify/page.tsx +6 -0
- package/landing/src/app/providers/layout.tsx +1 -1
- package/landing/src/app/upgrade/page.tsx +6 -0
- package/landing/src/app/workspace/page.tsx +6 -0
- package/landing/src/components/HeroTabs.tsx +2 -2
- package/landing/src/components/VideoDemo.tsx +94 -0
- package/landing/src/components/{ProviderDashboard.tsx โ Workspace.tsx} +2 -2
- package/landing/src/lib/mock-data.ts +1 -1
- package/landing/src/lib/stats.json +1 -1
- package/package.json +4 -2
- package/scripts/test-whitelist-v2.sh +128 -0
- package/src/access-control.ts +174 -0
- package/src/analytics.ts +5 -0
- package/src/cli/commands/mcp-install.ts +14 -4
- package/src/credentials.ts +156 -0
- package/src/discovery.ts +191 -82
- package/src/execute.ts +274 -0
- package/src/hivr-whitelist.ts +110 -0
- package/src/http-api.ts +18 -34
- package/src/http-server-minimal.ts +154 -0
- package/src/product-whitelist.ts +246 -0
- package/src/proxy.ts +1 -1
- package/test-actual-handlers.ts +92 -0
- package/test-apilayer-all-14.ts +249 -0
- package/test-apilayer-fixed.ts +248 -0
- package/test-direct-endpoints.ts +174 -0
- package/test-exact-endpoints.ts +144 -0
- package/test-final.ts +83 -0
- package/test-full-routing.ts +100 -0
- package/test-handlers-correct.ts +217 -0
- package/test-numverify-key.ts +41 -0
- package/test-via-handlers.ts +92 -0
- package/test-worldnews.mjs +26 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
|
|
5
|
+
interface TestResult {
|
|
6
|
+
name: string;
|
|
7
|
+
endpoint: string;
|
|
8
|
+
status: number | string;
|
|
9
|
+
success: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
responseTime: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const results: TestResult[] = [];
|
|
15
|
+
|
|
16
|
+
// Load credentials
|
|
17
|
+
function loadEnvFile(): Record<string, string> {
|
|
18
|
+
const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
|
|
19
|
+
if (!fs.existsSync(envPath)) {
|
|
20
|
+
console.error(`โ No credentials file at ${envPath}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const content = fs.readFileSync(envPath, 'utf-8');
|
|
25
|
+
const vars: Record<string, string> = {};
|
|
26
|
+
for (const line of content.split('\n')) {
|
|
27
|
+
const match = line.match(/^([^=]+)=(.*)$/);
|
|
28
|
+
if (match) {
|
|
29
|
+
vars[match[1].trim()] = match[2].trim().replace(/^['""]|["'"]$/g, '');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return vars;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const env = loadEnvFile();
|
|
36
|
+
|
|
37
|
+
// ALL 14 APIs with CORRECTED endpoints from user documentation
|
|
38
|
+
const tests = [
|
|
39
|
+
// โ
7 KNOWN WORKING (from previous tests)
|
|
40
|
+
{
|
|
41
|
+
name: 'ExchangeRate API',
|
|
42
|
+
url: (key: string) => `https://api.apilayer.com/exchangerate?apikey=${key}`,
|
|
43
|
+
key: env.APILAYER_EXCHANGERATE_KEY,
|
|
44
|
+
method: 'GET'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'AviationStack API',
|
|
48
|
+
url: (key: string) => `https://api.apilayer.com/aviationstack?access_key=${key}`,
|
|
49
|
+
key: env.APILAYER_AVIATIONSTACK_KEY,
|
|
50
|
+
method: 'GET'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'ScreenshotLayer API',
|
|
54
|
+
url: (key: string) => `https://api.apilayer.com/screenshot?url=https://example.com&access_key=${key}`,
|
|
55
|
+
key: env.APILAYER_SCREENSHOTLAYER_KEY,
|
|
56
|
+
method: 'GET'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'Number Verification API',
|
|
60
|
+
url: (key: string) => `https://api.apilayer.com/validate?number=1234567890&access_key=${key}`,
|
|
61
|
+
key: env.APILAYER_NUMVERIFY_KEY,
|
|
62
|
+
method: 'GET'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'Email Verification API',
|
|
66
|
+
url: (key: string) => `https://api.apilayer.com/check?email=test@example.com&access_key=${key}`,
|
|
67
|
+
key: env.APILAYER_EMAILVERIFY_KEY,
|
|
68
|
+
method: 'GET'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'Marketstack API',
|
|
72
|
+
url: (key: string) => `https://api.apilayer.com/eod?symbols=AAPL&access_key=${key}`,
|
|
73
|
+
key: env.APILAYER_MARKETSTACK_KEY,
|
|
74
|
+
method: 'GET'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'VAT Layer API',
|
|
78
|
+
url: (key: string) => `https://api.apilayer.com/validate?country_code=SE&access_key=${key}`,
|
|
79
|
+
key: env.APILAYER_VATLAYER_KEY,
|
|
80
|
+
method: 'GET'
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
// ๐ง 4 PREVIOUSLY FAILED - NOW WITH CORRECTED ENDPOINTS from user documentation
|
|
84
|
+
{
|
|
85
|
+
name: 'Image Crop API',
|
|
86
|
+
url: (key: string) => `https://api.apilayer.com/crop?url=https://example.com/image.jpg`,
|
|
87
|
+
key: env.APILAYER_IMAGECROP_KEY,
|
|
88
|
+
method: 'GET',
|
|
89
|
+
authType: 'header'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'Form API',
|
|
93
|
+
url: (key: string) => `https://api.apilayer.com/form`,
|
|
94
|
+
key: env.APILAYER_FORMAPI_KEY,
|
|
95
|
+
method: 'POST',
|
|
96
|
+
authType: 'header',
|
|
97
|
+
body: 'Test Form'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'Advanced Scraper API',
|
|
101
|
+
url: (key: string) => `https://api.apilayer.com/scraper?url=https://example.com`,
|
|
102
|
+
key: env.APILAYER_SCRAPER_KEY,
|
|
103
|
+
method: 'GET',
|
|
104
|
+
authType: 'header'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'Finance News API',
|
|
108
|
+
url: (key: string) => `https://api.apilayer.com/news?limit=5`,
|
|
109
|
+
key: env.APILAYER_FINANCENEWS_KEY,
|
|
110
|
+
method: 'GET',
|
|
111
|
+
authType: 'header'
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
// โ 3 AUTH FAILURES (investigating)
|
|
115
|
+
{
|
|
116
|
+
name: 'PDF Layer API',
|
|
117
|
+
url: (key: string) => `https://api.apilayer.com/pdf?url=https://example.com`,
|
|
118
|
+
key: env.APILAYER_PDFLAYER_KEY,
|
|
119
|
+
method: 'GET',
|
|
120
|
+
authType: 'header'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'SkillAPI',
|
|
124
|
+
url: (key: string) => `https://api.promptapi.com/skills?q=test`,
|
|
125
|
+
key: env.APILAYER_SKILLAPI_KEY,
|
|
126
|
+
method: 'GET',
|
|
127
|
+
authType: 'header'
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'World News API',
|
|
131
|
+
url: (key: string) => `https://api.apilayer.com/worldnews?keywords=test`,
|
|
132
|
+
key: env.APILAYER_WORLDNEWS_KEY,
|
|
133
|
+
method: 'GET',
|
|
134
|
+
authType: 'header'
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
async function runTests() {
|
|
139
|
+
console.log('๐งช Testing all 14 APILayer services (WITH CORRECTED ENDPOINTS)\n');
|
|
140
|
+
|
|
141
|
+
for (const test of tests) {
|
|
142
|
+
if (!test.key) {
|
|
143
|
+
results.push({
|
|
144
|
+
name: test.name,
|
|
145
|
+
endpoint: 'N/A',
|
|
146
|
+
status: 'NO KEY',
|
|
147
|
+
success: false,
|
|
148
|
+
responseTime: 0
|
|
149
|
+
});
|
|
150
|
+
console.log(`โ ${test.name}: NO API KEY FOUND`);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
const startTime = Date.now();
|
|
156
|
+
const url = test.url(test.key);
|
|
157
|
+
|
|
158
|
+
const headers: Record<string, string> = {
|
|
159
|
+
'Content-Type': 'application/json'
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// Add API key as header if needed
|
|
163
|
+
const authType = (test as any).authType || 'query';
|
|
164
|
+
if (authType === 'header') {
|
|
165
|
+
headers['apikey'] = test.key;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const options: RequestInit = {
|
|
169
|
+
method: test.method,
|
|
170
|
+
headers
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
if ((test as any).body) {
|
|
174
|
+
options.body = (test as any).body;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const response = await fetch(url, options);
|
|
178
|
+
const responseTime = Date.now() - startTime;
|
|
179
|
+
|
|
180
|
+
let success = false;
|
|
181
|
+
let error: string | undefined;
|
|
182
|
+
|
|
183
|
+
if (response.ok) {
|
|
184
|
+
success = true;
|
|
185
|
+
console.log(`โ
${test.name}: ${response.status} (${responseTime}ms)`);
|
|
186
|
+
} else {
|
|
187
|
+
let errorMsg = `HTTP ${response.status}`;
|
|
188
|
+
try {
|
|
189
|
+
const body = await response.json();
|
|
190
|
+
if (body.message) {
|
|
191
|
+
errorMsg += ` - ${body.message}`;
|
|
192
|
+
}
|
|
193
|
+
} catch {
|
|
194
|
+
// body not JSON
|
|
195
|
+
}
|
|
196
|
+
error = errorMsg;
|
|
197
|
+
console.log(`โ ${test.name}: ${errorMsg} (${responseTime}ms)`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
results.push({
|
|
201
|
+
name: test.name,
|
|
202
|
+
endpoint: url.split('?')[0],
|
|
203
|
+
status: response.status,
|
|
204
|
+
success,
|
|
205
|
+
error,
|
|
206
|
+
responseTime
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
} catch (err) {
|
|
210
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
211
|
+
console.log(`โ ${test.name}: ${errorMsg}`);
|
|
212
|
+
|
|
213
|
+
results.push({
|
|
214
|
+
name: test.name,
|
|
215
|
+
endpoint: 'N/A',
|
|
216
|
+
status: 'ERROR',
|
|
217
|
+
success: false,
|
|
218
|
+
error: errorMsg,
|
|
219
|
+
responseTime: 0
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Summary
|
|
225
|
+
console.log('\n' + '='.repeat(60));
|
|
226
|
+
console.log('๐ FINAL STATUS');
|
|
227
|
+
console.log('='.repeat(60));
|
|
228
|
+
|
|
229
|
+
const working = results.filter(r => r.success);
|
|
230
|
+
const failed = results.filter(r => !r.success);
|
|
231
|
+
|
|
232
|
+
console.log(`\nโ
WORKING (${working.length}/14):`);
|
|
233
|
+
working.forEach(r => {
|
|
234
|
+
console.log(` โข ${r.name}`);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (failed.length > 0) {
|
|
238
|
+
console.log(`\nโ NOT WORKING (${failed.length}/14):`);
|
|
239
|
+
failed.forEach(r => {
|
|
240
|
+
console.log(` โข ${r.name}: ${r.error}`);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
console.log(`\n๐ Success rate: ${working.length}/14 (${Math.round(working.length / results.length * 100)}%)`);
|
|
245
|
+
console.log('\n๐พ Ready for Pratham meeting: ' + (working.length >= 10 ? 'โ
YES' : 'โ NO'));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
runTests().catch(console.error);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
|
|
5
|
+
interface TestResult {
|
|
6
|
+
name: string;
|
|
7
|
+
endpoint: string;
|
|
8
|
+
method: string;
|
|
9
|
+
status: number | string;
|
|
10
|
+
success: boolean;
|
|
11
|
+
responseTime: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Load credentials
|
|
15
|
+
function loadEnv(): Record<string, string> {
|
|
16
|
+
const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
|
|
17
|
+
const content = fs.readFileSync(envPath, 'utf-8');
|
|
18
|
+
const vars: Record<string, string> = {};
|
|
19
|
+
for (const line of content.split('\n')) {
|
|
20
|
+
const match = line.match(/^([^=]+)=(.*)$/);
|
|
21
|
+
if (match) {
|
|
22
|
+
vars[match[1].trim()] = match[2].trim();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return vars;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const env = loadEnv();
|
|
29
|
+
|
|
30
|
+
const tests = [
|
|
31
|
+
{
|
|
32
|
+
name: 'ExchangeRate API',
|
|
33
|
+
url: `https://api.apilayer.com/exchangerates_data?apikey=${env.APILAYER_EXCHANGERATE_KEY}`,
|
|
34
|
+
method: 'GET',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'AviationStack API',
|
|
38
|
+
url: `https://api.apilayer.com/aviationstack?access_key=${env.APILAYER_AVIATIONSTACK_KEY}`,
|
|
39
|
+
method: 'GET',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'ScreenshotLayer API',
|
|
43
|
+
url: `https://api.screenshotlayer.com/api?url=https://example.com&access_key=${env.APILAYER_SCREENSHOTLAYER_KEY}`,
|
|
44
|
+
method: 'GET',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'Number Verification API',
|
|
48
|
+
url: `https://api.apilayer.com/validate?number=1234567890&access_key=${env.APILAYER_NUMVERIFY_KEY}`,
|
|
49
|
+
method: 'GET',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Email Verification API',
|
|
53
|
+
url: `https://api.apilayer.com/check?email=test@example.com&access_key=${env.APILAYER_EMAILVERIFY_KEY}`,
|
|
54
|
+
method: 'GET',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'Marketstack API',
|
|
58
|
+
url: `https://api.marketstack.com/v1/eod?symbols=AAPL&access_key=${env.APILAYER_MARKETSTACK_KEY}`,
|
|
59
|
+
method: 'GET',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'VAT Layer API',
|
|
63
|
+
url: `https://apilayer.net/api/validate?country_code=SE&access_key=${env.APILAYER_VATLAYER_KEY}`,
|
|
64
|
+
method: 'GET',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'Finance News API',
|
|
68
|
+
url: `https://api.apilayer.com/financelayer/news?apikey=${env.APILAYER_FINANCENEWS_KEY}`,
|
|
69
|
+
method: 'GET',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Image Crop API',
|
|
73
|
+
url: `https://api.apilayer.com/smart_crop/url?apikey=${env.APILAYER_IMAGECROP_KEY}`,
|
|
74
|
+
method: 'GET',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Advanced Scraper API',
|
|
78
|
+
url: `https://api.apilayer.com/adv_scraper/scraper?url=https://example.com&apikey=${env.APILAYER_SCRAPER_KEY}`,
|
|
79
|
+
method: 'GET',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'PDF Layer API',
|
|
83
|
+
url: `https://api.pdflayer.com/api`,
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: { 'apikey': env.APILAYER_PDFLAYER_KEY },
|
|
86
|
+
body: JSON.stringify({ document_url: 'https://example.com' }),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'World News API',
|
|
90
|
+
url: `https://api.apilayer.com/world_news/extract-news?url=https://example.com&apikey=${env.APILAYER_WORLDNEWS_KEY}`,
|
|
91
|
+
method: 'GET',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'Skills API',
|
|
95
|
+
url: `https://api.apilayer.com/skills?q=machine%20learning&apikey=${env.APILAYER_SKILLAPI_KEY}`,
|
|
96
|
+
method: 'GET',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'Form API',
|
|
100
|
+
url: `https://api.apilayer.com/form_api/test`,
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: { 'apikey': env.APILAYER_FORMAPI_KEY },
|
|
103
|
+
body: JSON.stringify({}),
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
async function runTests() {
|
|
108
|
+
console.log('๐งช Testing all 14 APILayer endpoints\n');
|
|
109
|
+
|
|
110
|
+
const results: TestResult[] = [];
|
|
111
|
+
let working = 0;
|
|
112
|
+
|
|
113
|
+
for (const test of tests) {
|
|
114
|
+
try {
|
|
115
|
+
const startTime = Date.now();
|
|
116
|
+
const options: RequestInit = {
|
|
117
|
+
method: test.method,
|
|
118
|
+
headers: {
|
|
119
|
+
'Content-Type': 'application/json',
|
|
120
|
+
...(test.headers || {}),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
if ((test as any).body) {
|
|
125
|
+
options.body = (test as any).body;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const response = await fetch((test as any).url, options);
|
|
129
|
+
const responseTime = Date.now() - startTime;
|
|
130
|
+
|
|
131
|
+
const success = response.ok;
|
|
132
|
+
if (success) {
|
|
133
|
+
working++;
|
|
134
|
+
console.log(`โ
${test.name}: ${response.status} (${responseTime}ms)`);
|
|
135
|
+
} else {
|
|
136
|
+
console.log(`โ ${test.name}: ${response.status} (${responseTime}ms)`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
results.push({
|
|
140
|
+
name: test.name,
|
|
141
|
+
endpoint: (test as any).url.split('?')[0],
|
|
142
|
+
method: test.method,
|
|
143
|
+
status: response.status,
|
|
144
|
+
success,
|
|
145
|
+
responseTime,
|
|
146
|
+
});
|
|
147
|
+
} catch (err) {
|
|
148
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
149
|
+
console.log(`โ ${test.name}: ${errorMsg}`);
|
|
150
|
+
results.push({
|
|
151
|
+
name: test.name,
|
|
152
|
+
endpoint: 'ERROR',
|
|
153
|
+
method: test.method,
|
|
154
|
+
status: 'ERROR',
|
|
155
|
+
success: false,
|
|
156
|
+
responseTime: 0,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
console.log('\n' + '='.repeat(60));
|
|
162
|
+
console.log('๐ FINAL RESULTS');
|
|
163
|
+
console.log('='.repeat(60));
|
|
164
|
+
console.log(`\nโ
WORKING: ${working}/14`);
|
|
165
|
+
console.log(`โ NOT WORKING: ${14 - working}/14\n`);
|
|
166
|
+
|
|
167
|
+
const failed = results.filter(r => !r.success);
|
|
168
|
+
if (failed.length > 0) {
|
|
169
|
+
console.log('Failed services:');
|
|
170
|
+
failed.forEach(r => console.log(` โข ${r.name}: ${r.status}`));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
runTests().catch(console.error);
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
|
|
5
|
+
function loadEnv(): Record<string, string> {
|
|
6
|
+
const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
|
|
7
|
+
const content = fs.readFileSync(envPath, 'utf-8');
|
|
8
|
+
const vars: Record<string, string> = {};
|
|
9
|
+
for (const line of content.split('\n')) {
|
|
10
|
+
const match = line.match(/^([^=]+)=(.*)$/);
|
|
11
|
+
if (match) {
|
|
12
|
+
vars[match[1].trim()] = match[2].trim().replace(/^['\"]|[\"']$/g, '');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return vars;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const env = loadEnv();
|
|
19
|
+
|
|
20
|
+
const tests = [
|
|
21
|
+
{
|
|
22
|
+
name: 'ExchangeRate API',
|
|
23
|
+
url: (key: string) => `https://api.apilayer.com/exchangerate?apikey=${key}`,
|
|
24
|
+
key: env.APILAYER_EXCHANGERATE_KEY,
|
|
25
|
+
method: 'GET'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'AviationStack API',
|
|
29
|
+
url: (key: string) => `https://api.apilayer.com/aviationstack?access_key=${key}`,
|
|
30
|
+
key: env.APILAYER_AVIATIONSTACK_KEY,
|
|
31
|
+
method: 'GET'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'ScreenshotLayer API',
|
|
35
|
+
url: (key: string) => `https://api.apilayer.com/screenshot?url=https://example.com&access_key=${key}`,
|
|
36
|
+
key: env.APILAYER_SCREENSHOTLAYER_KEY,
|
|
37
|
+
method: 'GET'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Number Verification API',
|
|
41
|
+
url: (key: string) => `https://api.apilayer.com/validate?number=1234567890&access_key=${key}`,
|
|
42
|
+
key: env.APILAYER_NUMVERIFY_KEY,
|
|
43
|
+
method: 'GET'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'Email Verification API',
|
|
47
|
+
url: (key: string) => `https://api.apilayer.com/check?email=test@example.com&access_key=${key}`,
|
|
48
|
+
key: env.APILAYER_EMAILVERIFY_KEY,
|
|
49
|
+
method: 'GET'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Marketstack API',
|
|
53
|
+
url: (key: string) => `https://api.apilayer.com/eod?symbols=AAPL&access_key=${key}`,
|
|
54
|
+
key: env.APILAYER_MARKETSTACK_KEY,
|
|
55
|
+
method: 'GET'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'VAT Layer API',
|
|
59
|
+
url: (key: string) => `https://api.apilayer.com/validate?country_code=SE&access_key=${key}`,
|
|
60
|
+
key: env.APILAYER_VATLAYER_KEY,
|
|
61
|
+
method: 'GET'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'Finance News API',
|
|
65
|
+
url: (key: string) => `https://api.apilayer.com/financelayer/news?limit=5&apikey=${key}`,
|
|
66
|
+
key: env.APILAYER_FINANCENEWS_KEY,
|
|
67
|
+
method: 'GET'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Image Crop API',
|
|
71
|
+
url: (key: string) => `https://api.apilayer.com/smart_crop/url?apikey=${key}`,
|
|
72
|
+
key: env.APILAYER_IMAGECROP_KEY,
|
|
73
|
+
method: 'GET'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'Advanced Scraper API',
|
|
77
|
+
url: (key: string) => `https://api.apilayer.com/adv_scraper/scraper?url=https://example.com&apikey=${key}`,
|
|
78
|
+
key: env.APILAYER_SCRAPER_KEY,
|
|
79
|
+
method: 'GET'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'PDF Layer API',
|
|
83
|
+
url: (key: string) => `https://api.pdflayer.com/api`,
|
|
84
|
+
key: env.APILAYER_PDFLAYER_KEY,
|
|
85
|
+
method: 'POST'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'World News API',
|
|
89
|
+
url: (key: string) => `https://api.apilayer.com/world_news/extract-news?url=https://example.com&apikey=${key}`,
|
|
90
|
+
key: env.APILAYER_WORLDNEWS_KEY,
|
|
91
|
+
method: 'GET'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'Skills API',
|
|
95
|
+
url: (key: string) => `https://api.apilayer.com/skills?q=test&apikey=${key}`,
|
|
96
|
+
key: env.APILAYER_SKILLAPI_KEY,
|
|
97
|
+
method: 'GET'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'Form API',
|
|
101
|
+
url: (key: string) => `https://api.apilayer.com/form_api/test?apikey=${key}`,
|
|
102
|
+
key: env.APILAYER_FORMAPI_KEY,
|
|
103
|
+
method: 'POST'
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
async function runTests() {
|
|
108
|
+
console.log('๐งช Testing exact endpoints from execute.ts\n');
|
|
109
|
+
|
|
110
|
+
let working = 0;
|
|
111
|
+
const failed: string[] = [];
|
|
112
|
+
|
|
113
|
+
for (const test of tests) {
|
|
114
|
+
try {
|
|
115
|
+
const startTime = Date.now();
|
|
116
|
+
const url = test.url(test.key);
|
|
117
|
+
const options: RequestInit = {
|
|
118
|
+
method: test.method,
|
|
119
|
+
headers: { 'Content-Type': 'application/json' }
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const response = await fetch(url, options);
|
|
123
|
+
const responseTime = Date.now() - startTime;
|
|
124
|
+
|
|
125
|
+
if (response.ok) {
|
|
126
|
+
working++;
|
|
127
|
+
console.log(`โ
${test.name}: ${response.status} (${responseTime}ms)`);
|
|
128
|
+
} else {
|
|
129
|
+
console.log(`โ ${test.name}: ${response.status} (${responseTime}ms)`);
|
|
130
|
+
failed.push(`${test.name}: ${response.status}`);
|
|
131
|
+
}
|
|
132
|
+
} catch (err) {
|
|
133
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
134
|
+
console.log(`โ ${test.name}: ${errorMsg}`);
|
|
135
|
+
failed.push(`${test.name}: ${errorMsg}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
console.log('\n' + '='.repeat(60));
|
|
140
|
+
console.log(`โ
WORKING: ${working}/14`);
|
|
141
|
+
console.log(`โ NOT WORKING: ${14 - working}/14\n`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
runTests().catch(console.error);
|
package/test-final.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
|
|
5
|
+
function loadEnv(): Record<string, string> {
|
|
6
|
+
const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
|
|
7
|
+
const content = fs.readFileSync(envPath, 'utf-8');
|
|
8
|
+
const vars: Record<string, string> = {};
|
|
9
|
+
for (const line of content.split('\n')) {
|
|
10
|
+
const match = line.match(/^([^=]+)=(.*)$/);
|
|
11
|
+
if (match) {
|
|
12
|
+
vars[match[1].trim()] = match[2].trim().replace(/^['\"]|[\"']$/g, '');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return vars;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const env = loadEnv();
|
|
19
|
+
|
|
20
|
+
const tests = [
|
|
21
|
+
{ name: 'ExchangeRate API', key: 'APILAYER_EXCHANGERATE_KEY', url: 'https://api.apilayer.com/exchangerates_data/latest?base=USD' },
|
|
22
|
+
{ name: 'AviationStack API', key: 'APILAYER_AVIATIONSTACK_KEY', url: 'http://api.aviationstack.com/v1/flights' },
|
|
23
|
+
{ name: 'ScreenshotLayer API', key: 'APILAYER_SCREENSHOTLAYER_KEY', url: 'https://api.screenshotlayer.com/api/capture?url=https://example.com' },
|
|
24
|
+
{ name: 'Number Verification API', key: 'APILAYER_NUMVERIFY_KEY', url: 'https://api.apilayer.com/number_verification/validate?number=+1234567890' },
|
|
25
|
+
{ name: 'Email Verification API', key: 'APILAYER_EMAILVERIFY_KEY', url: 'https://api.apilayer.com/email_verification/check?email=test@example.com' },
|
|
26
|
+
{ name: 'Marketstack API', key: 'APILAYER_MARKETSTACK_KEY', url: 'http://api.marketstack.com/v1/eod?symbols=AAPL' },
|
|
27
|
+
{ name: 'VAT Layer API', key: 'APILAYER_VATLAYER_KEY', url: 'https://apilayer.net/api/validate?country_code=SE' },
|
|
28
|
+
{ name: 'Finance News API', key: 'APILAYER_FINANCENEWS_KEY', url: 'https://api.apilayer.com/financelayer/news' },
|
|
29
|
+
{ name: 'Image Crop API', key: 'APILAYER_IMAGECROP_KEY', url: 'https://api.apilayer.com/smart_crop/url' },
|
|
30
|
+
{ name: 'Advanced Scraper API', key: 'APILAYER_SCRAPER_KEY', url: 'https://api.apilayer.com/adv_scraper/scraper?url=https://example.com' },
|
|
31
|
+
{ name: 'PDF Layer API', key: 'APILAYER_PDFLAYER_KEY', url: 'https://api.pdflayer.com/api', method: 'POST' },
|
|
32
|
+
{ name: 'World News API', key: 'APILAYER_WORLDNEWS_KEY', url: 'https://api.apilayer.com/world_news/extract-news?url=https://example.com' },
|
|
33
|
+
{ name: 'Skills API', key: 'APILAYER_SKILLAPI_KEY', url: 'https://api.apilayer.com/skills?q=test' },
|
|
34
|
+
{ name: 'Form API', key: 'APILAYER_FORMAPI_KEY', url: 'https://api.apilayer.com/form_api/test', method: 'POST' },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
async function runTests() {
|
|
38
|
+
console.log('๐งช Testing all 14 APILayer services\n');
|
|
39
|
+
|
|
40
|
+
let working = 0;
|
|
41
|
+
const failed: string[] = [];
|
|
42
|
+
|
|
43
|
+
for (const test of tests) {
|
|
44
|
+
try {
|
|
45
|
+
const startTime = Date.now();
|
|
46
|
+
const key = env[test.key as keyof typeof env];
|
|
47
|
+
if (!key) {
|
|
48
|
+
console.log(`โ ${test.name}: NO KEY`);
|
|
49
|
+
failed.push(`${test.name}: NO KEY`);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const sep = test.url.includes('?') ? '&' : '?';
|
|
54
|
+
const keyParam = test.key.includes('MARKETSTACK') || test.key.includes('AVIATIONSTACK') ? 'access_key' : 'apikey';
|
|
55
|
+
const fullUrl = `${test.url}${sep}${keyParam}=${key}`;
|
|
56
|
+
|
|
57
|
+
const options: RequestInit = {
|
|
58
|
+
method: test.method || 'GET',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const response = await fetch(fullUrl, options);
|
|
62
|
+
const responseTime = Date.now() - startTime;
|
|
63
|
+
|
|
64
|
+
if (response.ok) {
|
|
65
|
+
working++;
|
|
66
|
+
console.log(`โ
${test.name}: ${response.status} (${responseTime}ms)`);
|
|
67
|
+
} else {
|
|
68
|
+
console.log(`โ ${test.name}: ${response.status} (${responseTime}ms)`);
|
|
69
|
+
failed.push(`${test.name}: ${response.status}`);
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
73
|
+
console.log(`โ ${test.name}: ${errorMsg}`);
|
|
74
|
+
failed.push(`${test.name}: ${errorMsg}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log('\n' + '='.repeat(60));
|
|
79
|
+
console.log(`โ
WORKING: ${working}/14`);
|
|
80
|
+
console.log(`โ NOT WORKING: ${14 - working}/14\n`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
runTests().catch(console.error);
|