-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
39 lines (29 loc) · 1.03 KB
/
Copy pathserver.js
File metadata and controls
39 lines (29 loc) · 1.03 KB
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
const express = require('express');
const app = express();
const bodyParser = require("body-parser");
var mongoose = require('mongoose');
let config = ('config')
mongoose.Promise = global.Promise
if (process.env.NODE_ENV === 'test') {
mongoose.connect("mongodb://localhost:27017/applicantsTest")
} else {
mongoose.connect("mongodb://localhost:27017/applicants")
}
let Applicant = require('./app/models/applicant')
let applicant = require('./app/routes/applicant')
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || 8080;
var router = express.Router();
app.route('/applicant')
.post(applicant.postApplicant)
.get(applicant.getApplicants);
app.route('/applicant/:id')
.get(applicant.getApplicantById)
.put(applicant.updateApplicant)
.delete(applicant.deleteApplicant)
app.route('/applicant/name/:firstname')
.get(applicant.getApplicantByFirstname)
app.listen(port)
console.log("You're on localhost " + port + " and database " + process.env.NODE_ENV);
module.exports = app