A brief and clear explanation of how we configure the app.js file and whether we need to require parse-server in it is needed basically. Which files should and shouldn't be related with each other?
For example this is the main.js file where a simple Cloud Code function is defined:
Parse.Cloud.define('hello', function(request, response){
response.success('Hello world.');
}, function(error){
response.error(error);
});
So how should the app.js file be configured in order to run that Cloud Code function?
var path = require('path');
var bodyParser = require('body-parser');
var index = require('./routers/index');
app.set('views', path.join(__dirname, '/views'));
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use('/', index);
app.listen();
The above code example of an app.js file doesn't require and has no configuration of parse-server, does it need to?
var express = require('express');
var route = express.Router();
route.get('/', function(req, res){
Parse.Cloud.run('hello').then(function(r){
res.send(r);
}, function(error){
res.status(400).send(error);
});
});
module.exports = route;
The above code example of a call in routers/index.js file to a Cloud Code function doesn't work. Is it because the file should require the main.js file or not?
Simple examples of app.js and routers/index.js files will suffice and be deeply appreciated.