-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredirect-server.js
More file actions
66 lines (51 loc) · 1.67 KB
/
Copy pathredirect-server.js
File metadata and controls
66 lines (51 loc) · 1.67 KB
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
const express = require('express')
const app = express()
const session = require('cookie-session')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser');
app.set('view engine', 'ejs')
app.use(express.static(`${__dirname}/static`))
app.use(express.urlencoded({ extended: false }))
app.use(bodyParser.urlencoded({ extended: true }))
app.set('etag', false)
app.use((req, res, next) => {
res.set('Cache-Control', 'no-store')
next()
})
app.use(cookieParser());
require('dotenv').config()
app.use(session({
secret: process.env.SESSION_SECRET,
name: 'csgodoku',
resave: true,
saveUninitialized: true,
maxAge: 10 * 365 * 24 * 60 * 60 * 1000,
}))
app.get('/', (req, res) => {
res.render('newDomain')
})
app.post('/import', express.json({ limit: '100mb' }), async (req, res) => {
const localStorageValue = req.body.localStorageData || {};
const sessionValue = req.session
console.log('importing user data with session', sessionValue)
const localStorageKey = (await (await fetch("https://www.csdoku.com/import", {
method: 'POST',
credentials: 'include',
headers: new Headers({
'Content-Type': 'application/json'
}),
body: JSON.stringify({ sessionValue: sessionValue, localStorageValue: localStorageValue })
})).json()).key
res.send({ key: localStorageKey})
})
/* 404 Page */
app.use(function (req, res, next) {
res.redirect('/')
})
/* Start Function */
async function start() {
app.listen(process.env.PORT || 4000, () => console.log("Server is running..."))
}
start()
// npx tailwindcss -i .\static\styles.css -o ./static/output.css --watch
// npx tailwindcss -i static/styles.css -o static/output.css --watch