Socket
Socket
Sign inDemoInstall

dp-node

Package Overview
Dependencies
468
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dp-node

Faster, cheaper, better web framework for Node.js


Version published
Weekly downloads
5
increased by150%
Maintainers
1
Install size
21.7 MB
Created
Weekly downloads
 

Readme

Source

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

  • Rapid prototyping
  • 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 = {
    async get() {
        /*
         *  `this` 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 = this.model.foo.bar.add(arg1, arg2);  // == 30

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

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

Model

App/model/foo/bar/index.js / model.foo.bar
module.exports = {
    add(arg1, arg2) {
        /*
         *  `this` exports: {
         *     knex: (dsn)
         *     row: (query, params, dsn)
         *     rows: (query, params, dsn)
         *     execute: (query, params, dsn)
         *     tran: (blocks, dsn)
         *  }
         */

        return arg1 + arg2;
    }
};

Helper

App/helper/foo/bar/index.js / helper.foo.bar
module.exports = {
    add(arg1, arg2) {
        /*
         *  `this` exports: helpers
         */

        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

Keywords

FAQs

Last updated on 19 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc