Skip to content

Commit 56bc66d

Browse files
committed
add missing petstore file for demo dashboard
1 parent bbc211c commit 56bc66d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { on } from 'mokapi';
2+
import { fake } from 'mokapi/faker'
3+
4+
export default function() {
5+
on('http', (request, response) => {
6+
if (request.operationId === 'getUserByName') {
7+
8+
const username = request.path.username;
9+
console.log(`[HTTP] Incoming request → GET /user/${username}`);
10+
console.log(`[HTTP] Operation matched: getUserByName`);
11+
console.log(`[Script] Looking up user: "${username}"`);
12+
13+
if (users.has(username)) {
14+
console.log(`[Script] ✓ User found`);
15+
response.data = users.get(request.path.username);
16+
} else {
17+
console.log(`[Script] ✗ User not found → returning 404`);
18+
response.statusCode = 404
19+
}
20+
}
21+
})
22+
}
23+
24+
const users = new Map([
25+
['bmiller', {
26+
id: fake({ type: 'integer', format: 'int64' }),
27+
username: 'bmiller',
28+
firstName: 'Bob',
29+
lastName: 'Miller',
30+
31+
password: 'mysecretpassword123',
32+
phone: fake({ type: 'string', pattern: '(?:(?:\\+|0{0,2})91(\\s*[\\- ]\\s*)?|[0 ]?)?[789]\\d{9}|(\\d[ -]?){10}\\d' }),
33+
userStatus: 1
34+
}]
35+
]);

0 commit comments

Comments
 (0)