Stormpath wth Openshift has bad route

31 Views Asked by At

This setup is as follows:

Openshift gear with a nodejs component. npm install express body-parser express-stormpath --save. Server will run if you comment out the Stormpath calls/usage.

#!/bin/env node --harmony
// File: server.js
var fs      = require('fs');
var express = require('express');
var bparser = require('body-parser');
var stormpath = require('express-stormpath');

var app = express();
  // Log access URLs
  app.use(function (req, res, next) {
    console.log(req.url);
    next();
  });

  // Default response
  app.get('/', function(req, res){
    res.send('<h2>Ghostfacers</h2>');
  });

  // Stormpath ApiKey,Secrct,etc set in environment
  var baseFile = __dirname + '/index.html';
  app.use(stormpath.init(app, {
    web: {
      spa: { enabled: true, view: baseFile }
    }
  }));
var port = process.env.OPENSHIFT_NODEJS_PORT;
var addr = process.env.OPENSHIFT_NODEJS_IP;

app.on('stormpath.ready',function() {
  app.listen(port,addr, function() {
    console.log('%s: Started %s:%d ...',
      Date(Date.now() ),addr,port);
  });
});

Errors in the nodejs log:

TypeError: Property 'route' of object function router(req, res, next) {
    router.handle(req, res, next);
  } is not a function at Function.proto.(anonymous function) [as get]...
  ...
  lib/router/index.js:509:22
  at addGetRoute ... lib/stormpath.js:137:14
1

There are 1 best solutions below

0
On

After a good nights sleep and a cup of coffee I was able to get past this issue by using express version 4.x instead of version 3.x. I will submit a ticket to Stormpath to state this dependency.