Hello,
I have two files :
* server.js which is my main app :

/**
 * Created by IOSoftwareSAS on 25/08/15.
 */
var loopback = require('loopback');
var boot = require('loopback-boot');

//SSL configuation
var http = require('http');
var https = require('https');
var sslConfig = require('./ssl-config');
var options = {
    key: sslConfig.privateKey,
    cert: sslConfig.certificate
};

var app = module.exports = loopback();

// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname);

app.start = function(httpOnly) {
    if(httpOnly === undefined) {
        httpOnly = process.env.HTTP;
    }
    var server = null;
    if(!httpOnly) {
        var options = {
            key: sslConfig.privateKey,
            cert: sslConfig.certificate
        };
        server = https.createServer(options, app);
    } else {
        server = http.createServer(app);
    }
    server.listen(app.get('port'), function() {
        var baseUrl = (httpOnly? 'http://' : 'https://') + app.get('host') + 
':' + app.get('port');
        app.emit('started', baseUrl);
        console.log('LoopBack server listening @ %s%s', baseUrl, '/');
    });
    return server;
};

app.use('/express-status', function(req, res, next) {
    res.json({ running: true });
});

// start the server if `$ node server.js`
if (require.main === module) {
    app.start();
}


and another js file called config.local.js that versions API :

var p = require('../package.json');
var version = p.version.split('.').shift();
module.exports = {
    restApiRoot: '/api' + (version > 0 ? '/v' + version : ''),
    host: process.env.HOST || 'localhost',
    port: process.env.PORT || 3000
};


module.exports = function(server) {
    // Install a `/` route that returns server status
    var router = server.loopback.Router();
    router.get('/index.html', server.loopback.status());
    server.use(router);
};



Could anyone help me having the parsing of package.son integrated in 
server.js so I would have https://..../api/V2/ ...

Many thanks and sorry for my low knowledge of JS.

Philippe
 

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/18115ab4-05a1-4038-94af-8b7ddfeb287a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to