initial commit

This commit is contained in:
2024-08-20 19:15:38 +02:00
parent fbb4748e65
commit 5551086ed4
8 changed files with 71 additions and 4 deletions

1
.env Normal file
View File

@@ -0,0 +1 @@
PORT=4321

15
.idea/git_toolbox_prj.xml generated Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>

6
.idea/jsLibraryMappings.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM oven/bun
WORKDIR /app
COPY package.json .
COPY bun.lockb .
RUN bun install --production
COPY src src
COPY tsconfig.json .
# COPY public public
ENV NODE_ENV production
CMD ["bun", "src/index.ts"]
EXPOSE 4444

BIN
bun.lockb Normal file

Binary file not shown.

View File

@@ -6,7 +6,8 @@
"dev": "bun run --watch src/index.ts" "dev": "bun run --watch src/index.ts"
}, },
"dependencies": { "dependencies": {
"elysia": "latest" "elysia": "latest",
"elysia-rate-limit": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"bun-types": "latest" "bun-types": "latest"

View File

@@ -1,6 +1,27 @@
import {Elysia} from "elysia"; import {Elysia} from "elysia";
import {rateLimit} from "elysia-rate-limit";
const app = new Elysia().get("/", () => "Hello Elysia").listen(3000); const url =
"https://script.google.com/macros/s/AKfycbwHGQjf1vlKbY7UJ3h1OUTywJCgma6SlJi94WXaFBhS_93cdfHhIB0mVQBHqHRtbO4dQQ/exec";
const app = new Elysia()
.use(rateLimit({
max: 2
}))
.post("/", async ({body}) => {
const response = await fetch(url, {
method: "POST",
body: JSON.stringify(body),
headers: {"Content-Type": "application/json"},
})
return await response.json()
})
.listen(process.env.PORT ?? 4444);
console.log( console.log(
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}` `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`