How to deploy Trireme project on Apigee using Apigeetool

Discussão em 'StackOverflow' iniciado por fdantas, Julho 22, 2016.

  1. fdantas

    fdantas Administrator Moderador

    I have design a data layer API to establish openedge database connection using trireme-jdbc. The code is working solid when I am running the file by trireme command using cygwin, but when I start the complete project through apigeetool using command 'a127 project start' then it throws some error regarding trireme. I have used generic-pool package for database connection pooling along with trireme-jdbc.Below is the file that is running my trireme but not by a127. This is a apigee API so folder structure is totally as per apigee standard and swagger is also used here.

    var a127 = require('a127-magic');
    var express = require('express');
    var Pool = require('generic-pool').Pool;
    var jdbc = require('trireme-jdbc');
    var app = express();

    module.exports = app; // for testing



    // initialize a127 framework
    a127.init(function(config) {

    // include a127 middleware
    app.use(a127.middleware(config));

    var pool = new Pool(
    {
    name : 'Suppllier Collaboration - @Anil',
    create : function(callback) {
    var connOpenedge = new jdbc.Database(
    {
    url : 'jdbc:datadirect:eek:penedge://serverhost:portno;DatabaseName=xxxxx',
    properties : {
    user : 'db_user',
    password : 'db_password',
    },
    });
    callback(null, connOpenedge);
    },
    destroy : function(client) {
    client.end();
    },
    max : 10,
    min : 2,
    idleTimeoutMillis : 30,
    log : true

    });

    // error handler to emit errors as a json string
    app.use(function(err, req, res, next) {
    console.log('we are just enter in app.js file');

    if (typeof err !== 'object') {
    // If the object is not an Error, create a representation that appears to be
    err = {
    message: String(err) // Coerce to string
    };
    } else {
    // Ensure that err.message is enumerable (It is not by default)
    Object.defineProperty(err, 'message', { enumerable: true });
    }

    // Return a JSON representation of #/definitions/ErrorResponse
    res.set('Content-Type', 'application/json');
    res.end(JSON.stringify(err));
    });

    pool.acquire(function(err, conn) {
    if (err) {
    throw err;
    } else {
    app.get("/getData", function(req, res) {
    conn.execute('select * from "po" where "po-num" = ? and "vend-num" = ? ',
    [4322452, 4301170 ], function(err, result, rows) {

    if (err)
    res.json("Sorry !Error to get data from symix....");

    else
    res.json(rows);
    });

    });
    }
    });


    var ip = process.env.IP || 'localhost';
    var port = process.env.PORT || 10010;
    // begin listening for client requests
    app.listen(port, ip);
    console.log('we are inside app.js file');
    console.log('try this:\ncurl http://' + ip + ':' + port + '/hello?name=Scott');
    });

    Continue reading...

Compartilhe esta Página