forked from NodPay/NodPayServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (31 loc) · 1.25 KB
/
index.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
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config();
}
//development branch
const express = require('express');
const app = express();
const port = process.env.PORT || 8080;
const authRouter = require('./Controllers/AuthController');
const transactionRouter = require('./Controllers/TransactionController');
const mongoose = require('mongoose');
// Connect Database
mongoose.connect(`mongodb+srv://${process.env.DB_USER}:${process.env.DB_PASSWORD}@spotme.lidfh.mongodb.net/${process.env.DB_NAME}?retryWrites=true&w=majority`, {useNewUrlParser: true});
mongoose.set('useFindAndModify', false);
//firebase connection
const FireBase_Admin = require('firebase-admin');
const FireBase_Credentials = require('./spotme-nod-firebase-adminsdk-3ks6g-e3edbc0182.json')
FireBase_Admin.initializeApp({
credential: FireBase_Admin.credential.cert(FireBase_Credentials)
})
// Body parser
app.use(express.json({limit: '50mb'}));
app.use(express.urlencoded({limit: '50mb', extended: true}));
// Routes
app.use('/auth', authRouter);
app.use('/transaction', transactionRouter);
app.get('/', (req, res) => {
res.send({message: 'Welcome to the SpotMe BackEnd'});
});
// Port listening
app.listen(port, () => console.log(`Listening on port ${port}`));
module.exports = app;