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

cs

v1.0.3

Published

ES6-based framework for Node.js

Downloads

293

Readme

Cornerstone

Web framework built on Node.js.

This node framework is a production-ready Node.js framework that takes advantage of ECMAScript 6 features through the use of 6to5. It is built on top of Express.

View the docs on controllers and views.

Requirements

Installation

The idea here is that you have your app in development on Git. Then you'll clone or deploy to your production server, and run CS in production mode.

Development

> npm install -g cs
> cs init {{appname}}
> npm install
> cs run

Production

See production docs.

Running

Development

> cd {{app dir}}
> cs run

Production

See production docs.

Config

config.json
  • you can make any arbitrary config entries you want
  • if you want comments or logic in the config file, you need to change it from .json to .js and then module.exports the object. module.exports = { ... }
  • Anything outside of the env key is the default. Everything inside the env key will overwrite those depending on the enviroment you run in. You run different arbitrary enviroments via cs run [myapp] [env]
{
	"name": "appname",
	"port": "8000",
	"session": "redis",
	"debug": false,
	"db": {
		"adapter": "mongodb",
		"mongodb" : {
			"host": "mongodb://localhost:27017/sixtyvocab"
		}
	},
	"env": {
		"production": {
			"port": 80
		},
		"development": {
			"debug": true
		}
	}
}

Directory Structure

./controllers
./models
./public
./private
./views
./services
  • ./public is your web root. All static files, js, css, images, etc. go here.
  • ./private is where you put things to be compiled such as stylus, coffeescript, or ES6 files. By default, stylus files will compile and minify files into public/css automatically.
  • ./services is the location of all services which are basically CS extended functionality

Debugging

  • To run in debug mode, run > node index or > node index development (development is the default environment).
  • ./app.log is a log of all database queries.
  • In a view you have {{log variable}} to log a hbs variable to the node console
  • In a view you have {{log variable client=true}} to log a hbs variable to the browser console
  • log() is a convenient alias to console.log.
  • In the browser, CS is made global.
    • CS.private -- all variables available to your view that you passed
    • CS.public -- variables available to your JS files in CS.public
    • CS.session -- the session (which is available in your view)
    • CS.server -- server vars (which are available in your view)

Utilities

Include

// include and compile a template
var compiledHTML = app.util.include("path/to/file")(data);

Services

Services are a way to share complete parts of CS that are just arbitrary functions.

Create a service

  • Create services/yourservice/index.js
  • Create a package.json defining your attributes and dependecies
  • make sure your file module.exports = ...
  • You can export anything. A function, class an object.

Sample service package.json for gmail service

{
	"name": "gmail",
	"version": "1.0.0",
	"description": "Gmail SMTP sending",
	"main": "gmail.js",
	"keywords": ["gmail","email","smtp"],
	"author": "ConnectAi",
	"license": "BSD-2-Clause",
	"dependencies": {
		"emailjs": "~0.3.5"
	}
}

Currently the services package.json don't do anything

ES6 Goodies

Read about the cool stuff ES6 can do you for you

Dictionary

  • Controllers

    • are objects.
    • The object's keys are Routes.
    • These routes are string that have Tokens "/:token1/:token2".
    • The functions in controllers are called Actions, which handle what happens for the specified route.
    • The tokens are matched and passed as Params in the actions
      • "/:token1/:token2"(req, res, next, param1, param2) {}
      • "/:id/:username?"(req, res, next, id, username) {}
  • Views

    • Are any HTML or hbs file. They can be included, compiled or parsed. You can put them in folders to organize. Views are rendered with a layout which is just another view defined in res.layout.