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

meteor-wapi

v0.3.1

Published

Node module to allow CQRS-ing with Meteor

Downloads

8

Readme

Build Status Coverage Status Dependency Status devDependency Status

meteor-wapi

Node module to allow CQRS-ing with Meteor.

Install

npm i --save meteor-wapi

Example

var express     = require("express");
var MongoClient = require("mongodb").MongoClient;
var MW          = require("meteor-wapi");

var mongoUrl = process.env.MONGO_URL || "mongodb://localhost:3001/meteor";

MongoClient.connect(mongoUrl, function (err, db) {
    var mw = new MW(db);
    var optionalContext = {
        prefix: "echo: "
    };
    mw.methods({
        echo: function (string) {
            return this.prefix + string;
        }
    }, optionalContext);
    var app = express()
        .use("/call", mw.getRouter())
        .listen(process.env.PORT || 4000);
});

API

new MW(db)

Creates a new MW instance.

Arguments
  • db MongoClient connection required: a mongodb connection, as returned (via callback) by the MongoClient.connect method.
Returns

An MW instance.

.methods(methodsMap, optionalContext)

Registers one or more remote methods (mimicking Meteor's API). The methods will be invoked when the client POSTs a DDP method message to the server.

Methods can either:

  • throw an error
  • return a value
  • return a promise

If the method returns a value (or an eventually fulfilled promise), the client will receive the returned (or resolved) value in the DDP response message.

If the method throws (or returns an eventually rejected promise), the client will receive the error in the DDP response message. If the error is an instance of MW.Error, its code and message will be used for the reply. Otherwise a generic 500 INTERNAL SERVER ERROR error will be used.

Arguments
  • methodsMap string-function dictionary required: a dictionary of functions (just like in Meteor).

  • optionalContext object optional: an optional object which will be mixed in with the execution context of the method (the this value).

Returns

Nothing.

.getRouter()

Returns an express router which listens for POSTed DDP method messages, authenticates them and runs the appropriate methods.

Arguments

None.

Returns

An express router (to be used as argument to an express app use method).

Test

After cloning the repository and installing dependecies with npm install:

  • to run unit tests: npm run unit-tests
  • to run integration tests: npm run integration-tests (you need a running local mongo listening on port 27017)