0.1.3 • Published 12 years ago

lightcore v0.1.3

Weekly downloads
1
License
BSD
Repository
github
Last release
12 years ago

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

auto controllers

put js under controllers directory, and exports a class a example wrote in coffee script, test.coffee:

class test
    get: (req, res)->
		res.send 'test'
	post: (req, res)->
		res.send 'post test'
		
module.exports.route = {
	"/": test,
	"/test2": test
}

auto hooks

put js under hooks directory, and exports a function a example wrote in coffee script, test.coffee:

push = (arc)->
    #TODO: PUSH
    console.log 'Push article to remote:',arc.title
exports.hook =
    new_article: push

You should fire an event 'new_article'

lightcore.execHook 'new_article', articleObj

lightcore.execHook(event_name, params)

Licence

BSD

Link

http://www.shiguanglu.com

Project@Github

0.1.8

12 years ago

0.1.7

12 years ago

0.1.6

12 years ago

0.1.5

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago