npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

caraml

v0.1.5

Published

Generate SDK from RAML documentation

Readme

caraml

Generates an optimized SDK from a RAML specification. Works with modern browsers and node.

Usage and Documentation

Install with: npm install -S caraml or yarn add caraml

import caraml from 'caraml'

// ---------- OPTIONS ----------
const options = {
  // Path to root RAML file
  apiPath: './api.raml',
  // Parameters in base URI - version is auto-included
  baseUriParameters: {
    region: 'se01'
  },
  // Headers to send with every request unless overridden
  defaultHeaders: {
    Authorization: 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
  },
  // Prefix on resources when naming collisions occur
  overridePrefix: '$'
}

// ---------- RESOURCES ----------
const { resources } = caraml(options)

// The resources object contains the top-level RAML resources (lower cased)
const { users } = resources

// Nested resources are properties of the parent resource
users.me // = /users/me

// Add uri-parameters by calling the resource with parameters
users(42) // = /users/42
users({ id: 42 }) // = /users/42 (route is /users/{id})
users({ username: 'alladin' }) // = /users/alladin (route is /users/{username})

// Use above in combination to reach any resource
users(42).messages(1).attachments // = /users/42/messages/1/attachments

// ---------- METHODS ----------
// Methods are functions that return promises
const query = 'query=string' || { query: 'parameters' }
const data = { json: 'data' }
// GET
users.get(query, options)
users.find(query, options)
// POST
users.post(data, query, options)
users.create(data, query, options)
// PUT
users.put(data, query, options)
users.update(data, query, options)
// PATCH
users.patch(data, query, options)
// DELETE
users.delete(query, options)
users.remove(query, options)

// Methods are available on resources according to spec
users(42).messages.post(data) // = POST /users/42/messages

// Prefix nested resources with overridePrefix when collisions occur
users(42).$find.find(query) // = GET /users/42/find?query=string
users(42).find(query) // = GET /users/42?query=string

Examples

Using async/await (recommended)

const message = { text: 'Brevity is the soul of wit' }

async function spreadMessage () {
  const allUsers = await users.find()
  for (let user of allUsers) {
    await users(user.id).messages.create(message)
  }
}

Using promises

function spreadMessage () {
  return users.find().then(allUsers => {
    allUsers.reduce((promise, user) => {
      return promise.then(() => users(user.id).messages.create(message))
    }, Promise.resolve())
  })
}

TODO

  • [ ] Write tests for methods
  • [ ] Support for types
    • [ ] Wrap responses in type
  • [ ] Make optimizations to nested resource creation when calling with parameters
  • [ ] Improve comments/documentation
  • [ ] Custom error classes

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D