Have ideas to improve npm?Join in the discussion! »

    sutro-client
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.4 • Public • Published

    sutro-client NPM version Downloads Build Status

    A simple and sugary client for using sutro APIs.

    Install

    npm install sutro-client --save
    

    Example

    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 Output

    import 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()
    */

    Install

    npm i sutro-client

    DownloadsWeekly Downloads

    37

    Version

    3.0.4

    License

    MIT

    Unpacked Size

    62.7 kB

    Total Files

    23

    Last publish

    Collaborators

    • avatar