-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.ts
32 lines (26 loc) · 791 Bytes
/
demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Stubsy } from './dist';
const stubsy = new Stubsy();
stubsy.registerEndpoint('books', {
path: '/books',
status: 200,
type: 'get',
responseBody: [{ title: 'Divine reality' }, { title: 'The sealed nectar' }],
});
stubsy.registerOverride('books', 'error', {
status: 404,
responseBody: { message: 'resource not found' },
});
stubsy.registerOverride('books', 'outage', {
status: 500,
responseBody: { message: 'server outage' },
});
stubsy.activateOverride('books', 'error');
stubsy.registerEndpoint('magazines', {
path: '/magazines',
status: 200,
type: 'get',
responseBody: [{ title: 'Divine reality' }, { title: 'The sealed nectar' }],
});
stubsy.app.listen(3000, () => {
console.log('The Stubsy UI can be accessed on http://localhost:3000/Stubsy');
});