1const express = require('express'),
2 app = express(),
3 bodyParser = require('body-parser');
4 port = process.env.PORT || 3000;
5
6
7const mysql = require('mysql');
8// connection configurations
9const mc = mysql.createConnection({
10 host: 'localhost',
11 user: 'root',
12 password: '',
13 database: 'mydb'
14});
15
16// connect to database
17mc.connect();
18
19app.listen(port);
20
21console.log('API server started on: ' + port);
22
23app.use(bodyParser.urlencoded({ extended: true }));
24app.use(bodyParser.json());
25
26var routes = require('./app/routes/approutes'); //importing route
27routes(app); //register the route
28