oneuptime/accounts/index.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-08-02 12:56:16 +00:00
const express = require('express');
const path = require('path');
const app = express();
2019-08-29 08:10:51 +00:00
const envfile = require('envfile');
const fs = require('fs');
2020-02-16 22:50:27 +00:00
const child_process = require('child_process');
const compression = require('compression');
2019-08-29 08:10:51 +00:00
2020-02-16 22:50:27 +00:00
const env = {
2020-02-19 21:30:53 +00:00
REACT_APP_FYIPE_HOSTED: process.env.IS_SAAS_SERVICE,
2019-08-29 08:10:51 +00:00
REACT_APP_HOST: process.env.HOST,
2019-08-29 09:58:58 +00:00
REACT_APP_DASHBOARD_HOST: process.env.DASHBOARD_HOST,
2019-09-10 20:52:14 +00:00
REACT_APP_BACKEND_HOST: process.env.BACKEND_HOST,
REACT_APP_DOMAIN: process.env.DOMAIN,
2020-01-23 06:48:40 +00:00
REACT_APP_STRIPE_PUBLIC_KEY: process.env.STRIPE_PUBLIC_KEY,
REACT_APP_AMPLITUDE_PUBLIC_KEY: process.env.AMPLITUDE_PUBLIC_KEY
2019-08-29 08:10:51 +00:00
}
2019-08-29 09:00:55 +00:00
fs.writeFileSync('.env', envfile.stringifySync(env));
2019-08-02 12:56:16 +00:00
2019-09-09 05:20:52 +00:00
child_process.execSync('react-env', {
2019-08-29 14:21:09 +00:00
stdio: [0, 1, 2]
});
2019-08-29 10:47:17 +00:00
app.use(compression());
2019-08-02 12:56:16 +00:00
app.use(express.static(path.join(__dirname, 'build')));
2019-09-09 13:30:52 +00:00
app.get('/env.js', function (req, res) {
res.sendFile(path.join(__dirname, 'public', 'env.js'));
});
2019-08-28 10:16:14 +00:00
app.get('/*', function (req, res) {
2019-08-02 12:56:16 +00:00
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
2020-02-16 22:50:27 +00:00
const PORT = 3003
2019-09-18 17:48:11 +00:00
/* eslint-disable no-console */
2019-09-18 08:09:28 +00:00
console.log(`This project is running on port ${PORT}`)
app.listen(PORT);