-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
70 lines (52 loc) · 1.61 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
// Full Documentation - https://docs.turbo360.co
const vertex = require('vertex360')({ site_id: process.env.TURBO_APP_ID })
const express = require('express')
const cors = require('cors');
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const passport = require("passport");
const fs = require('fs')
const app = express() // initialize app
/* Apps are configured with settings as shown in the conig object below.
Options include setting views directory, static assets directory,
and database settings. Default config settings can be seen here:
https://docs.turbo360.co */
const config = {
views: 'views', // Set views directory
static: 'public', // Set static assets directory
logging: true,
/* To use the Turbo 360 CMS, from the terminal run
$ turbo extend cms
then uncomment line 21 below: */
// db: vertex.nedb()
}
vertex.configureApp(app, config)
// import routes
const index = require('./routes/index')
const user = require('./routes/user') // sample API Routes
// Bodyparser middleware
app.use(
bodyParser.urlencoded({
extended: false
})
);
app.use(bodyParser.json());
// DB Config
const db = require("./config/keys").mongoURI;
// Connect to MongoDB
mongoose
.connect(
db,
{ useNewUrlParser: true }
)
.then(() => console.log("MongoDB successfully connected"))
.catch(err => console.log(err));
// Passport middleware
app.use(passport.initialize());
// Passport config
require("./config/passport")(passport);
app.use(cors());
// set routes
app.use('/', index)
app.use('/api/users', user) // sample API Routes
module.exports = app