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

axolot

v0.2.5

Published

API-driven framework for building realtime apps.

Downloads

18

Readme

Axolot

http://devalien.github.io/Axolot/ for documentation

Axolot (Another node.js framework?)

I needed something similar to sails.js but that I could update, for example, socket.io and it was much simpler, without having everything out of the box. So I basically took out everything I liked about it and made a smaller version with some different features.

Get Started

Basic Tutorial

Axolot comes bundled with a command line tool which can be used to easily create a new project

$ npm install axolot -g
$ axolot new demoproject
$ cd demoproject

Once you are in the folder of your project, you will have a simple structure

  • api - Folder containing basically all your code (controllers, models, services, etc.)
  • config - Folder containing various configuration files
  • app.js - Your entry point

To start the app you have 2 different ways use gulp, which is good in development since it will restart when you edit a file, or simply use npm start

Models

For the models I choose to use Waterline from the guys of sails.js I find it simple to use and it does the job. Basically you can add a model inside the folder api/models.

Example api/models/user.js

    module.exports = {

        identity: 'user'
        attributes: {
            username: { type: 'string', required: true },
            password: { type: 'string', minLength: 6, required: true },
            // Lifecycle Callbacks
            beforeCreate: function(values, next) {
                bcrypt.hash(values.password, 10, function(err, hash) {
                    if(err) return next(err);
                    values.password = hash;
                    next();
                });
            }
        }
    };

If you don't know how Waterline works you can refer to their documentation: https://github.com/balderdashy/waterline-docs

Controllers

Controllers is where you define your endpoints (routing). A Controller can be associated with a model, and in this way, the CRUD operations will be there automatically, but you can always override them. Controllers are stored in api/controllers

Controllers can also have socket.io methods which are callable from socket.io-client with `controllername:method``

Example api/controllers/user.js

    module.exports = {
        model: 'user', // We are attaching the user to the model, so CRUD operations are there (good for dev purposes)
        path: '/user', // Tthis is the end point

        actions: {
            'get /': [
                function (req, res) {
                    var query = {};

                    Model.user.find(query).then(function(user) { // Find from the User Model declared above
                        res.send(user);
                    }).catch(function (err){
                        res.send(400, err);
                    });
                }],
        },
        sockets: {
            getSingle: function(userId, cb) { // This one is callable from socket.io using "user:getSingle
                Model.user.findOne(userId).then(function(user) {
                    cb(user)
                }).catch(function (err){
                    cb({error: err})
                });
            }
        }
    };

Services

Services are simply some support objects that can help us doing something. For example we could create a service to send emails. Services are accessible globally through the variable Service and are stored in api/services.

Example api/services/mailer.js which will be callable from Service.mailer.send

    var nodemailer = require('nodemailer');

    module.exports = {

        /**
         * Sends an email to a given recipient
         * @method send
         * @param {object}   email           an object containing all of the necessary data to email
         * @param {Function} cb[err, res]    the callback to call once email is sent, or if it fails
         * @return
         */
        send: function (email, cb) {
            var config = this.config;
            /** sets up the modemailer smtp transport */
            var transport = nodemailer.createTransport(config.nodemailer.type, {
                service: config.nodemailer.service,
                auth: {
                    user: config.nodemailer.user,
                    pass: config.nodemailer.pass
                }
            });

            /** sets up the mail options, from and such like that **/
            var from = email.from || '[email protected]';
            var subject;
            if (config.nodemailer.prependSubject) {
                subject = config.nodemailer.prependSubject + email.subject;
            } else {
                subject = email.subject;
            }

            var mailOptions = {
                from: email.name + '<' + from + '>',
                to: email.to,
                subject: subject,
                html: email.messageHtml
            };

            /** Actually sends the email */
            transport.sendMail(mailOptions, function (err, response) {
                if (err) return cb(err);
                return cb(null, response);
            });
        }
    };

Config

Configuration can be separated by environments

CLI

With the CLI you can create new projects and you can access an interactive console, loading your code as well. This is good for testing something and/or debugging.

To generate a new project is pretty easy, after you created it you can mode into that folder (same name of the project) and start coding.

$ axolot new projectName

To enter in the interactive console, you have to be in the folder of an axolot project. You can select the environment (which is basically the config filename).

$ axolot console environment

More commands will comoe shortly.

Support & Contact

You can drop me an email at [email protected] or ask a question in StackOverflow or simply open an issue on GitHub.com

More updats will come soon.