lightcore

A bridge for webapps.

lightcore

Convention over Configuration, simplify your code.

For expressjs.

Install

npm install lightcore

Quick start

var core = require('lightcore');
core.app.get('/', function(req, res){
    res.send('Hello World!');
}); 
core.start(); //default port 8964

Libraries

  • Based Framework: expressjs core.app
  • Template: swig core.view

Databases

Currenttly support

  • sqlite3 (core.model.sqlite)
  • mysql (core.model.mysql)
  • mongodb(mongoskin) (core.model.mongodb)
  • redis (core.model.redis)

Using db by configure it just one time, of cause you must install Modules first.

{
    "models": {
        "sqlite": "data/rss.db",
        "mysql": {
            "host": "127.0.0.1"
        }
    }
}

and now you can use it by

var core = require('lightcore')
core.model.sqlite.get("SELECT 1,2,3", function(err, result){
    console.log(result);
});    

Configure

  • IMPORTANT * Your current work directory is the base directory

put your config.json under base directory lightcore will merge your configure,default config under lightcore root directory.

{   
    "port": 8964,
    "express": {
        "disable": ["x-powered-by"],
        "enable": ["trust proxy"]
    },
    "static": {
        "/statics": "statics",
        "/css": "statics/css",
        "/js": "statics/js",
        "/img": "statics/img"
    },
    "models": {
        "sqlite": "data/rss.db",
        "mysql": {
            "host": "127.0.0.1"
        }
    }        
}

items express: auto configure your express js static: your static files,key is request path,value is the directory's path

Licence

BSD

Link

http://www.shiguanglu.com