-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
55 lines (34 loc) · 1020 Bytes
/
server.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
// Random String Generator
// Author @isaiahsaucedo
const express = require('express')
const mongoose = require('mongoose')
const session = require('express-session')
require('dotenv').config();
// server and port declaration
var app = express()
const port = process.env.PORT || 5000;
// middleware
app.use(express.json())
app.use(session({
secret: 'secret-key',
resave: false,
saveUninitialized: false,
}))
// connect to mongoDB atlas
// uncomment to connect to database
/*
const uri = process.env.ATLAS_URI;
mongoose.connect(uri, {useNewUrlParser: true, useCreateIndex: true});
mongoose.connection.once("open", () => {
console.log('Successfully connected to MemorStringDB!')
}).on("error", (error) => {
console.log('Failed to establish connection to MemorStringDB.' + error)
})
*/
// routes
const wordRouter = require('./routes/words')
app.use('/api', wordRouter)
// where the server is listening
app.listen(port, ()=> {
console.log('Sever started on port: ' + port)
})