2022-03-01 20:48:48 +00:00
|
|
|
import 'common-server/utils/env';
|
|
|
|
import 'common-server/utils/process';
|
2022-03-19 17:01:37 +00:00
|
|
|
import logger from 'common-server/utils/logger';
|
2022-03-21 22:26:54 +00:00
|
|
|
import express, {
|
|
|
|
ExpressRequest,
|
|
|
|
ExpressResponse,
|
2022-03-22 11:19:12 +00:00
|
|
|
ExpressStatic,
|
2022-03-21 22:26:54 +00:00
|
|
|
} from 'common-server/utils/express';
|
2022-02-27 12:24:02 +00:00
|
|
|
import path from 'path';
|
2022-03-19 17:01:37 +00:00
|
|
|
const app = express.getExpressApp();
|
2022-02-28 12:00:02 +00:00
|
|
|
|
2022-02-27 12:24:02 +00:00
|
|
|
import compression from 'compression';
|
2019-08-29 08:10:51 +00:00
|
|
|
|
2020-01-01 13:04:24 +00:00
|
|
|
app.use(compression());
|
|
|
|
|
2022-03-19 17:00:54 +00:00
|
|
|
app.get(
|
|
|
|
['/env.js', '/accounts/env.js'],
|
2022-03-21 22:26:02 +00:00
|
|
|
(req: ExpressRequest, res: ExpressResponse) => {
|
2022-03-19 17:00:54 +00:00
|
|
|
const env = {
|
2022-03-22 11:19:12 +00:00
|
|
|
REACT_APP_IS_SAAS_SERVICE: process.env['IS_SAAS_SERVICE'],
|
|
|
|
REACT_APP_DISABLE_SIGNUP: process.env['DISABLE_SIGNUP'],
|
2022-03-19 17:00:54 +00:00
|
|
|
REACT_APP_HOST: req.host,
|
2022-03-22 11:19:12 +00:00
|
|
|
REACT_APP_STRIPE_PUBLIC_KEY: process.env['STRIPE_PUBLIC_KEY'],
|
|
|
|
REACT_APP_AMPLITUDE_PUBLIC_KEY: process.env['AMPLITUDE_PUBLIC_KEY'],
|
2022-03-19 17:00:54 +00:00
|
|
|
REACT_APP_VERSION:
|
2022-03-22 11:19:12 +00:00
|
|
|
process.env['npm_package_version'] ||
|
|
|
|
process.env['REACT_APP_VERSION'],
|
2022-03-19 17:00:54 +00:00
|
|
|
};
|
2020-03-23 20:59:33 +00:00
|
|
|
|
2022-03-19 17:00:54 +00:00
|
|
|
res.contentType('application/javascript');
|
|
|
|
res.send('window._env = ' + JSON.stringify(env));
|
|
|
|
}
|
|
|
|
);
|
2019-09-09 13:30:52 +00:00
|
|
|
|
2022-03-22 11:19:12 +00:00
|
|
|
app.use(ExpressStatic(path.join(__dirname, 'build')));
|
2021-12-30 07:25:15 +00:00
|
|
|
|
2021-12-27 12:06:39 +00:00
|
|
|
app.use(
|
2021-12-30 07:25:15 +00:00
|
|
|
'/accounts/static/js',
|
2022-03-22 11:19:12 +00:00
|
|
|
ExpressStatic(path.join(__dirname, 'build', 'static', 'js'))
|
2021-12-27 12:06:39 +00:00
|
|
|
);
|
2021-12-29 13:16:55 +00:00
|
|
|
|
2022-03-22 11:19:12 +00:00
|
|
|
app.use('/accounts', ExpressStatic(path.join(__dirname, 'build')));
|
2021-12-30 07:25:15 +00:00
|
|
|
|
2022-03-22 11:19:12 +00:00
|
|
|
app.get('/*', (_req: ExpressRequest, res: ExpressResponse) => {
|
2020-02-27 11:15:46 +00:00
|
|
|
res.sendFile(path.join(__dirname, 'build', 'index.html'));
|
2019-08-02 12:56:16 +00:00
|
|
|
});
|
|
|
|
|
2022-03-20 22:14:51 +00:00
|
|
|
const PORT = process.env['PORT'] || 3003;
|
2022-03-19 17:01:37 +00:00
|
|
|
|
|
|
|
logger.info(`This project is running on port ${PORT}`);
|
2020-02-27 11:15:46 +00:00
|
|
|
app.listen(PORT);
|