Initial commit, including all apps previously in course

This commit is contained in:
Jordi Sola
2019-10-04 13:04:03 +02:00
parent a87e659954
commit f7cd8963ef
58 changed files with 2529 additions and 0 deletions

35
todoapp/nodejs_api/app.js Normal file
View File

@@ -0,0 +1,35 @@
var restify = require('restify');
var controller = require('./controllers/items');
var serverinfo = require('./controllers/serverinfo');
var db = require('./models/db');
var model = require('./models/items');
model.connect(db.params, function(err) {
if (err) throw err;
});
var server = restify.createServer()
.use(restify.fullResponse())
.use(restify.queryParser())
.use(restify.bodyParser())
.use(restify.CORS());
controller.context(server, '/todo/api', model);
serverinfo.context(server, '/todo/api');
var port = process.env.PORT || 30080;
server.listen(port, function (err) {
if (err)
console.error(err);
else
console.log('App is ready at : ' + port);
});
if (process.env.environment == 'production')
process.on('uncaughtException', function (err) {
console.error(JSON.parse(JSON.stringify(err, ['stack', 'message', 'inner'], 2)))
});