-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (61 loc) · 1.54 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const express = require("express");
const session = require("express-session");
const cors = require("cors");
const https = require("https");
const fs = require("fs");
const dotenv = require("dotenv");
const usersRouter = require("./routes/users");
const cardsRouter = require("./routes/cards");
const selectionsRouter = require("./routes/selections");
require("./models");
const app = express();
app.use(express.json());
const port = 4000;
const AWS = require("aws-sdk");
dotenv.config();
AWS.config.region = process.env.AWS_CONFIG_REGION;
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: process.env.AWS_CONFIG_IDENTITYPOOLID,
});
//express-session 설정
app.use(
session({
secret: "@mohazi",
resave: false,
saveUninitialized: true,
cookie: {
domain: "localhost",
path: "/",
maxAge: 24 * 60 * 60 * 1000,
sameSite: "none",
httpOnly: true,
secure: true,
},
})
);
//cors 설정
app.use(
cors({
origin: true,
methods: ["GET", "POST", "OPTIONS", "PATCH", "DELETE", "PUT"],
credentials: true,
})
);
//router 연결 - users
app.use("/", usersRouter);
// cards
app.use("/", cardsRouter);
// selections
app.use("/", selectionsRouter);
const server = https
.createServer(
{
key: fs.readFileSync(__dirname + `/` + "key.pem", "utf-8"),
cert: fs.readFileSync(__dirname + `/` + "cert.pem", "utf-8"),
},
app
)
.listen(port, () => {
console.log(`🚀 ${port}번 포트로 서버가 연결됐습니다.`);
});
module.exports = server;