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

v0.1.2

Published

Library for creation web and websocket restful APIs

Downloads

2,237

Readme

Features

  • units-based modular architecture
  • loader
    • provides multiple running modes
      • provides app console
    • brings app parts together automatically
  • flexible settings system
  • advanced routing with contracts/resources
  • ability to start multiple servers
    • allows to listen multiple ports, support HTTP+HTTPS, IP4+IP6, etc.
  • cluster support
  • domain support
  • integrated daemonization
  • logging
  • multiple transports support:
    • websockets
    • JSONP
    • batch requests
  • CORS-enabled
  • number of useful handlers, including:
    • authentication
    • data parsing and validation
    • response serialization and validation
    • static files handling
  • client libs for node.js and browser

Security Note

All apis resources are by default fully CORS and JSONP available. You must use CSRF protection for all your authenticated requests (even for GET requests) and apis supports such protection by default too. Optionally, you can check Origin of your requests or disable CORS/JSONP functionality (completely or for choosen request handlers).

By default, apis philosophy is to allow cross-origin requests and be ready for them.

Also, by default, every resource will have 'options' handler providing resource description and it will not be protected by authentication or something. You can allways override this handler with null or your own variant.

Handlers

Handler interface:

  • setup(chain) - can be used to perform some interaction between handlers of chain, used by Impl and Ret
  • handle(ctx) - async handle, must not throw any exceptions, use ctx.error() instead, usually must call ctx.next() at some point

Test page

To get test page on /test_page add to your contract:

cont('/test', [apis.testPage.contract])

Apps known by Loader

  • app - app itself, will be searched at cwd()+'/lib/app'
  • cluster_master - cluster master app, will be searched at cwd()+'/lib/claster_master'
  • daemon_master - daemon start/stop app, will be searched at cwd()+'/lib/daemon_master'

For any app, if it cannot be found, apis default will be used.

Units known by Loader

  • core.app - known by app actually (which also is loader), the app itself

  • core.uncaught - uncaught exception handler

  • core.logging - logging subsystem

    • core.logging.engines.syslog - syslog logging engine
  • core.mechanics.web - web mechanics, enables responding on HTTP requests

  • core.mechanics.socket - socket mechanics, enables web socket communications, runs on top of web mechanics

    • core.mechanics.socket.stat - web socket statistics
  • core.settings - settings, will be searched at cwd()+'/lib/settings'

  • core.handler - main app contract, will be searched at cwd()+'/lib/contract'

For both core.settings and core.handler units, if unit cannot be found, apis default will be used.

REST notes

  • stateless all the way
  • GET must be cacheable !!!
    • think about url & args, how to provide cacheable structure
  • PUT vs POST
    • PUT is safe to repeat (example: update something)
    • POST is not safe to repeat - can create copies (example: create)
  • DELETE is safe to repeat (just ensures that it's deleted)

License

MIT