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

ramlocker

v0.1.11

Published

Express server that serves mocked RAML endpoints

Downloads

6

Readme

RAMLocker

Construct a mock Express HTTP server based on a spec set out in RAML v0.8 files.

Quickstart

How to use on your project

To install ramlocker on your project, we recommend using NPM

npm install --save-dev ramlocker

You can then require the file into your file using your package manager of choice and start the server using the function this returns. On large projects, it can take a while to parse the RAML and construct the endpoints so this is an asynchronous process, that exposes a promise you can use to capture the server if, say, you want to shut it down.

let app;
const ramLocker = require('ramlocker');

ramLocker($PORT, $PATH_TO_RAML).then(server => {
    app = server;
});

How to develop on this project

Check out the code. The first time you do this you will need to install the dependencies

npm install

We currently have some smoke tests to ensure we don't break the fundamental HTTP requests. More tests are definitely on the todo list! You can run these using

gulp test

We'll use a fairly standard pull request model if you want to submit back to the project

API

ramlocker(port, pathToRaml) : Promise(Server)

The global export is a function that takes a port to run the server on, and a path to your raml directory. It will search at this level for RAML documentation.

It returns a promise that will resovle to an http.Server object.

TODOs

Functionality

  • HTTP methods that are not GET or POST
  • Custom HTTP status codes
  • Mock response based on schema (using fakerJS) if no example is presented
  • Wildcard content-types (application/*)
  • Validation of request bodies against schema (for non-GET requests)
  • Validate URL parameters based on data types
  • Allow any RAML that fits v0.8 schema, not just those which are defined according to the motivating project schema

Technically

  • More granular e2e tests + unit tests
  • Linter
  • Run tests on check-in
  • Move RAML parsing to a stream-based API to prevent passing all routes across in one promise