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 🙏

© 2024 – Pkg Stats / Ryan Hefner

apis.do

v2.3.3

Published

Hypermedia API Framework & Directory

Downloads

22

Readme

APIs.do - Driv.ly Workers framework

Important note:

If you don't link a CTX service worker, the API will default to fetching data from ctx.do. This means that the IP address and CF-Ray-Id headers will be incorrect for the request. If you want to use the correct IP address and CF-Ray-Id headers, you must link a CTX service worker.

Example

This example shows off the following features:

  • Automatic API documentation
  • Link generation
  • Query parameter modification
  • Query modification for multiple values (cities, zip codes, credit scores, etc.)
import { API, json, requiresAuth, modifyQuery, modifyQueryMultiple, schemaGen } from 'apis.do'

const api = new API({
  name: 'domain.do',
  description: '🤖 API'
}, {
  examples: {
    createVehicle: '/hello/0'
  }
})

api.get('/:hello/:worldNumber?', req => {
  return {
    links: {
      self: req.url,
      next: modifyQuery(req.url, { worldNumber: req.params.worldNumber + 1 }),
      'Create Plan By City': modifyQueryMultiple(req.url, 'zip', req.ctx.cities)
    },
    data: {
      hello: req.params.hello,
      worldNumber: req.params.worldNumber
    }
  }
}, {
  description: 'Hello world',
  parameters: {
    hello: 'string',
    worldNumber: 'number'
  },
  response: schemaGen({ hello: '', worldNumber: 0 })
})

export default {
  fetch: api.fetch
}

Request properties

Most of the properties are self-explanatory, but here are some modifications to the request object provided by itty-router:

  • request.user - The user object from ctx.vin
  • request.ctx - The context object from ctx.vin
  • request.waitUntil - The waitUntil function exposed by Cloudflare Workers
  • request.params - The params object from itty-router
  • request.query - The query object from itty-router
  • request.body - The body object from itty-router

Drivly Open – Accelerating Innovation through Open Source

Our Drivly Open Philosophy has these key principles:

  1. Build in Public
  2. Create Amazing Developer Experiences
  3. Everything Must Have an API
  4. Communicate through APIs not Meetings
  5. APIs Should Do One Thing, and Do It Well

🚀 We're Hiring!

Driv.ly is deconstructing the monolithic physical dealership into simple APIs enabling anyone to buy and sell cars online, and we're funded by some of the biggest names in automotive and finance & insurance

Our entire infrastructure is built with Cloudflare Workers, Durable Objects, KV, PubSub, R2, Pages, etc. If you love the Cloudflare Workers ecosystem as much as we do, we'd love to have you join our team!