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

evented.io

v0.1.4

Published

Evented.io is a realtime API server.

Downloads

2

Readme

Evented.IO

Evented.IO is a Node.JS module that provides a structured way of building RESTful API servers in combination with Websockets (Using Socket.IO) writen in CoffeScript.

The reason why I've created Evented.IO is because I like another framework called MeteorJS, but meteor is a full-stack framework. I needed the flexibility of an express.js server with the ease of use of a MeteorJS Server.

Also, Evented.IO provides a client-server JavaScript API to work with collections in realtime, in Meteor flavor. The API will result familiar to you even if you have used Firebase.

I wanted to construct AngularJS applications and mobile native applications using those kind of API's and being compleit enough to make whatever you want, having all control over your server.

I've used deployd for example, but I don't like the idea of for example, can't login by default using an OAuth provider. You have to figure out how to implement it. Evented.IO is compatible with everything, so you can implement it your way maybe using.... ¿Passport?

That said, let's provide a little of light over the table.

How to Install

In order to instantiate a new server you need to have running an instance of MongoDB and another of a Redis store

Configure a new server

evented = require 'evented.io'

Evented = evented({port: 5000});

Models and Controllers

You should have 2 folders on your server's root directory:

  • 'models' directory
  • 'controllers' directory

Checkout the examples to know how to write new models and controllers to create RESTful routes

Creating a new model

This is not the real User model implementation, we need password salting and those things, but this will give you an idea. Default Modules are loaded into process.modules

This is the default schema for a model.

 # Model Structure

 mongoose = process.modules.mongoose
 validate = process.modules.validate

 animalSchema = mongoose.Schema
  
   name:
      type: String
      required: true
      unique: true
      validate: validate('len', 5, 10)

   kind:
      type: String
      required: true
      enum: ['cat', 'dog']

 # Animal model
 module.exports = mongoose.model('Animal', animalSchema);  

Creating a new controller

 # Animals controller

 Animal = process.server.mongodb.models.Animal

 getAllAnimals =
    method: 'get'
    path: "/animal"
    version: 1 # Here we specify the version http://api.server.com/v1/animals
    description: 'Get all Animals'
    docURL: '/AnimalController#GET_ALL_ANIMAL_ACTION' # Documentation URL
    params:
    	# you can specify required or optional fields
        required: [] 
        optional: []
        
    # Also allowed user kinds and roles
    allowedUserKinds: []
    roles: []
    callback: (req, res, completeCall) ->

        Animal
        .find()
        .exec (err, animals)->

            if err
                return next
                	 # Send this data structure
                    httpStatus: 500 # There was an error
                    metadata: err

            completeCall({animals: animals})
            
 module.exports = ->
 	
 	# Here is where we export our Restfull API's
 	
 	[getAllAnimals]

Custom Databases

To use custom databases into your server do the next thing:

Your node index.js

Evented = evented({
  port: 5000,
  mongo: {
    host: 'localhost'
    password: '27017'
    db: 'testdb'
    user: ''
    password: ''
  },
  redis: {
    host: 'localhost'
    port: '6379'
    password: ''
  }
});

Configure a new client

You should use this two scripts in your header

<head>
	<script src="socket.io/socket.io.js"></script>
	<script src="evented.js"></script>
</head>

TODO

  • Describe API
  • UserCollection documentation
  • Evented API
  • Collections
  • Pub/Sub
  • process new API's (server, redis, mongoDB, etc...)
  • Evented.Collection
  • Evented.Collections
  • Evented.suscribe
  • Evented.publish