Add server for Railway deployment

This commit is contained in:
Alexa Amundson
2025-11-22 18:30:36 -06:00
parent dde613a012
commit 04de2c8157
3 changed files with 42 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
node_modules
npm-debug.log*
.DS_Store

View File

@@ -5,5 +5,8 @@
"dependencies": { "dependencies": {
"@primer/css": "17.0.1" "@primer/css": "17.0.1"
}, },
"scripts": {
"start": "node server.js"
},
"license": "MIT" "license": "MIT"
} }

36
server.js Normal file
View File

@@ -0,0 +1,36 @@
const http = require('http');
const fs = require('fs');
const path = require('path');
const PORT = process.env.PORT || 3000;
const HOST = '0.0.0.0';
const indexPath = path.join(__dirname, 'index.html');
const server = http.createServer((req, res) => {
if (req.url === '/health') {
const payload = { status: 'ok', service: 'demo' };
const body = JSON.stringify(payload);
res.writeHead(200, {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(body)
});
res.end(body);
return;
}
fs.readFile(indexPath, (err, data) => {
if (err) {
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.end('Internal Server Error');
return;
}
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(data);
});
});
server.listen(PORT, HOST, () => {
console.log(`Server running at http://${HOST}:${PORT}`);
});