I've written a basic node.js application, it's working on local with the command : node app.js but not in heroku here is my package.json
{
"name": "express-rest-youness",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"express": "^4.16.2",
"express-rest": "^1.0.4"
}
}
and my app.js
var express = require('express'),
expressRest = require('express-rest');
var app = express();
var rest = expressRest(app);
var records = [
{value: 'Apple'},
{value: 'Banana'}
];
rest.get('/api/food', function(req, rest) {
rest.ok(records);
});
rest.get('/api/food/:id', function(req, rest) {
var record = records[req.params.id];
if (record) rest.ok(record);
else rest.notFound();
});
rest.put('/api/food/:id', function(req, rest) {
records[req.params.id] = req.body;
return rest.accepted('/api/food/' + encodeURI(req.params.id));
});
rest.post('/api/food', function(req, rest) {
records.push(req.body);
rest.created('/api/food/' + (records.length - 1));
});
rest.delete('/api/food/:id', function(req, rest) {
delete records[req.params.id];
rest.gone();
})
app.listen(8080);
when trying to access the heroku app i get :
Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
Thanks :)