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

ng2-mock-server

v0.0.4

Published

Mock HTTP backend that runs in the browser to develop front-ends without back-ends.

Readme

ng2-mock-server

An angular2+ mock XHRBackend to ease front-end development when no real back-end is available.

  • No need to run a back-end on the dev machine.
  • Easy to show off a front-end from static servers like GitHub Pages, etc.
  • Easy to implement back-end functionality that runs in the browser. When the back-end is ready, just remove it and it's using the back-end with no changes in your application code.
  • Works with Angular 2 and Angular 4.

Getting started

npm install ng2-mock-server [--save | --save-dev]

In your main module file (other mandatory parts like Component-declarations omitted):

import { MockRouteInitializer } from './mock-route-initializer';
import { NgModule } from '@angular/core';

import { MockServerModule, RouteInitializer } from 'ng2-mock-server';
import { HttpModule } from '@angular/http';

@NgModule({
    imports: [
        HttpModule,
        MockServerModule
    ],
    providers: [
        { provide: RouteInitializer, useClass: MockRouteInitializer }
    ]
})
export class AppModule {
}

MockRouteInitializer is where you define your mock-routes:

import { RouteInitializer, MockSrvRouter, json, res } from 'ng2-mock-server';
import { ResponseOptions } from '@angular/http';

export class MockRouteInitializer implements RouteInitializer {

    initialize(r: MockSrvRouter): void {
        r.get("/hello", (req : Request, ...params : string) {
           return res(200, "world");
        });

        r.get("/hello/:name", (req : Request, name : string) {
            return res(200, name);
        });
    }
}

Development and running the example project

For development and running the example project, clone this repo, make the desired changes and:

# 1. build and link the module:
./buildAndLink.sh

# 2. use the linked module and start the example:
cd example
npm link ng2-mock-server
npm start

You can also use buildAndRunExample.sh to do all those steps at once

Changelog

0.0.4

  • ng2-mock-server now works with Angular 2 (Release Version) and 4
  • This update is contributed by Dominik Schlosser. Thank you for the pull request!

0.0.3

  • Fixed #3, a bug where onComplete callbacks weren't called after a request.
  • Make router.setup(r => {...}) the default way of setting up the routes to eliminate the call to r.ready(). This is backwards-compatible so if you're not using router.setup() and call router.ready(), everything will work just fine.

0.0.2

  • Updated code to Angular2 RC 1.
  • Thanks Stephan Beal for the code!

0.0.1

Initial release.

Contributions

Please create issues with bug reports, feature requests or asking for help.

Pull requests more than welcome.

Licence

Released under the MIT Licence.