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

airlane

v0.2.1

Published

airlane is micro service framework with express.

Downloads

6

Readme

Airlane

Airlane is the fast and confortable development environments with Node.js and Express. From micro service to more big services.

Features

  • Routing
  • Database with O/R mapper (Sequelize)
    • Support PostgreSQL/MySQL/SQLite3/MS SQL
  • Each routing has own View, Routing and Controller
  • Session
  • Code generator
    • Initialize
    • Controller
    • Model
  • Support ES2015
    • Server side
    • Web Browser
  • Development server
    • Chrome inspector
    • Auto reload
    • Auto re-deploy
  • Watchify
    • Client side JavaScript
    • Client side Stylesheet
  • Test
    • Including Mocha

Install

npm install airlane -g

Samples

Usage

cd some/path
airlane init app # Your application name
cd app
airlane serve

Open http://localhost:8080/

Constructors

Airlane generates those files.

  • config.js is development configures.
  • module contains database model, libraries.
  • routes contains controller, router, javascript, stylesheets, and views.
  • tmp is for temporary files like session database.

Default router supports below. It's simple RESTful.

  • GET /
  • GET /new
  • GET /:id/edit
  • POST /
  • PUT /:id
  • DELETE /:id

Add new routes.

When you add new routes like /users, you should enter command below.

$ airlane generate route users

Airlane generates those files.

$ tree .
.
├── routes
│   ├── users
│   │   ├── controller.js
│   │   ├── index.js
│   │   ├── public
│   │   │   ├── app.css
│   │   │   └── app.js
│   │   └── views
│   │       ├── edit.jade
│   │       ├── index.jade
│   │       └── new.jade

Each route has own View, Routing and Controller inside routes directory. After generating, you have those routes.

  • GET /users
  • GET /users/new
  • GET /users/:id/edit
  • POST /users
  • PUT /users/:id
  • DELETE /users/:id

Modules

Airlane has no module generator yet. You can make files like this.

modules/
└── db
    ├── index.js
    └── user.js

Airlane read every modules under modules directory. Each module has sub directory like db and there is index.js. Airlane import index.js.

index.js

let fs = require('fs');
let target_dir = fs.realpathSync('./');

module.exports = (options) => {
  let models = {};
  fs.readdir(`${target_dir}/modules/db`, (error, files) => {
    files.forEach((file, i) => {
      if (file.match(/^\./)) {
        return;
      }
      if (file === 'index.js')
        return;
      if (!file.match(/.*\.js$/))
        return;
      file = file.replace(/\.js$/g, "");
      models[file.capitalize()] = require(`./${file}`)(options)
    })
  });
  return models;
}

user.js:

// var sequelize = require('../../libs/database');
var crypto = require("crypto");

module.exports = (options) => {
  var database = options.database;
  var Sequelize = database.Sequelize;
  var db = database.database;

  var User = db.define('users', {
    id: {
      type: Sequelize.INTEGER,
      autoIncrement: true,
      primaryKey: true
    },
    name: {
      type: Sequelize.STRING
    },
    :
  }, {
    freezeTableName: true
  });

  User.role = 'User';
  return User;
}

Airlane supports Sequelize for O/R mapping. And you can use modules in router like this.

router.get('/new', (req, res, next) => {
  console.log(req.app.airlane.modules); // All modules
  console.log(req.app.airlane.modules.find('User')); // Get user module. You decide it with module's role like User.role = 'User';
  controller.new(req, res, next);
});

TODO

  • [ ] Generate module
  • [ ] Sample code
  • [ ] Test system

LICENSE

MIT License