venustech-node-server
Venustech frontend server. Based on Nodejs.
Last updated a year ago by zuoez02 .
ISC · Original npm · Tarball · package.json
$ cnpm install venustech-node-server 
SYNC missed versions from official npm registry.

@venustech/server

build-status

Venustech frontend server based on Express.

In order to make it easy to manage so many service, we decide to make server as a indsividual package.

How to use

First install the package with npm install --save @venustech/server to install the server in the project. Then create a Server object in the start script. To start it successfully, you need some required config. And you can add external modules or routers on the server.

  • configPath(required) The config file path for default config loader
  • componentsList(required) The client app components list for html5mode support
  • webpackConfig(required) A method with return a webpack config object for optimize. We will pass config object as the first argument to the function.
  • externalModules
  • externalRouters

External Modules

The externalModules should be an array of custom modules. You can define your own module and the server will load it before optimize and http server started. Such as:

const externalModule = function(server, config, app) {
    /**
        server: The Venustech server object
        config: The server configs object. Use get() or set() to use it.
        app:    The Express app
    /
}

Every module will run asynchronously with the order of the externalModules array. So pay attention to the order of loaded modules.

External Routers

The externalRouters should be an array of custom routers. You can create your own router. Here is an example:

const createRouter = require('@venustech/server').createRouter;

const router = createRouter();

router.on('/example', (req, res, next) => {
    res.send('This is an example of external router');
});

module.exports = router;

The express app will run in the default router on express app. They will create with the order of routers. Be careful.

Current Tags

  • 0.3.13                                ...           latest (a year ago)

1 Versions

  • 0.3.13                                ...           a year ago

Copyright 2014 - 2017 © taobao.org |