-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathapp.js
36 lines (29 loc) · 743 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mysql = require('mysql');
var port = 8080;
// models
var models = require("./models");
// routes
var books = require('./routes/books');
//Sync Database
models.sequelize.sync().then(function() {
console.log('connected to database')
}).catch(function(err) {
console.log(err)
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
// register routes
app.use('/books', books);
// index path
app.get('/', function(req, res){
console.log('app listening on port: '+port);
res.send('tes express nodejs mysql')
});
app.listen(port, function(){
console.log('app listening on port: '+port);
});