refactor(api): simplify schema export (#54722)

pull/54740/head
Oliver Eyton-Williams 2024-05-10 08:53:38 +02:00 committed by GitHub
parent ae1bc60cab
commit ab2f5a3004
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 42 additions and 79 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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'][];

View File

@ -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';
/**

View File

@ -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';
/**

View File

@ -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;

View File

@ -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';

View File

@ -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 });

View File

@ -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';