forked from emporix/b2b-showcase
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
78 lines (71 loc) · 2.06 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//app modules
const express = require('express')
const app = express()
const dotenv = require('dotenv')
const path = require('path')
// const {
// migrateCampaignsToContentful,
// } = require('./scripts/migrate-campaigns-to-contentfull')
// const {
// migratePromotionTiersToContentful,
// } = require('./scripts/migrate-promotion-tiers-to-contentfull')
// const {
// migrateStandaloneVouchersToContentful,
// } = require('./scripts/migrate-standalone-vouchers-to-contentfull')
const {
migrateProductsToVoucherify,
} = require('./scripts/migrate-products-to-voucherify')
const {
migrateCustomersToVoucherify,
} = require('./scripts/migrate-customers-to-voucherify')
dotenv.config()
// const checkExpiredEmailValidation = require("./modules/checkExpiredEmailValidation");
app.use(express.urlencoded({ extended: false }))
app.use((req, res, next) => {
express.json()(req, res, next)
})
// app.get('/hidden-migrate-all-promotions', async (req, res) => {
// res.json({ success: true, operation: 'started' })
// try {
// await migrateCampaignsToContentful()
// await migratePromotionTiersToContentful()
// await migrateStandaloneVouchersToContentful()
// } catch (e) {
// console.log(e)
// }
// return
// })
app.get('/hidden-migrate-all-products', async (req, res) => {
res.json({ success: true, operation: 'started' })
try {
await migrateProductsToVoucherify()
} catch (e) {
console.log(e)
}
return
})
app.get('/hidden-migrate-all-customers-to-voucherify', async (req, res) => {
res.json({ success: true, operation: 'started' })
try {
await migrateCustomersToVoucherify()
} catch (e) {
console.log(e)
}
return
})
const options = {
dotfiles: 'ignore',
etag: false,
extensions: ['htm', 'html'],
index: false,
maxAge: '1d',
redirect: false,
}
app.use(express.static('build', options))
app.get(`/*`, (req, res) => {
res.sendFile(path.resolve(__dirname, 'build', 'index.html'))
})
const PORT = process.env.PORT || 5555
const main = (async () => {
app.listen(PORT, () => console.log(`Server started on port ${PORT}!`))
})()