generated from include-davis/Next.js-App-Router-Starter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from HackDavis/feat/infrastructure-changes
Feat/infrastructure changes
- Loading branch information
Showing
85 changed files
with
375 additions
and
411 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
'use server'; | ||
|
||
import { CreateManyTeams } from '@datalib/teams/createTeams'; | ||
import parsedRecordInt from '@typeDefs/parsedRecord'; | ||
|
||
export default async function ingestCSV(parsedData: []) { | ||
const res = await (await CreateManyTeams(parsedData)).json(); | ||
export default async function ingestCSV(parsedData: parsedRecordInt[]) { | ||
const res = await CreateManyTeams(parsedData); | ||
return { ok: res.ok, error: res.error }; | ||
} |
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 |
---|---|---|
@@ -1,40 +1,38 @@ | ||
'use server'; | ||
import { NextResponse } from 'next/server'; | ||
import bcrypt from 'bcryptjs'; | ||
|
||
import { CreateJudge } from '@datalib/judges/createJudge'; | ||
import { DuplicateError, HttpError } from '@utils/response/Errors'; | ||
import { GetManyJudges } from '@datalib/judges/getJudge'; | ||
import { createAuthToken } from './authToken'; | ||
import JudgeInt from '@typeDefs/judges'; | ||
import JudgeInt from '@typeDefs/judge'; | ||
|
||
export async function Register(body: JudgeInt) { | ||
try { | ||
const { email, password, ...rest } = body; | ||
const hashedPassword = await bcrypt.hash(password as string, 10); | ||
|
||
// Find Judge | ||
const judgeRes = await GetManyJudges({ email }); | ||
const judgeData = await judgeRes.json(); | ||
const judgeData = await GetManyJudges({ email }); | ||
if (!judgeData.ok || judgeData.body.length !== 0) { | ||
throw new DuplicateError('Judge already exists'); | ||
} | ||
|
||
// Create Judge | ||
const res = await CreateJudge({ email, password: hashedPassword, ...rest }); | ||
const data = await res.json(); | ||
const data = await CreateJudge({ | ||
email, | ||
password: hashedPassword, | ||
...rest, | ||
}); | ||
|
||
if (!data.ok) { | ||
throw new HttpError('Failed to create judge'); | ||
} | ||
|
||
const token = await createAuthToken(data.body); | ||
return NextResponse.json({ ok: true, body: token }, { status: 200 }); | ||
return { ok: true, body: token, error: null }; | ||
} catch (e) { | ||
const error = e as HttpError; | ||
return NextResponse.json( | ||
{ ok: false, error: error.message }, | ||
{ status: error.status || 400 } | ||
); | ||
return { ok: false, error: error.message }; | ||
} | ||
} |
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
Oops, something went wrong.