repo
stringlengths
7
64
file_url
stringlengths
81
338
file_path
stringlengths
5
257
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:25:31
2026-01-05 01:50:38
truncated
bool
2 classes
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/confirm-email.ts
api/src/schemas/settings/confirm-email.ts
import { Type } from '@fastify/type-provider-typebox'; export const confirmEmail = { querystring: Type.Object({ email: Type.String({ maxLength: 1000 }), token: Type.String({ minLength: 64, maxLength: 64 }) }) };
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-username.ts
api/src/schemas/settings/update-my-username.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyUsername = { body: Type.Object({ username: Type.String({ minLength: 3, maxLength: 1000 }) }), response: { 200: Type.Object({ message: Type.String(), type: Type.Literal('success'), variables: Type.Object({ userna...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-quincy-email.ts
api/src/schemas/settings/update-my-quincy-email.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyQuincyEmail = { body: Type.Object({ sendQuincyEmail: Type.Boolean() }), response: { 200: Type.Object({ message: Type.Literal('flash.subscribe-to-quincy-updated'), type: Type.Literal('success') }), 400: Type.Ob...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-portfolio.ts
api/src/schemas/settings/update-my-portfolio.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyPortfolio = { body: Type.Object({ portfolio: Type.Array( Type.Object({ description: Type.Optional(Type.String()), id: Type.Optional(Type.String()), image: Type.Optional(Type.String()), title: Type.Op...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-privacy-terms.ts
api/src/schemas/settings/update-my-privacy-terms.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyPrivacyTerms = { body: Type.Object({ quincyEmails: Type.Boolean() }), response: { 200: Type.Object({ message: Type.Literal('flash.privacy-updated'), type: Type.Literal('success') }), 400: Type.Object({ m...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-profile-ui.ts
api/src/schemas/settings/update-my-profile-ui.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyProfileUI = { body: Type.Object({ profileUI: Type.Object({ isLocked: Type.Boolean(), showAbout: Type.Boolean(), showCerts: Type.Boolean(), showDonation: Type.Boolean(), showHeatMap: Type.Boolean(), sho...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-theme.ts
api/src/schemas/settings/update-my-theme.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyTheme = { body: Type.Object({ theme: Type.Union([Type.Literal('default'), Type.Literal('night')]) }), response: { 200: Type.Object({ message: Type.Literal('flash.updated-themes'), type: Type.Literal('success') }),...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-email.ts
api/src/schemas/settings/update-my-email.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyEmail = { body: Type.Object({ email: Type.String({ format: 'email', maxLength: 1024 }) }), response: { 200: Type.Object({ message: Type.Literal( 'Check your email and click the link we sent you to confirm your new e...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-socials.ts
api/src/schemas/settings/update-my-socials.ts
import { Type } from '@fastify/type-provider-typebox'; const urlOrEmptyString = Type.Union([ Type.Literal(''), Type.String({ format: 'uri', maxLength: 1024 }) ]); export const updateMySocials = { body: Type.Object({ website: urlOrEmptyString, twitter: urlOrEmptyString, bluesky: urlOrEmptyString, ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-keyboard-shortcuts.ts
api/src/schemas/settings/update-my-keyboard-shortcuts.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyKeyboardShortcuts = { body: Type.Object({ keyboardShortcuts: Type.Boolean() }), response: { 200: Type.Object({ message: Type.Literal('flash.keyboard-shortcut-updated'), type: Type.Literal('success') }), 400: T...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/settings/update-my-honesty.ts
api/src/schemas/settings/update-my-honesty.ts
import { Type } from '@fastify/type-provider-typebox'; export const updateMyHonesty = { body: Type.Object({ isHonest: Type.Literal(true) }), response: { 200: Type.Object({ message: Type.Literal('buttons.accepted-honesty'), type: Type.Literal('success') }), 400: Type.Object({ mes...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/deprecated/index.ts
api/src/schemas/deprecated/index.ts
import { Type } from '@fastify/type-provider-typebox'; export const deprecatedEndpoints = { response: { 410: Type.Object({ message: Type.Object({ type: Type.Literal('info'), message: Type.Literal( 'Please reload the app, this feature is no longer available.' ) }) ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/users/get-public-profile.ts
api/src/schemas/users/get-public-profile.ts
import { Type } from '@fastify/type-provider-typebox'; import { profileUI, examResults } from '../types.js'; export const getPublicProfile = { querystring: Type.Object({ username: Type.String({ minLength: 1 }) }), response: { 200: Type.Object({ entities: Type.Object({ user: Type.Record( ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/users/exists.ts
api/src/schemas/users/exists.ts
import { Type } from '@fastify/type-provider-typebox'; export const userExists = { querystring: Type.Object({ username: Type.String({ minLength: 1 }) }), response: { 200: Type.Object({ exists: Type.Boolean() }), 400: Type.Object({ type: Type.Literal('danger'), message: Type.Lite...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/ms-trophy-challenge-completed.ts
api/src/schemas/challenge/ms-trophy-challenge-completed.ts
import { Type } from '@fastify/type-provider-typebox'; export const msTrophyChallengeCompleted = { body: Type.Object({ id: Type.String({ format: 'objectid', maxLength: 24, minLength: 24 }) }), response: { 200: Type.Object({ completedDate: Type.Number(), points: Type.Number(), alreadyCom...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/daily-coding-challenge-completed.ts
api/src/schemas/challenge/daily-coding-challenge-completed.ts
import { Type } from '@fastify/type-provider-typebox'; // This has to be declared as a tuple, because Type.Union expects a // tuple of types, not an array of unions of said types. const languages: [Type.TLiteral<'javascript'>, Type.TLiteral<'python'>] = [ Type.Literal('javascript'), Type.Literal('python') ]; expo...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/submit-quiz-attempt.ts
api/src/schemas/challenge/submit-quiz-attempt.ts
import { Type } from '@fastify/type-provider-typebox'; import { genericError } from '../types.js'; export const submitQuizAttempt = { body: Type.Object({ challengeId: Type.String({ format: 'objectid', maxLength: 24, minLength: 24 }), quizId: Type.String() }), response: { 200: Ty...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/exam.ts
api/src/schemas/challenge/exam.ts
import { Type } from '@fastify/type-provider-typebox'; import { genericError } from '../types.js'; export const exam = { params: Type.Object({ id: Type.String({ format: 'objectid', maxLength: 24, minLength: 24 }) }), response: { 200: Type.Object({ generatedExam: Type.Array( ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/project-completed.ts
api/src/schemas/challenge/project-completed.ts
import { Type } from '@fastify/type-provider-typebox'; import { genericError } from '../types.js'; export const projectCompleted = { body: Type.Object({ id: Type.String({ format: 'objectid', maxLength: 24, minLength: 24 }), challengeType: Type.Optional(Type.Number()), // The solution must be a valid URL ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/backend-challenge-completed.ts
api/src/schemas/challenge/backend-challenge-completed.ts
import { Type } from '@fastify/type-provider-typebox'; import { genericError } from '../types.js'; export const backendChallengeCompleted = { body: Type.Object({ id: Type.String({ format: 'objectid', maxLength: 24, minLength: 24 }) }), response: { 200: Type.Object({ completedDate: Type.Number(), ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/exam-challenge-completed.ts
api/src/schemas/challenge/exam-challenge-completed.ts
import { Type } from '@fastify/type-provider-typebox'; import { examResults, genericError } from '../types.js'; export const examChallengeCompleted = { body: Type.Object({ id: Type.String({ format: 'objectid', maxLength: 24, minLength: 24 }), challengeType: Type.Number(), userCompletedExam: Type.Object({...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/coderoad-challenge-completed.ts
api/src/schemas/challenge/coderoad-challenge-completed.ts
import { Type } from '@fastify/type-provider-typebox'; export const coderoadChallengeCompleted = { body: Type.Object({ tutorialId: Type.String() }), headers: Type.Object({ 'coderoad-user-token': Type.String() }), response: { 200: Type.Object({ type: Type.Literal('success'), msg: Type.String...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/save-challenge.ts
api/src/schemas/challenge/save-challenge.ts
import { Type } from '@fastify/type-provider-typebox'; import { file, genericError, savedChallenge } from '../types.js'; export const saveChallenge = { body: Type.Object({ id: Type.String({ format: 'objectid', maxLength: 24, minLength: 24 }), files: Type.Array(file) }), response: { ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/schemas/challenge/modern-challenge-completed.ts
api/src/schemas/challenge/modern-challenge-completed.ts
import { Type } from '@fastify/type-provider-typebox'; import { genericError, savedChallenge } from '../types.js'; export const modernChallengeCompleted = { body: Type.Object({ id: Type.String({ format: 'objectid', maxLength: 24, minLength: 24 }), challengeType: Type.Number(), files: Type.Optional( ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/db/prisma.ts
api/src/db/prisma.ts
import fp from 'fastify-plugin'; import { FastifyPluginAsync } from 'fastify'; import { PrismaClient } from '@prisma/client'; // importing MONGOHQ_URL so we can mock it in testing. import { MONGOHQ_URL } from '../utils/env.js'; declare module 'fastify' { interface FastifyInstance { prisma: ReturnType<typeof ext...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/db/extensions.test.ts
api/src/db/extensions.test.ts
import { describe, it, expect, beforeEach, afterAll } from 'vitest'; import { defaultUserEmail, setupServer } from '../../vitest.utils.js'; import { createUserInput } from '../utils/create-user.js'; describe('prisma client extensions', () => { setupServer(); beforeEach(async () => { await fastifyTestInstance...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/schemas/exam-environment-exam-generated-exam.ts
api/src/exam-environment/schemas/exam-environment-exam-generated-exam.ts
import { Type } from '@fastify/type-provider-typebox'; import { STANDARD_ERROR } from '../utils/errors.js'; export const examEnvironmentPostExamGeneratedExam = { body: Type.Object({ examId: Type.String() }), headers: Type.Object({ 'exam-environment-authorization-token': Type.String() }), response: { ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/schemas/exam-environment-exam-attempt.ts
api/src/exam-environment/schemas/exam-environment-exam-attempt.ts
import { Type } from '@fastify/type-provider-typebox'; import { STANDARD_ERROR } from '../utils/errors.js'; export const examEnvironmentPostExamAttempt = { body: Type.Object({ attempt: Type.Object({ examId: Type.String({ format: 'objectid' }), questionSets: Type.Array( Type.Object({ ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/schemas/challenges.ts
api/src/exam-environment/schemas/challenges.ts
import { Type } from '@fastify/type-provider-typebox'; // import { STANDARD_ERROR } from '../utils/errors'; export const examEnvironmentGetExamChallenge = { querystring: Type.Object({ challengeId: Type.Optional(Type.String({ format: 'objectid' })), examId: Type.Optional(Type.String({ format: 'objectid' })) ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/schemas/token-meta.ts
api/src/exam-environment/schemas/token-meta.ts
import { Type } from '@fastify/type-provider-typebox'; import { STANDARD_ERROR } from '../utils/errors.js'; export const examEnvironmentTokenMeta = { headers: Type.Object({ 'exam-environment-authorization-token': Type.String() }), response: { 200: Type.Object({ expireAt: Type.String({ format: 'date...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/schemas/exam-environment-exams.ts
api/src/exam-environment/schemas/exam-environment-exams.ts
import { Type } from '@fastify/type-provider-typebox'; import { STANDARD_ERROR } from '../utils/errors.js'; export const examEnvironmentExams = { headers: Type.Object({ 'exam-environment-authorization-token': Type.Optional(Type.String()) }), response: { 200: Type.Array( Type.Object({ id: Typ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/schemas/index.ts
api/src/exam-environment/schemas/index.ts
export { examEnvironmentPostExamAttempt, examEnvironmentGetExamAttempts, examEnvironmentGetExamAttempt, examEnvironmentGetExamAttemptsByExamId } from './exam-environment-exam-attempt.js'; export { examEnvironmentPostExamGeneratedExam } from './exam-environment-exam-generated-exam.js'; export { examEnvironmentTo...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/routes/exam-environment.ts
api/src/exam-environment/routes/exam-environment.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { PrismaClientValidationError } from '@prisma/client/runtime/library.js'; import { type FastifyInstance, type FastifyReply } from 'fastify'; import { ExamEnvironmentExamModerationStatus } from '@prisma/client'; import jwt from 'j...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/routes/exam-environment.test.ts
api/src/exam-environment/routes/exam-environment.test.ts
import { describe, it, expect, beforeAll, afterAll, beforeEach, afterEach, vi } from 'vitest'; import { ExamEnvironmentExamModerationStatus } from '@prisma/client'; import { Static } from '@fastify/type-provider-typebox'; import jwt from 'jsonwebtoken'; import { createSuperRequest, defaultUserId, ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
true
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/utils/errors.ts
api/src/exam-environment/utils/errors.ts
import { format } from 'util'; import { Type } from '@fastify/type-provider-typebox'; export const ERRORS = { FCC_EINVAL_EXAM_ENVIRONMENT_AUTHORIZATION_TOKEN: createError( 'FCC_EINVAL_EXAM_ENVIRONMENT_AUTHORIZATION_TOKEN', '%s' ), FCC_EINVAL_EXAM_ENVIRONMENT_PREREQUISITES: createError( 'FCC_EINVAL_EX...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/utils/exam-environment.ts
api/src/exam-environment/utils/exam-environment.ts
// TODO: enable this, since strings don't make good errors. /* eslint-disable @typescript-eslint/only-throw-error */ import { ExamEnvironmentAnswer, ExamEnvironmentConfig, ExamEnvironmentExam, ExamEnvironmentExamAttempt, ExamEnvironmentExamModerationStatus, ExamEnvironmentGeneratedExam, ExamEnvironmentGen...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/exam-environment/utils/exam-environment.test.ts
api/src/exam-environment/utils/exam-environment.test.ts
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'; import { ExamEnvironmentAnswer, ExamEnvironmentQuestionType } from '@prisma/client'; import { type Static } from '@fastify/type-provider-typebox'; import { exam, examAttempt, generatedExam, oid } from '../../../__mocks__/exam-environmen...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/helpers/challenge-helpers.ts
api/src/routes/helpers/challenge-helpers.ts
/** * Confirm that a user can submit a CodeRoad project. * * @param id The id of the project. * @param param The challenges the user has completed. * @param param.partiallyCompletedChallenges The partially completed challenges. * @param param.completedChallenges The completed challenges. * @returns A boolean ind...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/helpers/auth-helpers.ts
api/src/routes/helpers/auth-helpers.ts
import { FastifyInstance } from 'fastify'; import { createUserInput } from '../../utils/create-user.js'; /** * Finds an existing user with the given email or creates a new user if none exists. * @param fastify - The Fastify instance. * @param email - The email of the user. * @returns The existing or newly created ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/helpers/challenge-helpers.test.ts
api/src/routes/helpers/challenge-helpers.test.ts
import { describe, test, expect, afterEach, vi } from 'vitest'; import type { PartiallyCompletedChallenge, CompletedChallenge } from '@prisma/client'; import { createFetchMock } from '../../../vitest.utils.js'; import { canSubmitCodeRoadCertProject, verifyTrophyWithMicrosoft, decodeFiles, decodeBase64, e...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/helpers/certificate-utils.ts
api/src/routes/helpers/certificate-utils.ts
import { Prisma } from '@prisma/client'; import { certSlugTypeMap, certToIdMap, Certification } from '../../../../shared/config/certification-settings.js'; import { normalizeDate } from '../../utils/normalize.js'; const fullStackCertificateIds = [ certToIdMap[Certification.RespWebDesign], certToIdMap[Certifi...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/helpers/is-restricted.ts
api/src/routes/helpers/is-restricted.ts
import { isProfane } from 'no-profanity'; import { blocklistedUsernames } from '../../../../shared/config/constants.js'; /** * Checks if a username is restricted (i.e. It's profane or reserved). * @param username - The username to check. * @returns True if the username is restricted, false otherwise. */ export co...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/helpers/user-utils.ts
api/src/routes/helpers/user-utils.ts
import { pick, omit } from 'lodash-es'; // user flags that the api-server returns as false if they're missing in the // user document. Since Prisma returns null for missing fields, we need to // normalize them to false. // TODO(Post-MVP): remove this when the database is normalized. const nullableFlags = [ 'is2018Da...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/helpers/auth-helpers.test.ts
api/src/routes/helpers/auth-helpers.test.ts
import { describe, test, expect, beforeAll, afterEach, afterAll, vi } from 'vitest'; import Fastify, { FastifyInstance } from 'fastify'; import db from '../../db/prisma.js'; import { createUserInput } from '../../utils/create-user.js'; import { checkCanConnectToDb } from '../../../vitest.utils.js'; impor...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/helpers/certificate-utils.test.ts
api/src/routes/helpers/certificate-utils.test.ts
import { describe, test, expect } from 'vitest'; import { getFallbackFullStackDate } from './certificate-utils.js'; const fullStackChallenges = [ { completedDate: 1585210952511, id: '5a553ca864b52e1d8bceea14' }, { completedDate: 1585210952511, id: '561add10cb82ac38a17513bc' }, { complete...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/donate.test.ts
api/src/routes/protected/donate.test.ts
import { describe, test, expect, beforeEach, vi } from 'vitest'; import { createSuperRequest, devLogin, setupServer, defaultUserEmail, defaultUserId } from '../../../vitest.utils.js'; import { createUserInput } from '../../utils/create-user.js'; const testEWalletEmail = 'baz@bar.com'; const testSubscriptionI...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/settings.test.ts
api/src/routes/protected/settings.test.ts
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { describe, test, expect, beforeAll, afterEach, beforeEach, vi, MockInstance } from 'vitest'; import { devLogin, setupServer, superRequest, createSuperRequest, defaultUserId, defaultUserEmail } from '../../../vitest.utils...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
true
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/user.test.ts
api/src/routes/protected/user.test.ts
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { describe, test, expect, beforeEach, afterEach, beforeAll, afterAll, vi, MockInstance } from 'vitest'; import ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
true
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/certificate.test.ts
api/src/routes/protected/certificate.test.ts
import { describe, test, expect, beforeAll, afterEach, beforeEach, vi } from 'vitest'; import { Certification } from '../../../../shared/config/certification-settings.js'; import { defaultUserEmail, defaultUserId, devLogin, resetDefaultUser, setupServer, superRequest } from '../../../vitest.u...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/certificate.ts
api/src/routes/protected/certificate.ts
import type { CompletedChallenge } from '@prisma/client'; import validator from 'validator'; import type { FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { challenges, getChallenges } from '../../utils/get-challenges.js'; import { Certification, type CertificationFlags, certSlugType...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/settings.ts
api/src/routes/protected/settings.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import type { FastifyInstance } from 'fastify'; import { differenceInMinutes } from 'date-fns'; import validator from 'validator'; import { isValidUsername } from '../../../../shared/utils/validate.js'; import * as schemas from '../../...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/challenge.test.ts
api/src/routes/protected/challenge.test.ts
import { describe, test, expect, beforeAll, afterEach, beforeEach, afterAll, vi } from 'vitest'; vi.mock('../helpers/challenge-helpers', async () => { const originalModule = await vi.importActual< typeof import('../helpers/challenge-helpers.js') >('../helpers/challenge-helpers'); return { ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
true
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/user.ts
api/src/routes/protected/user.ts
import type { FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { ObjectId } from 'mongodb'; import { FastifyInstance, FastifyReply } from 'fastify'; import jwt from 'jsonwebtoken'; import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library.js'; import * as schemas from '....
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/challenge.ts
api/src/routes/protected/challenge.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import jwt from 'jsonwebtoken'; import { CompletedExam, ExamResults, SavedChallengeFile } from '@prisma/client'; import type { FastifyBaseLogger, FastifyInstance, FastifyReply } from 'fastify'; import { uniqBy, matches } from 'lodash-es...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
true
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/index.ts
api/src/routes/protected/index.ts
export * from './certificate.js'; export * from './challenge.js'; export * from './donate.js'; export * from './settings.js'; export * from './user.js';
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/protected/donate.ts
api/src/routes/protected/donate.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import Stripe from 'stripe'; import * as schemas from '../../schemas.js'; import { donationSubscriptionConfig } from '../../../../shared/config/donation-settings.js'; import { STRIPE_SECRET_KEY, HOME_LOCATION } from '../../utils/env.js...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/deprecated-unsubscribe.ts
api/src/routes/public/deprecated-unsubscribe.ts
import { FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { getRedirectParams } from '../../utils/redirection.js'; type Endpoint = [string, 'GET' | 'POST']; export const unsubscribeEndpoints: Endpoint[] = [ ['/u/:email', 'GET'], ['/unsubscribe/:email', 'GET'] ]; /** * Plugin for the...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/deprecated-endpoints.ts
api/src/routes/public/deprecated-endpoints.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import * as schemas from '../../schemas.js'; type Endpoints = [string, 'GET' | 'POST'][]; export const endpoints: Endpoints = [ ['/refetch-user-completed-challenges', 'POST'], ['/certificate/verify-can-claim-cert', 'GET'], ['/a...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/auth.test.ts
api/src/routes/public/auth.test.ts
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { describe, it, expect, vi, beforeAll, beforeEach } from 'vitest'; import { setupServer, superRequest, createSuperRequest } from '../../../vitest.utils.js'; import { AUTH0_DOMAIN } from '../../utils/env.js'; const mockedFetch = vi.fn(); vi.sp...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/donate.test.ts
api/src/routes/public/donate.test.ts
import { describe, test, expect, beforeAll, vi } from 'vitest'; import { setupServer, superRequest } from '../../../vitest.utils.js'; const testEWalletEmail = 'baz@bar.com'; const testSubscriptionId = 'sub_test_id'; const testCustomerId = 'cust_test_id'; const sharedDonationReqBody = { amount: 500, duration: 'mon...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/sentry.ts
api/src/routes/public/sentry.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { type FastifyInstance, type FastifyReply } from 'fastify'; import { UpdateReqType } from '../../utils/index.js'; import * as schemas from '../../schemas.js'; /** * Plugin for Sentry-related endpoints. * * @param fastify The...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/email-subscription.ts
api/src/routes/public/email-subscription.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import * as schemas from '../../schemas.js'; import { getRedirectParams } from '../../utils/redirection.js'; /** * Endpoints to set 'sendQuincyEmail' to true or false using 'unsubscribeId'. * * @param fastify The Fastify instance. ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/user.test.ts
api/src/routes/public/user.test.ts
import type { Prisma } from '@prisma/client'; import { ObjectId } from 'mongodb'; import { omit } from 'lodash-es'; import { describe, it, test, expect, beforeAll, beforeEach, afterAll, vi } from 'vitest'; import { createUserInput } from '../../utils/create-user.js'; import { defaultUserEmail, setu...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/status.test.ts
api/src/routes/public/status.test.ts
import { describe, test, expect } from 'vitest'; import { setupServer, superRequest } from '../../../vitest.utils.js'; import { DEPLOYMENT_VERSION } from '../../utils/env.js'; describe('/status', () => { setupServer(); test('GET returns 200 status code with pong', async () => { const response = await superReq...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/auth.ts
api/src/routes/public/auth.ts
import type { FastifyPluginCallback, FastifyRequest } from 'fastify'; import validator from 'validator'; import { AUTH0_DOMAIN } from '../../utils/env.js'; import { auth0Client } from '../../plugins/auth0.js'; import { createAccessToken } from '../../utils/tokens.js'; import { findOrCreateUser } from '../helpers/auth-...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/auth-dev.ts
api/src/routes/public/auth-dev.ts
import type { FastifyPluginCallback } from 'fastify'; import { devAuth } from '../../plugins/auth-dev.js'; /** * Route handler for development login. * * @deprecated * @param fastify The Fastify instance. * @param _options Options passed to the plugin via `fastify.register(plugin, * options)`. * @param done Ca...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/certificate.test.ts
api/src/routes/public/certificate.test.ts
import { describe, it, test, expect, beforeAll, beforeEach, afterAll, vi } from 'vitest'; import { defaultUserEmail, defaultUserId, resetDefaultUser, setupServer, superRequest } from '../../../vitest.utils.js'; import { getFallbackFullStackDate } from '../helpers/certificate-utils.js'; const ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/certificate.ts
api/src/routes/public/certificate.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { find } from 'lodash-es'; import * as schemas from '../../schemas.js'; import { certSlugTypeMap, certToTitleMap, certToIdMap, completionHours, oldDataVizId } from '../../../../shared/config/certification-settings.js';...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/deprecated-endpoints.test.ts
api/src/routes/public/deprecated-endpoints.test.ts
import request from 'supertest'; import { describe, test, expect } from 'vitest'; import { setupServer } from '../../../vitest.utils.js'; import { endpoints } from './deprecated-endpoints.js'; describe('Deprecated endpoints', () => { setupServer(); endpoints.forEach(([endpoint, method]) => { test(`${method} ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/deprecated-unsubscribe.test.ts
api/src/routes/public/deprecated-unsubscribe.test.ts
import { describe, test, expect } from 'vitest'; import { setupServer, superRequest } from '../../../vitest.utils.js'; import { unsubscribeEndpoints } from './deprecated-unsubscribe.js'; const urlEncodedMessage = '?messages=info%5B0%5D%3DWe%2520are%2520no%2520longer%2520able%2520to%2520process%2520this%2520unsubscr...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/user.ts
api/src/routes/public/user.ts
import { Portfolio } from '@prisma/client'; import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { ObjectId } from 'mongodb'; import { omit } from 'lodash-es'; import { isRestricted } from '../helpers/is-restricted.js'; import * as schemas from '../../schemas.js'; import { splitUs...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/status.ts
api/src/routes/public/status.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import { DEPLOYMENT_VERSION } from '../../utils/env.js'; /** * Plugin for the health check endpoint. * * @param fastify The Fastify instance. * @param _options Options passed to the plugin via `fastify.register(plugin, * options)...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/index.ts
api/src/routes/public/index.ts
export * from './auth-dev.js'; export * from './auth.js'; export * from './certificate.js'; export * from './deprecated-endpoints.js'; export * from './deprecated-unsubscribe.js'; export * from './donate.js'; export * from './email-subscription.js'; export * from './signout.js'; export * from './status.js'; export * fr...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/email-subscription.test.ts
api/src/routes/public/email-subscription.test.ts
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import type { Prisma } from '@prisma/client'; import { describe, test, expect } from 'vitest'; import { setupServer, superRequest } from '../../../vitest.utils.js'; import { HOME_LOCATION } from '../../utils/env.js'; import { createUserInput } from '../../...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/donate.ts
api/src/routes/public/donate.ts
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox'; import Stripe from 'stripe'; import { STRIPE_SECRET_KEY } from '../../utils/env.js'; import { donationSubscriptionConfig, allStripeProductIdsArray } from '../../../../shared/config/donation-settings.js'; import * as schemas from '....
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/signout.ts
api/src/routes/public/signout.ts
import type { FastifyPluginCallback } from 'fastify'; import { signout } from '../../schemas.js'; /** * Route handler for signing out. * * @param fastify The Fastify instance. * @param _options Options passed to the plugin via `fastify.register(plugin, * options)`. * @param done Callback to signal that the logi...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/routes/public/signout.test.ts
api/src/routes/public/signout.test.ts
import { describe, it, expect, beforeEach } from 'vitest'; import { devLogin, setupServer, superRequest } from '../../../vitest.utils.js'; describe('GET /signout', () => { setupServer(); beforeEach(async () => { await devLogin(); }); it('should clear all the cookies', async () => { const res = await s...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/allowed-origins.ts
api/src/utils/allowed-origins.ts
import { HOME_LOCATION, FREECODECAMP_NODE_ENV } from './env.js'; const ALLOWED_ORIGINS = [ 'https://www.freecodecamp.dev', 'https://www.freecodecamp.org', // pretty sure the rest of these can go? 'https://beta.freecodecamp.dev', 'https://beta.freecodecamp.org', 'https://chinese.freecodecamp.dev', 'https:...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/index.test.ts
api/src/utils/index.test.ts
import { describe, test, expect } from 'vitest'; import { base64URLEncode, challenge, verifier } from './index.js'; describe('utils', () => { test('base64URLEncode', () => { expect(base64URLEncode(Buffer.from('test'))).toEqual('dGVzdA'); }); test('verifier', () => { expect(verifier).toHaveLength(43); ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/exam.ts
api/src/utils/exam.ts
import { Exam, Question } from '@prisma/client'; import { shuffleArray } from './../../../shared/utils/shuffle-array.js'; import { UserExam, GeneratedExam } from './exam-types.js'; /** * Remove objects from array with deprecated: true. * * @param arr An array. * @returns The array without objects that have depreca...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/progress.ts
api/src/utils/progress.ts
export type ProgressTimestamp = number | { timestamp: number } | null; export type Calendar = Record<number, 1>; /** * Converts a ProgressTimestamp array to a object with keys based on the timestamps. * * @param progressTimestamps The ProgressTimestamp array. * @returns The object with keys based on the timestamps....
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/email-templates.ts
api/src/utils/email-templates.ts
import { user } from '@prisma/client'; /** * Generates an email template for reporting a user profile. * @param reporter - The user who is reporting the profile. * @param abuser - The username of the user being reported. * @param reportDesc - The description of the report. * @returns - The generated email templat...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/common-challenge-functions.ts
api/src/utils/common-challenge-functions.ts
import type { ExamResults, user, Prisma } from '@prisma/client'; import { FastifyInstance } from 'fastify'; import { omit, pick } from 'lodash-es'; import { challengeTypes } from '../../../shared/config/challenge-types.js'; import { challenges, savableChallenges } from './get-challenges.js'; import { normalizeDate } fr...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/tokens.test.ts
api/src/utils/tokens.test.ts
import { describe, test, expect, vi } from 'vitest'; vi.useFakeTimers(); /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { createAccessToken, createAuthToken, isExpired } from './tokens.js'; describe('createAccessToken', () => { test('creates an object with id, ttl, created and userId', () => { ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/normalize.test.ts
api/src/utils/normalize.test.ts
import { describe, test, expect } from 'vitest'; import { normalizeTwitter, normalizeBluesky, normalizeProfileUI, normalizeChallenges, normalizeFlags, normalizeDate, normalizeChallengeType } from './normalize.js'; describe('normalize', () => { describe('normalizeTwitter', () => { test('returns the ...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/validation.ts
api/src/utils/validation.ts
import { ObjectId } from 'mongodb'; // This is trivial, but makes it simple to refactor if we swap monogodb for // bson, say. /** * Checks if a string is a valid MongoDB ObjectID. * @param id A string to check. * @returns A boolean indicating if the string is a valid MongoDB ObjectID. */ export const isObjectID =...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/exam-schemas.ts
api/src/utils/exam-schemas.ts
import { Answer, Exam, Question, ExamResults } from '@prisma/client'; import Joi from 'joi'; import { GeneratedExam, UserExam } from './exam-types.js'; const nanoIdRE = new RegExp('[a-z0-9]{10}'); const objectIdRE = new RegExp('^[0-9a-fA-F]{24}$'); // Exam from database schema const DbPrerequisitesJoi = Joi.object()....
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/redirection.test.ts
api/src/utils/redirection.test.ts
import { describe, test, expect, vi } from 'vitest'; import jwt from 'jsonwebtoken'; import { getReturnTo, normalizeParams, getRedirectParams, getPrefixedLandingPath, getLoginRedirectParams } from './redirection.js'; import { HOME_LOCATION } from './env.js'; const validJWTSecret = 'this is a super secret st...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/tokens.ts
api/src/utils/tokens.ts
import jwt from 'jsonwebtoken'; import { customNanoid } from './ids.js'; import { JWT_SECRET } from './env.js'; /** * Encode an id into a JWT (the naming suggests it's a user token, but it's the * id of the UserToken document). * @param userToken A token id to encode. * @returns An encoded object with the userTok...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/exam-types.ts
api/src/utils/exam-types.ts
export interface Answer { id: string; answer: string; } // types for a generated exam interface GeneratedQuestion { id: string; question: string; answers: Answer[]; } export type GeneratedExam = GeneratedQuestion[]; // types for a user completed exam (from client) interface UserQuestion { id: string; q...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/validation.test.ts
api/src/utils/validation.test.ts
import { describe, it, expect } from 'vitest'; import { isObjectID } from './validation.js'; describe('Validation', () => { describe('isObjectID', () => { it('returns true for valid ObjectIDs', () => { expect(isObjectID('5f1e0f3b5d2c12b0b8f7a6b9')).toBe(true); }); it('returns false for invalid Obj...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/create-user.ts
api/src/utils/create-user.ts
import crypto from 'node:crypto'; import { customAlphabet } from 'nanoid'; export const nanoidCharSet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; const nanoid = customAlphabet(nanoidCharSet, 21); /** * Creates the necessary data to reset a user's properties. * @returns Default data for re...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/env.ts
api/src/utils/env.ts
import assert from 'node:assert'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { config } from 'dotenv'; import { LogLevel } from 'fastify'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const envPath = path.resolve(__dirname, '../../../.env'); const { error } = conf...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/get-challenges.test.ts
api/src/utils/get-challenges.test.ts
import { describe, test, expect } from 'vitest'; import { getChallenges } from './get-challenges.js'; import { isObjectID } from './validation.js'; describe('getChallenges', () => { test('returns an array of challenges', () => { const challenges = getChallenges(); expect(Array.isArray(challenges)).toBe(true)...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/progress.test.ts
api/src/utils/progress.test.ts
import { describe, test, expect } from 'vitest'; import { getCalendar, getPoints } from './progress.js'; describe('utils/progress', () => { describe('getCalendar', () => { test('should return an empty object if no timestamps are passed', () => { expect(getCalendar([])).toEqual({}); expect(getCalendar...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/get-challenges.ts
api/src/utils/get-challenges.ts
// TODO: keeping curriculum in memory is handy if we want to field requests that // need to 'query' the curriculum, but if we force the client to handle // redirectToCurrentChallenge and, instead, only report the current challenge id // via the user object, then we should *not* store this so it can be garbage // collec...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/validate-donation.ts
api/src/utils/validate-donation.ts
/** * Checks if a timestamp was created within five minutes. * @param unixTimestamp - A unix timestamp . * @returns - The generated email template. */ export const inLastFiveMinutes = (unixTimestamp: number) => { const currentTimestamp = Math.floor(Date.now() / 1000); const timeDifference = currentTimestamp - u...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/validate-donation.test.ts
api/src/utils/validate-donation.test.ts
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'; import { inLastFiveMinutes } from './validate-donation.js'; describe('inLastFiveMinutes', () => { beforeAll(() => { vi.useFakeTimers(); }); afterAll(() => { vi.useRealTimers(); }); it('should return true if the timestamp is wit...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/logger.ts
api/src/utils/logger.ts
import { Transform, TransformCallback, TransformOptions } from 'stream'; import { FastifyRequest, FastifyReply } from 'fastify'; import { isEmpty } from 'lodash-es'; import type { TransportTargetOptions, // DestinationStream, LoggerOptions, DestinationStream } from 'pino'; import { pino, transport } from 'pino'...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false
freeCodeCamp/freeCodeCamp
https://github.com/freeCodeCamp/freeCodeCamp/blob/7d58ef2062b457d9370a7f730fc875f92ad28a80/api/src/utils/exam.test.ts
api/src/utils/exam.test.ts
import { describe, it, expect } from 'vitest'; import { Exam, Question } from '@prisma/client'; import { examJson, examWithZeroCorrect, examWithOneCorrect, examWithTwoCorrect, examWithAllCorrect, mockResultsZeroCorrect, mockResultsOneCorrect, mockResultsTwoCorrect, mockResultsAllCorrect } from '../../...
typescript
BSD-3-Clause
7d58ef2062b457d9370a7f730fc875f92ad28a80
2026-01-04T15:25:31.297347Z
false