Skip to content

Commit 9cdbfdf

Browse files
committed
init
0 parents  commit 9cdbfdf

6 files changed

Lines changed: 895 additions & 0 deletions

File tree

dockerfile/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM alpine
2+
3+
RUN echo hello
4+
5+
CMD echo start

hello.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const text = "hello world";

index.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import fastify from "fastify";
2+
import { text } from "./hello";
3+
4+
// Get all environment variables that start with RAILWAY_
5+
const railwayVars: Record<string, string> = {};
6+
Object.entries(process.env)
7+
.filter(([key]) => key.startsWith("RAILWAY_"))
8+
.forEach(([key, value]) => {
9+
railwayVars[key] = value ?? "";
10+
});
11+
12+
if (Object.keys(railwayVars).length > 0) {
13+
console.log(JSON.stringify(railwayVars, null, 2));
14+
}
15+
16+
const server = fastify();
17+
18+
server.get("/", async (request, reply) => {
19+
reply.code(200).send({ message: text });
20+
});
21+
22+
server.listen(process.env.PORT || 8080, "0.0.0.0", (err, address) => {
23+
if (err) {
24+
console.error(err);
25+
process.exit(1);
26+
}
27+
console.log(`Server listening at ${address}`);
28+
console.log(`Text: ${text}`);
29+
});

0 commit comments

Comments
 (0)