forked from tylerasai/ResumeX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
77 lines (49 loc) · 1.69 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require('dotenv').config();
const pg = require('pg');
const Client = pg.Client;
const axios = require('axios');
var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
var cors = require('cors');
const connectionString = `postgres://${process.env.DB_USER}:${process.env.DB_PASS}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}?sslmode=disable` ;
const db = new Client({connectionString: process.env.DB_URL || connectionString});
db.connect(() => {
console.log('successfully connected to db');
});
var keywordsRouter = require("./routes/keywords");
var softSkillsRouter = require("./routes/softskills");
const dbHelpers = require('./db/helpers/dbHelpers')(db);
var app = express();
app.use(cors());
app.use(express.static("./resumex/build"));
const port = process.env.PORT || 3005
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use('/api/keywords', keywordsRouter(dbHelpers));
app.use('/api/softskills', softSkillsRouter(dbHelpers));
app.post('/api/jobs', (req, res) => {
axios.post("https://jooble.org/api/8f8d03fd-afc8-4740-b314-bb413140ac4f", {
"keywords": req.body.keywords,
"location": req.body.location,
"page": "1"
})
.then(response => {
// return response.data.jobs;
res.send(response.data.jobs)
})
.catch((error) => {
console.error(error);
res.status(500);
res.send("THERE HAS BEEN AN ERROR");
})
// .then(setJobPosting);
})
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'resumex','build', 'index.html'));
});
app.listen(port);
module.exports = app;