-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
56 lines (43 loc) · 1.49 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const mongoose = require('mongoose');
let config;
if (process.env.NODE_ENV == 'test') {
config = require('./config/testing');
} else {
config = require('./config/database');
}
mongoose.connect(config.database);
mongoose.connection.on('connected', () =>
console.log('DATABASE CONNECTED: ' + config.database)
);
mongoose.connection.on('error', err => console.log('DATABASE ERROR: ' + err));
// init express
const app = express();
// routes
const skillSearch = require('./routes/tsq/skillSearch');
const userSkillData = require('./routes/tsq/skillsUser');
const healthCheck = require('./routes/tsq/healthCheck');
// port variable
const port = 4000;
// middleware
app.use(cors());
app.use(bodyParser.json());
app.use('/tsq/skills', skillSearch);
app.use('/tsq/skills/users', userSkillData);
// console.log('healthCheck: ', healthCheck);
app.use('/tsq/healthCheck', healthCheck);
// app.get('/healthCheck', (req, res) => res.send('por que no tengo comida'));
// app.use('/healthCheck', (req, res) => {
// console.log('tsq health check');
// res.writeHead(201);
// res.write('200 found');
// res.end();
// // res.send('woo hoo');
// });
// route settings
app.get('/', (req, res) => res.send('Hello from TSQ!'));
// tell app to listen on the port
app.listen(port, () => console.log('Server started on port ' + port));
module.exports = app;