Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit cc9b388

Browse files
committed
chore: make errors lowercase (#64)
1 parent 04f7685 commit cc9b388

File tree

18 files changed

+187
-68
lines changed

18 files changed

+187
-68
lines changed

.github/workflows/test-all.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
- push
44

55
env:
6-
CURRENT_WORKING_ENGINE_COMMIT: cbdd1e1b364b1906347b3ef541a4a5057651650f
6+
CURRENT_WORKING_ENGINE_COMMIT: 1971d6db5c5ffd065fec24764c122b4ab74e3172
77

88
jobs:
99
build:

modules/auth/module.yaml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
1+
name: Authentication
2+
description: Authenticate users with multiple authentication methods.
3+
icon: key
4+
tags:
5+
- core
6+
- auth
7+
- user
8+
authors:
9+
- rivet-gg
10+
- NathanFlurry
11+
status: stable
112
dependencies:
213
email: {}
314
users: {}
415
rate_limit: {}
516
scripts:
617
auth_email_passwordless:
18+
name: Authenticate Email Passwordless
19+
description: Send a one-time verification code to a user's email address to authenticate them.
720
public: true
821
verify_email_passwordless:
22+
name: Verify Email Passwordless
23+
description: Verify a user's email address with a one-time verification code.
924
public: true
1025
errors:
11-
PROVIDER_DISABLED: {}
12-
VERIFICATION_CODE_INVALID: {}
13-
VERIFICATION_CODE_ATTEMPT_LIMIT: {}
14-
VERIFICATION_CODE_EXPIRED: {}
15-
VERIFICATION_CODE_ALREADY_USED: {}
16-
EMAIL_ALREADY_USED: {}
26+
provider_disabled:
27+
name: Provider Disabled
28+
verification_code_invalid:
29+
name: Verification Code Invalid
30+
verification_code_attempt_limit:
31+
name: Verification Code Attempt Limit
32+
verification_code_expired:
33+
name: Verification Code Expired
34+
verification_code_already_used:
35+
name: Verification Code Already Used
36+
email_already_used:
37+
name: Email Already Used

modules/auth/scripts/auth_email_passwordless.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function run(
1717
): Promise<Response> {
1818
await ctx.modules.rateLimit.throttlePublic({});
1919

20-
if (!ctx.userConfig.email) throw new RuntimeError("PROVIDER_DISABLED");
20+
if (!ctx.userConfig.email) throw new RuntimeError("provider_disabled");
2121

2222
// Fetch existing user if session token is provided
2323
let userId: string | undefined;
@@ -31,7 +31,7 @@ export async function run(
3131
where: { email: req.email },
3232
});
3333
if (existingIdentity && existingIdentity.userId !== userId) {
34-
throw new RuntimeError("EMAIL_ALREADY_USED");
34+
throw new RuntimeError("email_already_used");
3535
}
3636
}
3737

modules/auth/scripts/verify_email_passwordless.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ export async function run(
4545
},
4646
});
4747
if (!verification) {
48-
throw new RuntimeError("VERIFICATION_CODE_INVALID");
48+
throw new RuntimeError("verification_code_invalid");
4949
}
5050
if (verification.attemptCount >= verification.maxAttemptCount) {
51-
throw new RuntimeError("VERIFICATION_CODE_ATTEMPT_LIMIT");
51+
throw new RuntimeError("verification_code_attempt_limit");
5252
}
5353
if (verification.completedAt !== null) {
54-
throw new RuntimeError("VERIFICATION_CODE_ALREADY_USED");
54+
throw new RuntimeError("verification_code_already_used");
5555
}
5656
if (verification.code !== code) {
5757
// Same error as above to prevent exploitation
58-
throw new RuntimeError("VERIFICATION_CODE_INVALID");
58+
throw new RuntimeError("verification_code_invalid");
5959
}
6060
if (verification.expireAt < new Date()) {
61-
throw new RuntimeError("VERIFICATION_CODE_EXPIRED");
61+
throw new RuntimeError("verification_code_expired");
6262
}
6363

6464
// Mark as used
@@ -73,7 +73,7 @@ export async function run(
7373
},
7474
});
7575
if (verificationConfirmation === null) {
76-
throw new RuntimeError("VERIFICATION_CODE_ALREADY_USED");
76+
throw new RuntimeError("verification_code_already_used");
7777
}
7878

7979
// Get or create user

modules/currency/module.yaml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
1-
status: preview
1+
name: Currency
2+
description: Track user balances and allow them to deposit and withdraw.
3+
icon: coin
4+
tags:
5+
- economy
26
authors:
37
- ABCxFF
8+
status: preview
49
dependencies:
510
rate_limit: {}
611
users: {}
712
scripts:
813
# Maybe deposit?
9-
deposit: {}
14+
deposit:
15+
name: Deposit
1016
# Maybe withdraw?
11-
withdraw: {}
12-
get_balance: {}
13-
set_balance: {}
17+
withdraw:
18+
name: Withdraw
19+
get_balance:
20+
name: Get Balance
21+
set_balance:
22+
name: Set Balance
1423
get_balance_by_token:
24+
name: Get Balance by Token
1525
public: true
1626
errors:
17-
INVALID_USER: {}
18-
INVALID_AMOUNT: {}
19-
NOT_ENOUGH_FUNDS: {}
27+
invalid_user:
28+
name: Invalid User
29+
invalid_amount:
30+
name: Invalid Amount
31+
not_enough_funds:
32+
name: Not Enough Funds

modules/currency/scripts/deposit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ export async function run(
1919
await ctx.modules.rateLimit.throttlePublic({ requests: 25 });
2020

2121
if (req.amount < 0 || !Number.isFinite(req.amount)) {
22-
throw new RuntimeError("INVALID_AMOUNT");
22+
throw new RuntimeError("invalid_amount");
2323
}
2424

2525
return ctx.db.$transaction(async (tx) => {
2626
const balance = await getBalance(tx, req.userId);
2727

2828
const updatedBalance = balance + req.amount;
2929

30-
if (updatedBalance < 0) throw new RuntimeError("NOT_ENOUGH_FUNDS");
30+
if (updatedBalance < 0) throw new RuntimeError("not_enough_funds");
3131

3232
try {
3333
await setBalance(tx, req.userId, updatedBalance);
3434
} catch {
35-
throw new RuntimeError("INVALID_AMOUNT");
35+
throw new RuntimeError("invalid_amount");
3636
}
3737

3838
return {

modules/currency/scripts/set_balance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export async function run(
1717
await ctx.modules.rateLimit.throttlePublic({ requests: 25 });
1818

1919
if (req.balance < 0 || !Number.isFinite(req.balance)) {
20-
throw new RuntimeError("INVALID_AMOUNT");
20+
throw new RuntimeError("invalid_amount");
2121
}
2222

2323
try {
2424
await setBalance(ctx.db, req.userId, req.balance);
2525
} catch {
26-
throw new RuntimeError("INVALID_AMOUNT");
26+
throw new RuntimeError("invalid_amount");
2727
}
2828

2929
return {};

modules/currency/scripts/withdraw.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ export async function run(
1919
await ctx.modules.rateLimit.throttlePublic({ requests: 25 });
2020

2121
if (req.amount < 0 || !Number.isFinite(req.amount)) {
22-
throw new RuntimeError("INVALID_AMOUNT");
22+
throw new RuntimeError("invalid_amount");
2323
}
2424

2525
return ctx.db.$transaction(async (tx) => {
2626
const balance = await getBalance(tx, req.userId);
2727

2828
const updatedBalance = balance - req.amount;
2929

30-
if (updatedBalance < 0) throw new RuntimeError("NOT_ENOUGH_FUNDS");
30+
if (updatedBalance < 0) throw new RuntimeError("not_enough_funds");
3131

3232
try {
3333
await setBalance(tx, req.userId, updatedBalance);
3434
} catch {
35-
throw new RuntimeError("INVALID_AMOUNT");
35+
throw new RuntimeError("invalid_amount");
3636
}
3737

3838
return {

modules/currency/utils/set_balance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const setBalance = async (
1010
userId: string,
1111
balance: number,
1212
) => {
13-
if (balance < 0) throw new RuntimeError("INVALID_AMOUNT");
13+
if (balance < 0) throw new RuntimeError("invalid_amount");
1414

1515
await db.userWallet.upsert({
1616
where: {

modules/email/module.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
name: Email
2+
description: Send emails using multiple providers.
3+
icon: envelope
4+
tags:
5+
- email
6+
authors:
7+
- rivet-gg
8+
- NathanFlurry
9+
status: stable
110
scripts:
2-
send_email: {}
11+
send_email:
12+
name: Send Email
313
errors:
4-
EMAIL_MISSING_CONTENT:
14+
email_missing_content:
15+
name: Email Missing Content
516
description: Email must have `html` and/or `text`
6-
SENDGRID_ERROR: {}
17+
sendgrid_error:
18+
name: SendGrid Error

0 commit comments

Comments
 (0)