Skip to content

Commit 4c6e0b5

Browse files
committed
Strict mode
1 parent 941659e commit 4c6e0b5

File tree

15 files changed

+37
-36
lines changed

15 files changed

+37
-36
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@typescript-eslint/adjacent-overload-signatures": "warn",
3333
"@typescript-eslint/no-inferrable-types": "warn",
3434
"@typescript-eslint/no-namespace": "off",
35-
"@typescript-eslint/no-duplicate-enum-values": "off"
35+
"@typescript-eslint/no-duplicate-enum-values": "off",
36+
"@typescript-eslint/no-explicit-any": "warn"
3637
}
3738
}

functions/account/create.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ export async function onRequest({ env, request }: RequestContext): Promise<Respo
1414
let newUser: Account;
1515
try {
1616
newUser = await createAccount(body.username, body.email, body.password);
17-
} catch (err) {
17+
} catch (err: any) {
1818
return parseError(err);
1919
}
2020

2121
return response(StatusCodes.OK, newUser);
22-
} catch (e) {
22+
} catch (e: any) {
2323
if (e instanceof Response) {
2424
return e;
2525
}

functions/account/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function onRequest({ env, request }: RequestContext): Promise<Respo
2424
await deleteAccount(target.id, body.reason);
2525

2626
return response(StatusCodes.OK);
27-
} catch (e) {
27+
} catch (e: any) {
2828
if (e instanceof Response) {
2929
return e;
3030
}

functions/account/info.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function onRequest({ env, request }: RequestContext): Promise<Respo
2626

2727
if (!body.multiple) {
2828
checkParams(body, 'key', 'value');
29-
const target = await getAccount(body.key, body.value);
29+
const target = await getAccount(body.key!, body.value!);
3030

3131
await checkAuth({
3232
auth: request,
@@ -52,12 +52,12 @@ export async function onRequest({ env, request }: RequestContext): Promise<Respo
5252
}
5353

5454
checkParams(body, 'key', 'value');
55-
const accounts = await getAccounts(body.key, body.value);
55+
const accounts = await getAccounts(body.key!, body.value!);
5656
return response(
5757
StatusCodes.OK,
5858
accounts.map(account => stripAccountInfo(account, body.access))
5959
);
60-
} catch (e) {
60+
} catch (e: any) {
6161
if (e instanceof Response) {
6262
return e;
6363
}

functions/account/login.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export async function onRequest({ env, request }: RequestContext): Promise<Respo
2929
let token;
3030
try {
3131
token = await login(account.id);
32-
} catch (err) {
32+
} catch (err: any) {
3333
return parseError(err);
3434
}
3535

3636
return response(StatusCodes.OK, { ...stripAccountInfo(account), token });
37-
} catch (e) {
37+
} catch (e: any) {
3838
if (e instanceof Response) {
3939
return e;
4040
}

functions/account/logout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export async function onRequest({ env, request }: RequestContext): Promise<Respo
2323

2424
try {
2525
await logout(target.id, body.reason);
26-
} catch (err) {
26+
} catch (err: any) {
2727
return parseError(err);
2828
}
2929

3030
return response(StatusCodes.OK, true);
31-
} catch (e) {
31+
} catch (e: any) {
3232
if (e instanceof Response) {
3333
return e;
3434
}

functions/account/num.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function onRequest({ env }: RequestContext) {
99
try {
1010
setDB(env.DB);
1111
return response(StatusCodes.OK, await getAccountNum(), false);
12-
} catch (e) {
12+
} catch (e: any) {
1313
console.error(e);
1414
return error(StatusCodes.INTERNAL_SERVER_ERROR, env.DEBUG && e?.message);
1515
}

functions/account/update.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { AccountType, accountAttributes, stripAccountInfo, type FullAccount } fr
33
import { setAccountAttribute, setDB } from '../../src/backend/api';
44
import type { RequestContext } from '../../src/backend/context';
55
import { checkAuth, checkBody, error, getAccountFromTokenOrID, parseError, response } from '../../src/backend/utils';
6-
import { Access } from '../../src/generic';
76

87
export { onRequestOptions } from '../../src/backend/utils';
98

@@ -31,18 +30,18 @@ export async function onRequest({ env, request }: RequestContext): Promise<Respo
3130
await checkAuth({
3231
auth: request,
3332
target,
34-
allowIfSame: ['username', 'email'].includes(body.key),
35-
requiredType: requiredTypeForChange[body.key],
33+
allowIfSame: ['username', 'email'].includes(body.key!),
34+
requiredType: requiredTypeForChange[body.key!],
3635
});
3736

3837
try {
39-
await setAccountAttribute(target.id, body.key, body.value, body.reason);
40-
} catch (err) {
38+
await setAccountAttribute(target.id, body.key!, body.value!, body.reason);
39+
} catch (err: any) {
4140
throw parseError(err);
4241
}
4342

4443
return response(StatusCodes.OK, stripAccountInfo(target));
45-
} catch (e) {
44+
} catch (e: any) {
4645
if (e instanceof Response) {
4746
return e;
4847
}

functions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function onRequest({ env }: RequestContext) {
1111
debug: !!env.DEBUG,
1212
};
1313
return response(StatusCodes.OK, metadata, false);
14-
} catch (e) {
14+
} catch (e: any) {
1515
console.error(e);
1616
return error(StatusCodes.INTERNAL_SERVER_ERROR, env.DEBUG && e?.message);
1717
}

functions/metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function onRequest({ env }: RequestContext) {
1111
debug: !!env.DEBUG,
1212
};
1313
return response(StatusCodes.OK, metadata, false);
14-
} catch (e) {
14+
} catch (e: any) {
1515
console.error(e);
1616
return error(StatusCodes.INTERNAL_SERVER_ERROR, env.DEBUG && e?.message);
1717
}

0 commit comments

Comments
 (0)