Skip to content

Commit 40f2f51

Browse files
committed
chore: bun?
1 parent ee8cd1b commit 40f2f51

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

.github/workflows/docker-image.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
test:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- uses: oven-sh/setup-bun@v1
1818
- run: bun install --frozen-lockfile
1919
- run: bun run tsc
@@ -26,20 +26,20 @@ jobs:
2626
packages: write
2727

2828
steps:
29-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
3030
- uses: oven-sh/setup-bun@v1
3131
- run: bun install --frozen-lockfile
3232
- run: bun run build
3333
- name: Log in to the Container registry
34-
uses: docker/login-action@v2
34+
uses: docker/login-action@v3
3535
with:
3636
registry: ${{ env.REGISTRY }}
3737
username: ${{ github.actor }}
3838
password: ${{ secrets.GITHUB_TOKEN }}
3939

4040
- name: Extract metadata (tags, labels) for Docker
4141
id: meta
42-
uses: docker/metadata-action@v4
42+
uses: docker/metadata-action@v5
4343
with:
4444
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4545

Dockerfile

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
FROM gcr.io/distroless/nodejs18-debian11
1+
FROM oven/bun:1
22

33
WORKDIR /app
4-
5-
COPY dist /app
4+
COPY dist/server.js /app/server.js
65

76
EXPOSE 3000
87

98
ENV NODE_ENV=production
109

11-
CMD ["index.js"]
10+
CMD ["server.js"]

bun.lockb

-702 Bytes
Binary file not shown.

package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,24 @@
66
"repository": "https://github.com/karl-run/1337-bot.git",
77
"packageManager": "[email protected]",
88
"scripts": {
9-
"start": "ncc run src/server.ts",
10-
"build": "ncc build src/server.ts -o dist"
9+
"start": "bun run src/server.ts",
10+
"build": "bun build --target=bun src/server.ts --outfile dist/server.js"
1111
},
1212
"dependencies": {
1313
"@slack/bolt": "^3.13.1",
1414
"croner": "^7.0.1",
1515
"date-fns": "^2.30.0",
1616
"date-fns-tz": "^2.0.0",
17-
"dotenv": "^16.0.3",
1817
"open": "^9.1.0",
1918
"pg": "^8.11.3",
2019
"remeda": "^1.27.0",
2120
"yargs": "^17.7.2"
2221
},
2322
"devDependencies": {
23+
"@types/bun": "^1.1.1",
2424
"@types/node": "^20.2.3",
2525
"@types/pg": "^8.10.2",
2626
"@types/yargs": "^17.0.25",
27-
"@types/bun": "^1.1.1",
28-
"@vercel/ncc": "^0.38.0",
2927
"prettier": "^3.0.3",
3028
"prettier-plugin-sql": "^0.15.1",
3129
"typescript": "^5.2.2"

scripts/repars-finder.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { startOfDay, startOfYear } from "date-fns";
2+
import { app } from "../src/slack/slack";
3+
4+
// @ts-ignore Bun :)
5+
const messages = await app.client.conversations.history({
6+
channel: "C04N7R2F8B0",
7+
oldest: `${startOfYear(new Date()).getTime() / 1000}`,
8+
});
9+
10+
console.log(messages.has_more);
11+
console.log(messages.response_metadata.next_cursor);
12+
console.log(messages.messages.length);
13+
14+
let pages = 1;
15+
let nextCursor = messages.response_metadata.next_cursor;
16+
17+
while (nextCursor != null) {
18+
try {
19+
// @ts-ignore Bun :)
20+
const nextMessages = await app.client.conversations.history({
21+
channel: "C04N7R2F8B0",
22+
oldest: `${startOfYear(new Date()).getTime() / 1000}`,
23+
cursor: nextCursor,
24+
});
25+
26+
nextCursor = nextMessages.response_metadata.next_cursor;
27+
28+
if (pages > 3) {
29+
break;
30+
}
31+
32+
pages++;
33+
console.log(`Page: ${pages}`);
34+
console.log(messages.has_more);
35+
console.log(messages.response_metadata.next_cursor);
36+
console.log(messages.messages.length);
37+
38+
console.log(messages.messages.map((it) => it.text));
39+
} catch (e) {
40+
console.error(e);
41+
break;
42+
}
43+
}

src/db/client.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import { config } from "dotenv";
21
import { Client } from "pg";
32

4-
config();
5-
63
export const client = new Client({
74
host: process.env.DATABASE_URL,
85
user: process.env.DATABASE_USER,

src/slack/slack.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { App } from "@slack/bolt";
2-
import { config } from "dotenv";
3-
4-
config();
52

63
export const app = new App({
74
token: process.env.BOT_TOKEN,

0 commit comments

Comments
 (0)