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

helicopter

v0.1.57

Published

Web application framework

Downloads

20

Readme

Helicopter

Is a web application framework inspired by SailsJS.

Install

Install helicopter via npm.

npm install helicopter

To have nice cli binary you can also install helicpoter-cli.

npm install helicopter-cli -g

Initialize project

Initialize project with init command:

helicopter init [dir]

This command create new project with basic structure. To create project from template use create command which will download template from github or npm:

helicopter create helicopterjs/basic .

Start server

Application should be started with up command:

helicopter up [port]

Options

| Name | Desc | |:------------|:--------------------------| | v,verbose | Make output verbose. | | e,env | Specify environment name. | | d,debug | Turn debug mode on. |

Run application in development environment example.

helicopter up -e development

Run custom command

Helicopter has cli interface to provide application's api which could be called from terminal:

helicopter exec <command> -- [...args]

Arguments are parsed automatically with simplified argv parser. It uses full name arguments only like --name[=value]. Example:

helicopter exec dump -- --mongo-db=test --dir=./test/ --overwrite

Options

| Name | Desc | |:------------|:--------------------------| | v,verbose | Make output verbose. | | e,env | Specify environment name. | | d,debug | Turn debug mode on. |

Example

Commands are specified with commands method of main app class stored in app.js. This method should return dictionary of commands where key is a command name in camel case and value is object descriptor of command. This method should contains several keys: params, description and action.

Helicopter.extend({
  commands() {
    return {
      print: {
        params: '[text]',
        description: 'Print console arguments',
        action: (text) => {
          this.service('Print').print(text);
        }
      }
    };
  }
});

Filesystem layout

Default layout has 3 separated folders to separate code on levels api, config and modules. Basic example:

.
|-- api
|   |-- controllers
|   |   `-- main-controller.js
|   |-- events
|   |   `-- main-events.js
|   |-- models
|   `-- services
|   |   `-- print-service.js
|-- config
|   |-- app.js
|   |-- development
|   |   `-- app.js
|   |-- events.js
|   |-- http.js
|   |-- production
|   `-- routes.js
|-- modules
|-- app.js
`-- package.json

But you can choose your own layout system with overwriting core modules configuration.

Controllers

Usually controllers stored in api/controllers directory in files with postfix -controller.js. Each controller file should export an object which methods will be used as http methods. Routes could be configured manually in config/routes.js file and could differ for different environments.

Controller example.

// config/routes.js
exports.routes = {
  'GET /hello' : {
    method: 'test.hello'
  }
};

// api/controllers/test.js
module.exports = {
  hello(req, res) {
    res.end('Hello world');
  }
};

Controller method also could be a generator thus it will be wrapped with co. Web controller could return promise and it's result will be used as http output. Each return result will be wrapped with customization responses (sendData and sendError).

Responses

HTTP-interface supports custom response system to provide wide functionality. There is two ways of using responses: manual in the code res.notFound() or automatically by router which will run methods res.sendError if controllers method returns instance of error and res.sendData when method returns an object.

Response file exports factory which returns new method. Example:

// responses/not-found.js
module.exports = function(req, res) {
  return function (message) {
    this.status(404)
      .end(message || 'Nothing found');
  };
};

NOTE! Responses shares scope with whole api directory. See wide scope.

Wide scope

Helicopter use it's own require mechanism which share scope of all files from api directory and allows to avoid mess of requires or other tricks with using initialized modules. This way controllers could access to services by it's name.

Example.

// services/print-service.js
module.exports = function () {
  return {
    print: function (msg) {
      console.log(msg);
    }
  }
};

Using of print service in controller:

// controllers/print-controller.js
module.exports = {
  print (req, res) {
    PrintService.print(req.body);
    res.end();
  }
};

Misc

Bitdeli Badge