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

easy-web-framework

v0.1.1

Published

A simple and easy to use web framwork

Readme

easy-web-framework

This software is depricated, do not use it.

It may be rewritten next year (2020), but I promise nothing

This is a simple and easy to use web framework, for learning some basic uses of a web server. It will try to let the web server developer only write the most important code and fix everything else automatically.

This framework could be used to test your ideas or to learn some basics of programing a web server, but consider rewriting your web server if you want to use it for something else. See below for a list of helpful packages that we are using in this web framework.

Have fun!

Usage

Add this package to “dependencies” in your package.json file. Then install it with the following command:

 npm install

Create a new file for your web server and add the following line:

require(“easy-web-framework”)();

Then use the global define router functions or the options functions to add behavior to the server. You can use the aiding functions described below for logging and database management.

A the end of the file written:

start(serverCallback)

The serverCallback function should be declared as follow:

function () {
  // Your code here, will be run before server start.
}

Observe that the start function could take various configurations as parameters.

start({“port”:1337}, serverCallback);

Or use a path to a json file containing the configuration.

start(“relative/path/to/config.json”, serverCallback);

Start the server by:

  nodejs server.js

To stop the server use Ctrl-c on Linux, Mac or other POSIX system.

You can also add option to the server to configure it. To see which options that exist use following command:

  nodejs server.js -h

The options can also be used to configure the program, see above. Nice to have options is:

  • -p To set the port for the server.
  • -v Display usefull information about the web server.
  • -d Display debug information.

Option functions

option(name, short, description, default,number_of_arguments, group)

Define an option for the program. The options will be found in a object called options.

Router functions

get(url, webCallback)

This function will listen to any requst for url and then call the webCallback function. Which will have this form:

function (result, options) {
    // Your code
  result(“What you will send back to the client.”);
}

The options.param argument is set to the web parameters send by the client. The options.url argument is set to the url used to request the function.

Aiding functions

query(sql, queryCallback)

This function will do a query against a database if a database connection is defined by configurations or options to the server. The queryCallback function should be declared as follows:

function (answer) {
  // Your code here.
}

The answer argument is a list of rows from the query. If the query fail for any reason the answer have the value of false.

template(data, filePath, templateCallback)

This function will read a file from filePath and render it with the mustache template system using data. The templateCallback function should be declared as follows:

function(page) {
  // Your code here.
}

The page argument is a string containg the result of the rendering from data and file.

trace(text)

debug(text)

info(text)

log(text)

warning(text)

error(text)

fatal(text)

A logger that will log a text depending on log level and message type.

Tests

Coming soon.

Contributing

Suggestions, comments and pull request would be very welcome.

Package

  • express for web server.
  • mustache for template.
  • yargs for options parsing.
  • mysql for connecting to a mysql database.

License

Copyright © 2017-2019 by Magnus Kronnäs, you can use it under the GNU General Public License Version 3 (GPL). The license is for you own protection so you do not do anything stupid.

Release History

This list will not contain information about releases with only small bug fixes.

  • 0.1.0 2019-06-22 Fixed a bug with mariadb for me, but it could break things on other systems. Marked the software as depricated.
  • 0.0.5 Added cookies, session and escaping
  • 0.0.3 Added template functions and more options.
  • 0.0.1 Initial release