Change server listening port to 80 for production deployment

This commit is contained in:
Johannes Baumeister 2026-04-20 15:24:18 +02:00
parent 1b67432b71
commit b2ed6bee38
1 changed files with 8 additions and 7 deletions

View File

@ -158,7 +158,7 @@ app.get('/api/poi', async (req, res) => {
SELECT SELECT
id, id,
ST_AsGeoJSON(ST_Transform(geom, 4326)) as geometry ST_AsGeoJSON(ST_Transform(geom, 4326)) as geometry
FROM "netzverknüpfungspunkt" FROM netzverknüpfungspunkt
`; `;
const result = await client.query(query); const result = await client.query(query);
const geojson = { const geojson = {
@ -258,7 +258,7 @@ app.post('/api/variants', async (req, res) => {
const routeName = properties.name || 'Neue Trasse'; const routeName = properties.name || 'Neue Trasse';
const varianteValue = properties.Variante || (properties.name ? properties.name.replace('Variante ', '') : 'A'); const varianteValue = properties.Variante || (properties.name ? properties.name.replace('Variante ', '') : 'A');
const geoJsonStr = JSON.stringify(geometry); const geoJsonStr = JSON.stringify(geometry);
// Safety Check: DON'T delete/save if geometry is empty or invalid // Safety Check: DON'T delete/save if geometry is empty or invalid
if (!geometry || !geometry.coordinates || geometry.coordinates.length < 2) { if (!geometry || !geometry.coordinates || geometry.coordinates.length < 2) {
console.log(`Aborting save for ${varianteValue}: Geometry is too short or empty.`); console.log(`Aborting save for ${varianteValue}: Geometry is too short or empty.`);
@ -267,7 +267,7 @@ app.post('/api/variants', async (req, res) => {
try { try {
await client.query('BEGIN'); await client.query('BEGIN');
// Delete existing variant if it exists // Delete existing variant if it exists
await client.query('DELETE FROM kabeltrasse WHERE "Variante" = $1 OR name = $2', [varianteValue, routeName]); await client.query('DELETE FROM kabeltrasse WHERE "Variante" = $1 OR name = $2', [varianteValue, routeName]);
@ -280,10 +280,10 @@ app.post('/api/variants', async (req, res) => {
) )
RETURNING id RETURNING id
`; `;
const insertRes = await client.query(insertQuery, [geoJsonStr, routeName, varianteValue]); const insertRes = await client.query(insertQuery, [geoJsonStr, routeName, varianteValue]);
await client.query('COMMIT'); await client.query('COMMIT');
res.json({ success: true, id: insertRes.rows[0].id }); res.json({ success: true, id: insertRes.rows[0].id });
} catch (sqlErr) { } catch (sqlErr) {
await client.query('ROLLBACK'); await client.query('ROLLBACK');
@ -320,6 +320,7 @@ app.patch('/api/owners/:id', async (req, res) => {
} }
}); });
app.listen(3000, () => { const PORT = process.env.PORT || 80;
console.log(`Server running at http://localhost:3000`); app.listen(PORT, '0.0.0.0', () => {
console.log(`Server running on port ${PORT}`);
}); });