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 🙏

© 2025 – Pkg Stats / Ryan Hefner

microcosmos.js

v0.1.0

Published

Experimental HTTP/2 API Framework

Downloads

7

Readme

MicroCosmos.JS🚀🌌

Experimental High Performance HTTP/2 API Framework For Node.js 15 (ES6)

Example Microcosmos.js Project with simple Actions and SSE

Get started:

npm install microcosmos.js --save
  • Add "type": "module" in package.json.

  • Generate local certificate for HTTP/2

    openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -keyout localhost-privkey.pem -out localhost-cert.pem
  • Create applications actions for shared actions logic /actions/ApplicationsActions.js

    import { MicroAction } from 'microcosmos.js';
    
    export default class ApplicationActions extends MicroAction {
      // Here we put common logic for our app Action Stores
    }
  • Sample Action Store: /actions/UserActions.js

    import ApplicationActions from './ApplicationsActions.js';
      
    export default class UserActions extends ApplicationActions {
      static get routeName() {
        return 'users';
      }
      
      show() {
        this.render.json({ message: 'Hello from /users/show' });
      }
    }
  • Add Following to entry point of app e.g. index.js

    import { readFileSync } from 'fs';
    import { MicroServer } from 'microcosmos.js';
      
    const cert = readFileSync('localhost-cert.pem');
    const key = readFileSync('localhost-privkey.pem');
      
    new MicroServer({ cert, key, port: 3000 }).listen();
  • run node index.js

  • go to https://localhost:3000/users/show

Actions

All Action Stores should be located within /actions folder in project root directory and lib automatically initializes them.

Routes are automatically mapped to /routeName/actionName, so if we have Action store /actions/UsersAction.js with routeName defined

static get routeName() {
  return 'users';
}

action show() defined as:

show() {
  this.render.json({ message: 'Hello from /users/show' });
}

action show() will be mapped to url: https://localhost:3000/users/show. As you can see, routeName is defined by using static getter.

Actions can be sync or async

async show() {
  const result = await someAction();
  this.render.json({ message: 'Hello from /users/show' });
}

Params

Params object can be accessed by using this.params, so if we need query urlSearchParams we access by this.params.searchParams.

Third part of the path is matched as id within params, so if we have path https://localhost:3000/users/show/42 we can access 42 by:

show() {
  this.params.id; // 42
}

On HTTP POST request we can access data by using this.params.data

async create() {
  this.params.data; // {}
}

Streamer

Microcosmos also supports Server Sent Events, and those depend on Redis. If Redis has additional configuration it should be exported as object from conifg/redis.js within project.

To join SSE: this.streamer.join('event_name', this.stream)within MicroActions Store.

Emit SSE: this.streamer.emitEvent('event_name', data)

export default class UserActions extends ApplicationActions {
  static get routeName() {
    return 'users'
  }

  // Join for SSE
  joinEvent() {
    this.streamer.join('user_event', this.stream);
  }

  // Emit SSE
  emitEvent() {
    this.streamer.emitEvent('user_event', this.params.searchParams.get('event'));
    this.render.txt('ok');
  }
}

To listen for events for 'user_event' on client side you do:

// chrome console
const event = new EventSource('/users/joinEvent');
event.onmessage = (event) => console.log(event.data);

and you can go to url: https://localhost:3000/users/emitEvent?event=helloFromUserEvent and it should output helloFromUserEvent in the console every time you hit this link.