-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
39 lines (28 loc) · 859 Bytes
/
app.js
File metadata and controls
39 lines (28 loc) · 859 Bytes
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
/**
* Created by PY028031 on 10/21/2016.
*/
var express = require("express"),
mongoose = require("mongoose"),
bodyParser = require("body-parser");
var db ;
if (process.env.ENV === "Test") {
db = mongoose.connect("mongodb://localhost/bookAPI_Test");
}
else {
db = mongoose.connect("mongodb://localhost/bookAPI");
}
var Book = require("./models/bookModel");
var app = express();
var port = process.env.PORT || 3000;
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
bookRouter = require("./Routes/bookRoutes")(Book);
app.use("/api/books", bookRouter);
//app.use("/api/authors", authorRouter);
app.get('/', function (req, res) {
res.send("Welcome to my API launched from gulp!!");
});
app.listen(port, function () {
console.log("Gulp is running my app on port: " + port);
});
module.exports = app;