Reference Source

Design - Servers feature

Devapt provides builtin servers for common usages (Restify, Express, SocketIO).

But you can code your own server.

A server is attached to a node (a couple of hostname and port).

Description

Servers provide featured services.

Status

Express server: make middlewares use configurables.

Restify server: make middlewares use configurables, check authorizations.

Need Test, Optimization and code review.

Builtin servers

Devapt provides builtin servers for common usages. But you can code your own server.

EXPRESS

Serve static pages or middleware generated content.

RESTIFY

Serve RESTfull content.

For Devapt users:

Configure servers in nodes.json A JSON nodes servers declaration:

{
    "nodes":{
        "NodeA":{
            "host":"localhost",
            "is_master":true,
            "servers":{
                "NodeALocal8080":{
                    "type":"express",
                    "port":8080,
                    "protocole":"http",
                    "middlewares":[],
                    "use_socketio":true,

                    "security": {
                        "authentication": {
                            "enabled":true,
                            "plugins":["file_users"]
                        }
                    }
                },
                "NodeALocal8081":{
                    "type":"restify",
                    "port":8081,
                    "protocole":"http",
                    "middlewares":[],
                    "use_socketio":true,

                    "security": {
                        "authentication": {
                            "enabled":true,
                            "plugins":["file_users"]
                        }
                    }
                }
            }
        },

        "NodeB":{
            "host":"localhost",
            "is_master":false,
            "servers":{
                "NodeBLocal8080":{
                    "type":"express",
                    "port":8080,
                    "protocole":"http",
                    "middlewares":[],
                    "use_socketio":true,

                    "security": {
                        "authentication": {
                            "enabled":true,
                            "plugins":["file_users"]
                        }
                    }
                },
                "NodeBLocal8081":{
                    "type":"restify",
                    "port":8081,
                    "protocole":"http",
                    "middlewares":[],
                    "use_socketio":true,

                    "security": {
                        "authentication": {
                            "enabled":true,
                            "plugins":["file_users"]
                        }
                    }
                },
                "NodeBLocal8082":{
                    "type":"express",
                    "port":8082,
                    "protocole":"http",
                    "middlewares":[],
                    "use_socketio":true,

                    "security": {
                        "authentication": {
                            "enabled":true,
                            "plugins":["file_users"]
                        }
                    }
                },
            }
        }
    }
}

Each node contains one or more servers.

A server declaration:

"serverA2":{
    "type":"express",
    "port":8082,
    "protocole":"http",
    "middlewares":[],
    "use_socketio":true,

    "security": {
        "authentication": {
            "enabled":true,
            "plugins":["file_users"]
        }
    }
}

A server has

For Devapt contributers:

Thanks

Express

Strongloop provides a wonderfull de facto standard library, Express. It's a very popular project, used by many people.

Express

Restify

Restify helps to easily provides a RESTfull server.

Express