# nodeframe

> A modular web application framework based-on popular node technologies (express, swig and etc.).

Latest version **0.2.0** (published 2015-01-15) · 0 weekly downloads

## Install

```sh
npm install nodeframe
pnpm add nodeframe
yarn add nodeframe
bun add nodeframe
```

Provides the command `noding`.

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-01-15 |
| First published | 2014-01-06 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 33 |
| Known vulnerabilities | 0 (+33 in 11 direct dependencies) |
| Install scripts | no |
| Maintainers | rockie |
| Keywords | website, builder, express, bootstrap, swig |

## Links

- npm: https://www.npmjs.com/package/nodeframe
- Repository: https://github.com/kitmi/nodeframe
- Issues: https://github.com/kitmi/nodeframe/issues
- npm.io page: https://npm.io/package/nodeframe

## Dependencies (33)

- [acl](https://npm.io/package/acl.md) 0.4.2
- [swig](https://npm.io/package/swig.md) 1.2.2
- [async](https://npm.io/package/async.md) 0.7.0
- [mysql](https://npm.io/package/mysql.md) 2.5.4
- [moment](https://npm.io/package/moment.md) 2.6.0
- [string](https://npm.io/package/string.md) 1.8.0
- [wechat](https://npm.io/package/wechat.md) 0.6.6
- [xmldom](https://npm.io/package/xmldom.md) 0.1.19
- [express](https://npm.io/package/express.md) 4.5.0
- [mongodb](https://npm.io/package/mongodb.md) 1.4.0
- [request](https://npm.io/package/request.md) 2.34.0
- [shortid](https://npm.io/package/shortid.md) 2.0.1
- [winston](https://npm.io/package/winston.md) 0.7.3
- [fs-extra](https://npm.io/package/fs-extra.md) 0.10.0
- [uid-safe](https://npm.io/package/uid-safe.md) 1.0.1
- [ttl-cache](https://npm.io/package/ttl-cache.md) 1.0.2
- [underscore](https://npm.io/package/underscore.md) 1.6.0
- [body-parser](https://npm.io/package/body-parser.md) 1.4.3
- [compression](https://npm.io/package/compression.md) 1.0.8
- [stack-trace](https://npm.io/package/stack-trace.md) 0.0.9
- [buffer-crc32](https://npm.io/package/buffer-crc32.md) 0.2.3
- [errorhandler](https://npm.io/package/errorhandler.md) 1.1.1
- [serve-static](https://npm.io/package/serve-static.md) 1.3.0
- [winston-mail](https://npm.io/package/winston-mail.md) 0.2.7
- [connect-mongo](https://npm.io/package/connect-mongo.md) 0.4.1
- [cookie-parser](https://npm.io/package/cookie-parser.md) 1.3.2
- [event-emitter](https://npm.io/package/event-emitter.md) 0.2.2
- [random-string](https://npm.io/package/random-string.md) 0.1.1
- [connect-timeout](https://npm.io/package/connect-timeout.md) 1.2.1
- [express-session](https://npm.io/package/express-session.md) 1.6.3
- [express-winston](https://npm.io/package/express-winston.md) 0.2.6
- [winston-mongodb](https://npm.io/package/winston-mongodb.md) 0.4.3
- [shorter-mongo-id](https://npm.io/package/shorter-mongo-id.md) 0.0.2

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2015-01-15
- 0.1.2 — 2014-06-15
- 0.1.1 — 2014-04-04
- 0.1.0 — 2014-03-28
- 0.0.9 — 2014-03-09
- 0.0.8 — 2014-03-06
- 0.0.7 — 2014-02-26
- 0.0.6 — 2014-02-21
- 0.0.5 — 2014-02-11
- 0.0.3 — 2014-01-16
- 0.0.2 — 2014-01-13
- 0.0.1 — 2014-01-06

## README

# Nodeframe

  A modular web application framework based-on popular node technologies (express, swig and etc.).

## License

  MIT

## Latest version

  0.2.0
  
---

## Quick Start

### 1). Bootstrapping nodeframe.

1. Write a "package.json" file as below.

        {      
            "name": "Project Name",  
            "version": "0.0.1",  
            "private": true,  
            "scripts": {  
                "start": "node app-server.js"  
            },  
            "dependencies": {  
                "nodeframe": "*"  
            }  
        }  

2. Run "npm install" under the same directory with "package.json".

3. Write a "app-server.js" file as below.

        require('nodeframe').start();

4. Run "node app-server.js".

5. Try visit http://localhost:3000

### 2). Create a new web module.

1. Create a module directory "hello_nodeframe" under the "web_modules" directory which is automatically created by previous operations.

2. Write a "bootstrap.js" as below under the newly created directory.

        module.exports = {

            version: '0.0.1', // the version of the new module

            routes: { // routes settings

                '/': {
                    rule: { // router type, currently supports rule/mvc/rest
                        rules: { // required for rule based router
                            '/': { // sub-path
                                get: 'home.index' // http method and controller action
                            }
                        }
                    }
                }

            }
        };

3. Create a controllers directory "controllers" under the "hello_nodeframe" directory.

4. Write the controller file "home.js" as below under the "controllers" directory.

        module.exports = {
            index: function (router) { // controller action

                router.appendViewData({
                    title: 'Hello nodeframe!'
                });

                // to render "index" view template, modify router.view to render other template
                router.renderResponse();
            }
        };

5. Create a views directory "views" under the "hello_nodeframe" directory.

6. Write the view template "home_index.swig" as below under the "views" directory.

        {{ title }}

7. Update the "etc/development.js" file that generated by 1) as below to enable the new module.

       module.exports = {

           modules: {
               hello_nodeframe: {
                   route: '/hello' // can be whatever path you want, e.g. /test, /module1
               }
           }
       };

8. Run "node app-server.js" again.

9. Try visit http://localhost:3000/hello

### 3). Create a wechat module.

1. Create a module directory "hello_wechat" under the "web_modules" directory.

2. Write a "bootstrap.js" as below under the "hello_wechat" directory.

        module.exports = {

            version: '0.0.1', // the version of the new module

            routes: { // routes settings

                '/': {
                    rule: { // router type, currently supports rule/mvc/rest
                        
                        rules: { // required for rule based router
                            '/': 'wechat.service'
                        }
                    }
                }

            },
            
            middlewares: {
		        'wechat': {
		            token: 'your_wechat_token_here'
		        }
		    }
        };

3. Create a controllers directory "controllers" under the "hello_wechat" directory.

4. Write the controller file "wechat.js" as below under the "controllers" directory.

        module.exports = {
            service: function (router) {
		        var message = router.req.weixin;
		
		        if (message.MsgType === 'event') {
		
		            if (message.Event === 'subscribe') {
		                return router.res.reply('Welcome to subscribe!');
		            }
		
		            return router.res.reply('I am fine.');
		        }
		
		        if (message.MsgType === 'text') {
		            return router.res.reply(message.Content);
		        }
		
		        router.res.reply('Hi');
		    }
		};

5. Update the "etc/development.js" file that generated by 1) as below to enable the new module.

       module.exports = {

           wechat: {},

           modules: {
               hello_nodeframe: {
                   route: '/hello' // can be whatever path you want, e.g. /test, /module1
               },
               
               hello_wechat: {
                   route: '/wechat' // can be whatever path you want, e.g. /test, /module1
               }
           }
       };

6. Run "node app-server.js" again.

7. Try visit http://localhost:3000/wechat, and you should see "invalid signature".

8. Now you can use this web module as the back-end application to serve wechat request. (PS: Wechat requires the service to listen on 80 port.)

---
_Source: https://npm.io/package/nodeframe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
