Skip to content

BenoitClaveau/qwebs-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qwebs-http

Http server for Qwebs Qwebs.

Features

Installation

npm install $qwebs --save
npm install $qwebs-http --save

Create a service.js

"use strict";

class Service {
	constructor() {	
};

index(request, response) {
 let content = {
  text: `hello ${request.params.name}`
 };
 return response.send({ request: request, content: content });
};

exports = module.exports = Service;

Define routes.json

{
    "services": [
        { "name": "$http", "location": "qwebs-http"},
        { "name": "$service", "location": "./service"}
    ],
    "locators": [
        { "get": "/:name", "service": "$service", "method": "index" },
    ]
}

config.json for http

{
    "routes": "./routes.json",
    "http": {
        "port": 3000
    }
}

config.json for https

{
    "routes": "./routes.json",
    "https": {
        "port": 3443
    }
}

config.json with redirection to https

{
    "routes": "./routes.json",
    "http": {
        "port": 3000,
        redirect: true
    }
    "https": {
        "port": 3443
        "key": "./certificate.key",
        "cert": "./certificate.crt",
        "ca": [
            "./certificate.interm.1.pem",
            "./certificate.interm.2.pem"
        ]
    }
}

Enjoy

Create a server.js

"use strict";

const Qwebs = require("qwebs");
new Qwebs().load();

Run server on http://localhost:3000

node server.js

About

Http server for Qwebs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published