Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…
| var mbaasApi = require('fh-mbaas-api'); | |
| var express = require('express'); | |
| var mbaasExpress = mbaasApi.mbaasExpress(); | |
| var cors = require('cors'); | |
| // list the endpoints which you want to make securable here | |
| var securableEndpoints; | |
| securableEndpoints = ['/hello']; | |
| var app = express(); | |
| // Enable CORS for all requests | |
| app.use(cors()); | |
| // Note: the order which we add middleware to Express here is important! | |
| app.use('/sys', mbaasExpress.sys(securableEndpoints)); | |
| app.use('/mbaas', mbaasExpress.mbaas); | |
| /* uncomment this code if you want to use $fh.auth in the app preview | |
| * localAuth is only used for local development. | |
| * If the app is deployed on the platform, | |
| * this function will be ignored and the request will be forwarded | |
| * to the platform to perform authentication. | |
| app.use('/box', mbaasExpress.auth({localAuth: function(req, cb){ | |
| return cb(null, {status:401, body: {"message": "bad request"}}); | |
| }})); | |
| or | |
| app.use('/box', mbaasExpress.core({localAuth: {status:401, body: {"message": "not authorised”}}})); | |
| */ | |
| // allow serving of static files from the public directory | |
| app.use(express.static(__dirname + '/public')); | |
| // Note: important that this is added just before your own Routes | |
| app.use(mbaasExpress.fhmiddleware()); | |
| app.use('/hello', require('./lib/hello.js')()); | |
| // Important that this is last! | |
| app.use(mbaasExpress.errorHandler()); | |
| var port = process.env.FH_PORT || process.env.OPENSHIFT_NODEJS_PORT || 8001; | |
| var host = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; | |
| app.listen(port, host, function() { | |
| console.log("App started at: " + new Date() + " on port: " + port); | |
| }); |