@sap/xsodata
Version:
Expose data from a HANA database as OData V2 service with help of .xsodata files.
49 lines (41 loc) • 1.51 kB
JavaScript
;
var http = require("http");
var path = require('path');
var logger = require('<winston_api_like_logger>');
var xsOData = require('./../../../index');
logger.level = 'warn';
//Webserver configuration
var webServerPort = 8019;
var hostPortName = "localhost:" + webServerPort;
//OData handler configuration
var configuration = {
//Here serviceConfiguration points to a single directory: so the first uri segment behind the port
//must contain the name of the xsodata file to use. E.g. for name demo.xsodata:
//http://localhost/demo.xsodata/$metadata
"serviceConfiguration": path.join(__dirname, "services/demo.xsodata"),
"defaultSchema": 'REFSCENARIO',
"dbConfiguration": {
"host": "<your host>",
"port": 1234,
"user": "<your user>",
"password": "<your password>"
},
"logger": logger
};
//Instantiate ODataHandler
var handler = new xsOData.ODataHandler(configuration);
var webServer = http.createServer(function (request, response) {
if (request.url.indexOf("favicon.ico") === -1) {
try {
handler.processRequest(request, response, null, function done() {
console.log("processed request " + request.url);
});
} catch (ex) {
console.log(ex);
}
}
});
webServer.listen(webServerPort, function () {
console.log("Listen on localhost:" + webServerPort);
console.log("Service url for demo : http://" + hostPortName + '/?$format=json');
});