Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit c3ef4ce

Browse files
brownie-in-motionethanwu10
authored andcommitted
refactor(server): type registration handling
1 parent e66b4d7 commit c3ef4ce

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"@types/mailgun-js": "0.22.10",
6464
"@types/mustache": "4.0.1",
6565
"@types/nodemailer": "6.4.0",
66+
"@types/uuid": "8.0.1",
6667
"@typescript-eslint/eslint-plugin": "3.7.0",
6768
"@typescript-eslint/parser": "3.8.0",
6869
"ava": "3.11.1",
File renamed without changes.

server/auth/register.js renamed to server/auth/register.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { v4 as uuidv4 } from 'uuid'
2-
import * as database from '../database'
2+
import { makeUser, User } from '../database/users'
33
import { getToken, tokenKinds } from './token'
44
import { responses } from '../responses'
55

6-
export const register = async ({ division, email, name, ctftimeId }) => {
6+
export const register = async (
7+
{ division, email, name, ctftimeId }: User
8+
): Promise<[typeof responses.goodRegister, { authToken: string }] | (typeof responses)[keyof typeof responses]> => {
79
const userUuid = uuidv4()
810
try {
9-
await database.users.makeUser({
11+
await makeUser({
1012
division,
1113
email,
1214
name,

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,11 @@
13061306
dependencies:
13071307
"@types/node" "*"
13081308

1309+
1310+
version "8.0.1"
1311+
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.0.1.tgz#42958a1a880640b139eea97a1640e1a3f61016d2"
1312+
integrity sha512-2kE8rEFgJpbBAPw5JghccEevQb0XVU0tewF/8h7wPQTeCtoJ6h8qmBIwuzUVm2MutmzC/cpCkwxudixoNYDp1A==
1313+
13091314
"@typescript-eslint/[email protected]":
13101315
version "3.7.0"
13111316
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.0.tgz#0f91aa3c83d019591719e597fbdb73a59595a263"

0 commit comments

Comments
 (0)