-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
19 changed files
with
751 additions
and
322 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use server'; | ||
import db from '@/lib/db'; | ||
import * as Sentry from '@sentry/nextjs'; | ||
import jwt from 'jsonwebtoken'; | ||
|
||
interface APIKeyGenerationResult { | ||
error?: { | ||
message: string; | ||
}; | ||
data?: { | ||
key: string; | ||
}; | ||
} | ||
|
||
/** | ||
* @description Generates an write to the database a new API key for the team | ||
* @param teamId a string representing the team id | ||
* @returns | ||
*/ | ||
export default async function generateAPIKey( | ||
teamId: string | ||
): Promise<APIKeyGenerationResult> { | ||
if (!process.env.JWT_SECRET) { | ||
return { | ||
error: { | ||
message: 'Internal server error', | ||
}, | ||
}; | ||
} | ||
try { | ||
const token = jwt.sign({ teamId }, process.env.JWT_SECRET); | ||
|
||
await db.team.update({ | ||
where: { id: teamId }, | ||
data: { | ||
apiKey: token, | ||
}, | ||
}); | ||
|
||
return { | ||
data: { | ||
key: token, | ||
}, | ||
}; | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
return { | ||
error: { | ||
message: 'Internal server 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import dynamic from 'next/dynamic'; | ||
|
||
export default dynamic( | ||
// @ts-expect-error | ||
() => import('react-beautiful-dnd').then((res) => res.Droppable), | ||
{ ssr: false } | ||
); |
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
Oops, something went wrong.