A simple and sugary client for using sutro APIs.
npm install sutro-client --save
sutro
Server{
user: {
create: async ({ data }) => User.create(data),
find: async ({ options }) => User.findAll(options),
findById: async ({ userId }) => User.findById(userId),
updateById: async ({ userId, data }) => User.updateById(userId, data),
replaceById: async ({ userId, data }) => User.replaceById(userId, data),
deleteById: async ({ userId }) => User.deleteById(userId),
friend: {
create: async ({ userId, data }) => {
const me = await User.findById(userId)
await me.addFriend(data)
return me
},
find: async ({ userId, options }) => {
const me = await User.findById(userId)
return me.findFriends(options)
},
findById: async ({ userId, friendId }) => {
const me = await User.findById(userId)
return me.findFriendById(friendId)
}
}
}
}
sutro-client
Outputimport client from 'sutro-client'
const api = client(server.meta)
/*
All functions return promises:
api.user.create()
api.user.find()
api.user.findById()
api.user.updateById()
api.user.replaceById()
api.user.deleteById()
api.user.friend.create()
api.user.friend.find()
api.user.friend.findById()
*/
Generated using TypeDoc