Esempio n. 1
0
module.exports = function(app) {
  console.log(auth.isAuthenticated())
  // Insert routes below
  app.use('/api/ticTacToeGames', auth.isAuthenticated(), require('./api/ticTacToeGame'));


  app.use('/api/customDataInstances', require('./api/customDataInstance'));
  app.post('/api/customDataInstance', auth.isAuthenticated());
  app.put('/api/customDataInstance', auth.isAuthenticated());
  app.delete('/api/customDataInstance', auth.isAuthenticated());

  app.use('/api/customDataSchemas',auth.isAuthenticated(), require('./api/customDataSchema'));
  app.post('/api/customDataSchema', auth.isAuthenticated());
  app.put('/api/customDataSchema', auth.isAuthenticated());
  app.delete('/api/customDataSchema', auth.isAuthenticated());
  app.use('/api/things', require('./api/thing'));
  app.use('/api/users', require('./api/user'));

  app.use('/auth', require('./auth'));
  //app.all('/api/*', auth.isAuthenticated());
  app.use('/api', mers({
    mongoose: mongoose
  }).rest())
  
  // All undefined asset or api routes should return a 404
  app.route('/:url(api|auth|components|app|bower_components|assets)/*')
   .get(errors[404]);

  // All other routes should redirect to the index.html
  app.route('/*')
    .get(function(req, res) {
      res.sendfile(app.get('appPath') + '/index.html');
    });
};
Esempio n. 2
0
module.exports = function (app) {


/*
    // Server API Routes
    app.get('/api/promotions', promotions.list);
    app.post('/api/promotions', promotions.create);
    app.post('/api/promotions/:id', promotions.show);


    app.post('/api/session', session.login);
    app.del('/api/session', session.logout);

    // All undefined api routes should return a 404
    app.get('/api/*', function (req, res) {
        res.send(404);
    });
*/

    app.post('/api/session', session.login);
    app.del('/api/session', session.logout);

    app.post('/api/users', users.create);
    app.put('/api/users', users.changePassword);
    app.get('/api/users/me', users.me);
    app.get('/api/users/:id', users.show);

    app.use('/api', mers({mongoose: mongoose}).rest());

    // All other routes to use Angular routing in app/scripts/app.js
    app.get('/partials/*', index.partials);
    app.get('/*', middleware.setUserCookie, index.index);
};
    BufferedJSONStream.apply(this, arguments);
}
util.inherits(RestLikeJSONStream, BufferedJSONStream);
//overwrite format;
RestLikeJSONStream.prototype.format = function(send){
    return JSON.stringify(send.payload);
}

app.use(methodOverride());
app.use(bodyParser());
app.use(allowCrossDomain);
app.use(express.static(path.join(__dirname, '../bower_components/')));
app.use(express.static(path.join(__dirname, '../lib/')));
app.use(express.static(path.join(__dirname, '../dist/')));
app.use(express.static(path.join(__dirname, '../app')));
app.use('/api',mers({responseStream: RestLikeJSONStream, uri:'mongodb://localhost/goalfactor_db'}).rest());
//app.use(express.static(path.join(__dirname, '../example')));
app.use(errorHandler({
    dumpExceptions: true,
    showStack: true
}));

/*
facultyAPI.addResource({
  app: app,
  resourceName: 'systems',
  collection: db.system
});

facultyAPI.addResource({
  app: app,
Esempio n. 4
0
File: app.js Progetto: tompi/evently
  app.use(express.urlencoded());
  app.use(express.methodOverride());
  app.use(express.cookieParser() );
  app.use(express.session({secret: config.sessionSecret}));
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(express.compress());
  app.use(app.router);
  app.use(express.static(path.join(__dirname, '../client')));
});

app.configure('development', function(){
  app.use(express.errorHandler());
});


var mongo = require('./mongo.js');
var mers = require('mers');
var mc = config.mongodb;
var dbUri = process.env.MONGOHQ_URL;
if (!dbUri) dbUri = 'mongodb://' + mc.user + ':' + mc.password + '@' + mc.host + '/' + mc.db;

app.use('/api/v1', mers({ uri: dbUri }).rest());

var userService = require('./userService')(app.locals.mers.conn);
auth.init(app, config, passport, userService);

http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});