generated from ibm-developer-skills-network/coding-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
/
app.js
42 lines (26 loc) · 1.24 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
const express = require('express');
const jwt = require('jsonwebtoken');
const session = require('express-session');
const path = require('path');
const mongoose = require('mongoose');
const app = express();
const PORT = process.env.PORT || 3000;
const SECRET_KEY = 'your_secret_key';
mongoose.set('strictQuery', false);
const uri = "mongodb://root:<replace password>@localhost:27017";
mongoose.connect(uri,{'dbName':'SocialDB'});
const User = mongoose.model('User', { username: String, email: String, password: String });
const Post = mongoose.model('Post', { userId: mongoose.Schema.Types.ObjectId, text: String });
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(session({ secret: SECRET_KEY, resave: false, saveUninitialized: true, cookie: { secure: false } }));
// Insert your authenticateJWT Function code here.
// Insert your requireAuth Function code here.
// Insert your routing HTML code here.
// Insert your user registration code here.
// Insert your user login code here.
// Insert your post creation code here.
// Insert your post updation code here.
// Insert your post deletion code here.
// Insert your user logout code here.
app.listen(PORT, () => console.log(`Server is running on port ${PORT}`));