This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7560ea
commit 64eac6b
Showing
32 changed files
with
824 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,11 @@ import { faker } from "https://deno.land/x/[email protected]/mod.ts"; | |
test( | ||
"e2e transaction", | ||
async (ctx: TestContext) => { | ||
const { user: user, token: token } = await ctx.modules.users.register({ | ||
const { user: user } = await ctx.modules.users.createUser({ | ||
username: faker.internet.userName(), | ||
identity: { guest: {} }, | ||
}); | ||
const { token } = await ctx.modules.users.createUserToken({ | ||
userId: user.id, | ||
}); | ||
|
||
const { updatedBalance } = await ctx.modules.currency.deposit({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,15 @@ import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts"; | |
import { faker } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
test("e2e accept", async (ctx: TestContext) => { | ||
const { user: _userA, token: tokenA } = await ctx.modules.users.register({ | ||
const { user: userA } = await ctx.modules.users.createUser({ | ||
username: faker.internet.userName(), | ||
identity: { guest: {} }, | ||
}); | ||
const { token: tokenA } = await ctx.modules.users.createUserToken({ userId: userA.id }); | ||
|
||
const { user: userB, token: tokenB } = await ctx.modules.users.register({ | ||
const { user: userB } = await ctx.modules.users.createUser({ | ||
username: faker.internet.userName(), | ||
identity: { guest: {} }, | ||
}); | ||
const { token: tokenB } = await ctx.modules.users.createUserToken({ userId: userB.id }); | ||
|
||
const { friendRequest } = await ctx.modules.friends.sendRequest({ | ||
userToken: tokenA.token, | ||
|
@@ -57,15 +57,15 @@ test("e2e accept", async (ctx: TestContext) => { | |
}); | ||
|
||
test("e2e reject", async (ctx: TestContext) => { | ||
const { user: _userA, token: tokenA } = await ctx.modules.users.register({ | ||
const { user: userA } = await ctx.modules.users.createUser({ | ||
username: faker.internet.userName(), | ||
identity: { guest: {} }, | ||
}); | ||
const { token: tokenA } = await ctx.modules.users.createUserToken({ userId: userA.id }); | ||
|
||
const { user: userB, token: tokenB } = await ctx.modules.users.register({ | ||
const { user: userB } = await ctx.modules.users.createUser({ | ||
username: faker.internet.userName(), | ||
identity: { guest: {} }, | ||
}); | ||
const { token: tokenB } = await ctx.modules.users.createUserToken({ userId: userB.id }); | ||
|
||
const { friendRequest } = await ctx.modules.friends.sendRequest({ | ||
userToken: tokenA.token, | ||
|
9 changes: 9 additions & 0 deletions
9
modules/rate_limit/db/migrations/20240313051342_init/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- CreateTable | ||
CREATE UNLOGGED TABLE "TokenBuckets" ( | ||
"type" TEXT NOT NULL, | ||
"key" TEXT NOT NULL, | ||
"tokens" BIGINT NOT NULL, | ||
"lastRefill" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "TokenBuckets_pkey" PRIMARY KEY ("type","key") | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
model TokenBuckets { | ||
type String | ||
key String | ||
tokens BigInt | ||
lastRefill DateTime | ||
@@id([type, key]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ authors: | |
- NathanFlurry | ||
scripts: | ||
throttle: {} | ||
errors: {} | ||
throttle_public: {} | ||
errors: | ||
RATE_LIMIT_EXCEEDED: {} |
Oops, something went wrong.