This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
52 lines (41 loc) · 1.44 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
40
41
42
43
44
45
46
47
48
49
50
51
52
const express = require('express');
const getPort = require('get-port');
const https = require('https');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const cors = require('cors');
global.config = require('./config');
global.mongodb = true;
mongoose.connect(global.config.database,
{
useNewUrlParser: true
}).
catch(error => function(error) {
global.mongodb = false;
console.log('Error connecting to MongoDB');
console.log('-------------------------------------');
console.log(error);
});
const app = express();
const environment = process.env.NODE_ENV || 'development';
let port;
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
port = process.env.API_PORT || config.port || 80;
app.get('/', require('./functions/Misc/status'));
const User = require('./models/User');
const Profile = require('./models/Profile');
const Link = require('./models/Link');
const Theme = require('./models/Theme');
const Visit = require('./models/Visit');
app.use('/user', require('./functions/User'));
app.use('/profile', require('./functions/Profile'));
app.use('/link', require('./functions/Link'));
app.use('/theme', require('./functions/Theme'));
app.use('/analytics', require('./functions/Analytics'))
app.listen(port, () => {
console.log(`🔗 Singlelink API listening on port ${port}`)
})