diff --git a/api/src/routes/certificate.ts b/api/src/routes/certificate.ts index d5e19425e8b..14af8adb22e 100644 --- a/api/src/routes/certificate.ts +++ b/api/src/routes/certificate.ts @@ -2,7 +2,7 @@ import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebo import isEmail from 'validator/lib/isEmail'; import { find } from 'lodash'; import { CompletedChallenge } from '@prisma/client'; -import { schemas } from '../schemas'; +import * as schemas from '../schemas'; import { getChallenges } from '../utils/get-challenges'; import { certIds, diff --git a/api/src/routes/challenge.ts b/api/src/routes/challenge.ts index 52e9fa1dd44..41aafb8bd8b 100644 --- a/api/src/routes/challenge.ts +++ b/api/src/routes/challenge.ts @@ -5,7 +5,7 @@ import { CompletedExam, ExamResults } from '@prisma/client'; import isURL from 'validator/lib/isURL'; import { challengeTypes } from '../../../shared/config/challenge-types'; -import { schemas } from '../schemas'; +import * as schemas from '../schemas'; import { jsCertProjectIds, multifileCertProjectIds, diff --git a/api/src/routes/deprecated-endpoints.ts b/api/src/routes/deprecated-endpoints.ts index 321361529b4..c6035255542 100644 --- a/api/src/routes/deprecated-endpoints.ts +++ b/api/src/routes/deprecated-endpoints.ts @@ -1,6 +1,6 @@ import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; -import { schemas } from '../schemas'; +import * as schemas from '../schemas'; type Endpoints = [string, 'GET' | 'POST'][]; diff --git a/api/src/routes/donate.ts b/api/src/routes/donate.ts index 82b82cde2d4..51533542211 100644 --- a/api/src/routes/donate.ts +++ b/api/src/routes/donate.ts @@ -5,7 +5,7 @@ import { import Stripe from 'stripe'; import { donationSubscriptionConfig } from '../../../shared/config/donation-settings'; -import { schemas } from '../schemas'; +import * as schemas from '../schemas'; import { STRIPE_SECRET_KEY } from '../utils/env'; /** diff --git a/api/src/routes/email-subscription.ts b/api/src/routes/email-subscription.ts index 8444c1f36c8..9e941bce3cf 100644 --- a/api/src/routes/email-subscription.ts +++ b/api/src/routes/email-subscription.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; -import { schemas } from '../schemas'; +import * as schemas from '../schemas'; import { getRedirectParams } from '../utils/redirection'; /** diff --git a/api/src/routes/settings.ts b/api/src/routes/settings.ts index 2127e281b31..81a07deaffc 100644 --- a/api/src/routes/settings.ts +++ b/api/src/routes/settings.ts @@ -18,7 +18,7 @@ import { isProfane } from 'no-profanity'; import { blocklistedUsernames } from '../../../shared/config/constants'; import { isValidUsername } from '../../../shared/utils/validate'; -import { schemas } from '../schemas'; +import * as schemas from '../schemas'; type WaitMesssageArgs = { sentAt: Date | null; diff --git a/api/src/routes/user.ts b/api/src/routes/user.ts index 6eb4ca74f4b..ab16be6500b 100644 --- a/api/src/routes/user.ts +++ b/api/src/routes/user.ts @@ -1,7 +1,7 @@ import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { ObjectId } from 'mongodb'; -import { schemas } from '../schemas'; +import * as schemas from '../schemas'; // Loopback creates a 64 character string for the user id, this customizes // nanoid to do the same. Any unique key _should_ be fine, though. import { customNanoid } from '../utils/ids'; diff --git a/api/src/schema.test.ts b/api/src/schema.test.ts index a6fdc122234..f081880240b 100644 --- a/api/src/schema.test.ts +++ b/api/src/schema.test.ts @@ -1,7 +1,7 @@ import Ajv from 'ajv'; import secureSchema from 'ajv/lib/refs/json-schema-secure.json'; -import { schemas } from './schemas'; +import * as schemas from './schemas'; // it's not strict, but that's okay - we're not using it to validate data const ajv = new Ajv({ strictTypes: false }); diff --git a/api/src/schemas.ts b/api/src/schemas.ts index d81d3242bcc..2473795bd35 100644 --- a/api/src/schemas.ts +++ b/api/src/schemas.ts @@ -1,71 +1,34 @@ -import { certSlug } from './schemas/certificate/cert-slug'; -import { certificateVerify } from './schemas/certificate/certificate-verify'; -import { backendChallengeCompleted } from './schemas/challenge/backend-challenge-completed'; -import { coderoadChallengeCompleted } from './schemas/challenge/coderoad-challenge-completed'; -import { exam } from './schemas/challenge/exam'; -import { examChallengeCompleted } from './schemas/challenge/exam-challenge-completed'; -import { modernChallengeCompleted } from './schemas/challenge/modern-challenge-completed'; -import { msTrophyChallengeCompleted } from './schemas/challenge/ms-trophy-challenge-completed'; -import { projectCompleted } from './schemas/challenge/project-completed'; -import { saveChallenge } from './schemas/challenge/save-challenge'; -import { deprecatedEndpoints } from './schemas/deprecated'; -import { chargeStripeCard } from './schemas/donate/charge-stripe-card'; -import { resubscribe } from './schemas/email-subscription/resubscribe'; -import { unsubscribe } from './schemas/email-subscription/unsubscribe'; -import { updateMyAbout } from './schemas/settings/update-my-about'; -import { updateMyClassroomMode } from './schemas/settings/update-my-classroom-mode'; -import { updateMyEmail } from './schemas/settings/update-my-email'; -import { updateMyHonesty } from './schemas/settings/update-my-honesty'; -import { updateMyKeyboardShortcuts } from './schemas/settings/update-my-keyboard-shortcuts'; -import { updateMyPortfolio } from './schemas/settings/update-my-portfolio'; -import { updateMyPrivacyTerms } from './schemas/settings/update-my-privacy-terms'; -import { updateMyProfileUI } from './schemas/settings/update-my-profile-ui'; -import { updateMyQuincyEmail } from './schemas/settings/update-my-quincy-email'; -import { updateMySocials } from './schemas/settings/update-my-socials'; -import { updateMyTheme } from './schemas/settings/update-my-theme'; -import { updateMyUsername } from './schemas/settings/update-my-username'; -import { deleteMsUsername } from './schemas/user/delete-ms-username'; -import { deleteMyAccount } from './schemas/user/delete-my-account'; -import { deleteUserToken } from './schemas/user/delete-user-token'; -import { getSessionUser } from './schemas/user/get-session-user'; -import { postMsUsername } from './schemas/user/post-ms-username'; -import { reportUser } from './schemas/user/report-user'; -import { resetMyProgress } from './schemas/user/reset-my-progress'; -import { submitSurvey } from './schemas/user/submit-survey'; - -export const schemas = { - backendChallengeCompleted, - certificateVerify, - certSlug, - chargeStripeCard, - coderoadChallengeCompleted, - deleteMyAccount, - deleteMsUsername, - deleteUserToken, - deprecatedEndpoints, - exam, - examChallengeCompleted, - getSessionUser, - modernChallengeCompleted, - msTrophyChallengeCompleted, - postMsUsername, - projectCompleted, - saveChallenge, - submitSurvey, - reportUser, - resetMyProgress, - resubscribe, - unsubscribe, - updateMyAbout, - updateMyClassroomMode, - updateMyEmail, - updateMyHonesty, - updateMyKeyboardShortcuts, - updateMyPortfolio, - updateMyPrivacyTerms, - updateMyProfileUI, - updateMyQuincyEmail, - updateMySocials, - updateMyTheme, - updateMyUsername -}; +export { certSlug } from './schemas/certificate/cert-slug'; +export { certificateVerify } from './schemas/certificate/certificate-verify'; +export { backendChallengeCompleted } from './schemas/challenge/backend-challenge-completed'; +export { coderoadChallengeCompleted } from './schemas/challenge/coderoad-challenge-completed'; +export { exam } from './schemas/challenge/exam'; +export { examChallengeCompleted } from './schemas/challenge/exam-challenge-completed'; +export { modernChallengeCompleted } from './schemas/challenge/modern-challenge-completed'; +export { msTrophyChallengeCompleted } from './schemas/challenge/ms-trophy-challenge-completed'; +export { projectCompleted } from './schemas/challenge/project-completed'; +export { saveChallenge } from './schemas/challenge/save-challenge'; +export { deprecatedEndpoints } from './schemas/deprecated'; +export { chargeStripeCard } from './schemas/donate/charge-stripe-card'; +export { resubscribe } from './schemas/email-subscription/resubscribe'; +export { unsubscribe } from './schemas/email-subscription/unsubscribe'; +export { updateMyAbout } from './schemas/settings/update-my-about'; +export { updateMyClassroomMode } from './schemas/settings/update-my-classroom-mode'; +export { updateMyEmail } from './schemas/settings/update-my-email'; +export { updateMyHonesty } from './schemas/settings/update-my-honesty'; +export { updateMyKeyboardShortcuts } from './schemas/settings/update-my-keyboard-shortcuts'; +export { updateMyPortfolio } from './schemas/settings/update-my-portfolio'; +export { updateMyPrivacyTerms } from './schemas/settings/update-my-privacy-terms'; +export { updateMyProfileUI } from './schemas/settings/update-my-profile-ui'; +export { updateMyQuincyEmail } from './schemas/settings/update-my-quincy-email'; +export { updateMySocials } from './schemas/settings/update-my-socials'; +export { updateMyTheme } from './schemas/settings/update-my-theme'; +export { updateMyUsername } from './schemas/settings/update-my-username'; +export { deleteMsUsername } from './schemas/user/delete-ms-username'; +export { deleteMyAccount } from './schemas/user/delete-my-account'; +export { deleteUserToken } from './schemas/user/delete-user-token'; +export { getSessionUser } from './schemas/user/get-session-user'; +export { postMsUsername } from './schemas/user/post-ms-username'; +export { reportUser } from './schemas/user/report-user'; +export { resetMyProgress } from './schemas/user/reset-my-progress'; +export { submitSurvey } from './schemas/user/submit-survey';