Skip to content

Commit 441422f

Browse files
committed
http server
1 parent 5dff8b4 commit 441422f

4 files changed

Lines changed: 37 additions & 4 deletions

File tree

.github/workflows/fly-deploy.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
2+
3+
name: Fly Deploy
4+
on:
5+
push:
6+
branches:
7+
- main
8+
jobs:
9+
deploy:
10+
name: Deploy app
11+
runs-on: ubuntu-latest
12+
concurrency: deploy-group # optional: ensure only one action runs at a time
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: superfly/flyctl-actions/setup-flyctl@master
16+
- run: flyctl deploy --remote-only
17+
env:
18+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

bot.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Bot, Context } from "grammy";
22
import dotenv from "dotenv";
33
import { dailyQuote, loadInitialQuote } from "./getQuoteFunc";
4+
import http from "http";
45

56
dotenv.config();
67

@@ -106,3 +107,17 @@ async function main() {
106107
}
107108

108109
main().catch(console.error);
110+
111+
http
112+
.createServer((req, res) => {
113+
if (req.url === "/ping") {
114+
res.writeHead(200, { "Content-Type": "text/plain" });
115+
res.end("pong");
116+
} else {
117+
res.writeHead(404);
118+
res.end();
119+
}
120+
})
121+
.listen(process.env.PORT || 8080, () => {
122+
console.log("Ping server is running");
123+
});

fly.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# fly.toml app configuration file generated for randomquotes on 2025-07-29T15:47:39Z
1+
# fly.toml app configuration file generated for randomquotes-white-darkness-8812 on 2025-07-29T20:44:14+03:00
22
#
33
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
44
#
55

6-
app = 'randomquotes'
6+
app = 'randomquotes-white-darkness-8812'
77
primary_region = 'waw'
88

99
[build]
@@ -23,4 +23,3 @@ primary_region = 'waw'
2323
memory = '1gb'
2424
cpu_kind = 'shared'
2525
cpus = 1
26-
memory_mb = 1024

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"scripts": {
1515
"lint": "biome check .",
16-
"lint:fix": "biome check . --apply"
16+
"lint:fix": "biome check . --apply",
17+
"start" : "node bot.js"
1718
}
1819
}

0 commit comments

Comments
 (0)