Skip to content

Commit

Permalink
feat(#35): get port through config
Browse files Browse the repository at this point in the history
  • Loading branch information
jannis-baum committed Jul 12, 2024
1 parent d1a12fd commit 339b949
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import { router as viewerRouter } from './routes/viewer';
import { router as staticRouter } from './routes/static';
import { setupSockets } from './sockets';
import { urlToPath } from './utils/path';

process.env['VIV_PORT'] = process.env['VIV_PORT'] ?? '31622';
import config from './parser/config';

const app = express();
app.use(express.json());
Expand All @@ -30,9 +29,9 @@ app.use('/viewer', viewerRouter);

const server = createServer(app);

server.listen(process.env['VIV_PORT'], async () => {
server.listen(config.port, async () => {
await Promise.all(asyncInits.map(async (i) => await i()));
console.log(`App is listening on port ${process.env['VIV_PORT']}!`);
console.log(`App is listening on port ${config.port}!`);
});

let shutdownTimer: NodeJS.Timeout | null = null;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ router.get(/.*/, async (req: Request, res: Response) => {
</div>
</body>
<script>
window.VIV_PORT = "${process.env['VIV_PORT']}";
window.VIV_PORT = "${config.port}";
window.VIV_PATH = "${req.path}";
</script>
<script type="text/javascript" src="/static/client.js"></script>
Expand Down

0 comments on commit 339b949

Please sign in to comment.