-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
62 lines (46 loc) · 1.01 KB
/
test.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/** Messing around with what future api could look like */
// shared definitions
const usersNS = defineNamespace(t => ({
id: t.id(),
name: t.string(),
}))
const tasksNS = defineNamespace(t => ({
id: t.id(),
user_id: t.ref(usersNS),
status: t.bool(),
}))
.query(['status'])
.aggregate('count', t => t.int())
const sessionNS = defineNamespace()
const COLLECTION = defineCollection({
users: usersNS,
tasks: tasksNS,
session: sessionNS,
})
// server
const server = createServer(COLLECTION)
server.users.onList(() => {
return []
})
server.tasks.onList(() => {
return []
})
server.tasks.onGetId(() => {
return {}
})
// client
// if BE not supported
const $api = mockServeCollection(COLLECTION)
$api.users.onList(() => {
return []
})
$api.tasks.onList(() => {
return []
})
$api.tasks.onGetId(() => {
return {}
})
// could have different clients for different frameworks
const $client = createReactClient(COLLECTION, $api) // server mock is optional
$client.users.use()
$client.tasks.use()