Skip to content

Node.js, Faster, cheaper, better web framework for Node.js

License

Notifications You must be signed in to change notification settings

breadkingdom/dp-node

 
 

Repository files navigation

THIS PROJECT IS UNDER DEVELOPMENT, DO NOT USE IN PRODUCTION.

dp-node

NPM Version NPM Downloads Dependency Status Linux Build Windows Build

Faster, cheaper, better web framework for Node.js, built on top of express.

Installation

$ npm install dp-node

Features

  • Focus on faster development.
  • Async/Await ready.

Quick Start

Directory Structure

App
 ├─ controller
 │  ├─ foo
 │  │  ├─ bar
 │  │  │  └─ index.js
 │  │  └─ index.js
 │  ├─ bar
 │  └─ index.js
 ├─ model
 │  ├─ foo
 │  │  ├─ bar
 │  │  │  └─ index.js
 │  │  └─ index.js
 │  ├─ bar
 │  └─ index.js
 ├─ view
 │  ├─ foo
 │  │  ├─ foo.html
 │  │  └─ bar.html
 │  ├─ bar
 │  │  └─ baz.html
 │  └─ index.html
 └─ index.js

Controller

App/controller/foo/bar/index.js / http://localhost/foo/bar

module.exports = {
    get: async (controller) => {  // `controller` parameter is required.
        /*
         *  `controller` exports: {
         *     raw: {
         *        req: return express `req` object.
         *        res: return express `res` object.
         *     }
         *     model: return model accessor
         *     session: return model accessor
         *     params: (key, isURL)
         *     headers: (key)
         *     redirect: (url, statusCode)
         *     render: (view, params)
         *     finish: (body)
         *     finisher: {
         *        notfound: (body)
         *        invalid: (body)
         *        error: (body)
         *     }
         *     finishWithCode: (code, body)
         *  }
         */

        var arg1 = 10;
        var arg2 = 20;
        var res = controller.model.foo.bar.add(arg1, arg2);  // == 30

        var params = {
            arg1: arg1,
            arg2: arg2,
            res: res
        };

        await controller.render('foo/foo.html', params);
    }
};

Model

App/model/foo/bar/index.js / model.foo.bar

module.exports = {
    add: (db, arg1, arg2) => {  // `db` parameter is required.
        /*
         *  `db` exports: {
         *     knex: (dsn)
         *     row: (query, params, dsn)
         *     rows: (query, params, dsn)
         *     execute: (query, params, dsn)
         *     tran: (blocks, dsn)
         *  }
         */

        return arg1 + arg2;
    }
};

View

App/view/foo/foo.html / foo/foo.html

<p>{{arg1}} + {{arg2}} = <strong>{{res}}</strong></p>

Install

$ npm install dp-node

Dependencies

License

MIT

About

Node.js, Faster, cheaper, better web framework for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.7%
  • CSS 1.3%