mirror of
https://github.com/ershisan99/rate-limited-server.git
synced 2025-12-16 12:33:52 +00:00
initial commit
This commit is contained in:
15
.idea/git_toolbox_prj.xml
generated
Normal file
15
.idea/git_toolbox_prj.xml
generated
Normal 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
6
.idea/jsLibraryMappings.xml
generated
Normal 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
6
.idea/vcs.xml
generated
Normal 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
17
Dockerfile
Normal 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
|
||||
@@ -6,7 +6,8 @@
|
||||
"dev": "bun run --watch src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"elysia": "latest"
|
||||
"elysia": "latest",
|
||||
"elysia-rate-limit": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bun-types": "latest"
|
||||
|
||||
23
src/index.ts
23
src/index.ts
@@ -1,6 +1,27 @@
|
||||
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(
|
||||
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
|
||||
|
||||
Reference in New Issue
Block a user