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
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/comments/resumeCommentConstants.ts
apps/portal/src/components/resumes/comments/resumeCommentConstants.ts
import { ResumesSection } from '@prisma/client'; export const RESUME_COMMENTS_SECTIONS = [ { label: 'General', value: ResumesSection.GENERAL, }, { label: 'Education', value: ResumesSection.EDUCATION, }, { label: 'Experience', value: ResumesSection.EXPERIENCE, }, { label: 'Proj...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/comments/comment/ResumeCommentDeleteForm.tsx
apps/portal/src/components/resumes/comments/comment/ResumeCommentDeleteForm.tsx
import { Button, Dialog } from '~/ui'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { trpc } from '~/utils/trpc'; type ResumeCommentDeleteFormProps = Readonly<{ id: string; isDeletingComment: boolean; setIsDeletingComment: (value: boolean) => void; }>; export default functio...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/comments/comment/ResumeCommentReplyForm.tsx
apps/portal/src/components/resumes/comments/comment/ResumeCommentReplyForm.tsx
import type { SubmitHandler } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import type { ResumesSection } from '@prisma/client'; import { Button, TextArea } from '~/ui'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { trpc } from '~/utils/trpc'; type ResumeCom...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/comments/comment/ResumeCommentEditForm.tsx
apps/portal/src/components/resumes/comments/comment/ResumeCommentEditForm.tsx
import type { SubmitHandler } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import { Button, TextArea } from '~/ui'; import { trpc } from '~/utils/trpc'; import type { ResumeComment } from '~/types/resume-comments'; type ResumeCommentEditFormProps = { comment: ResumeComment; setIsEditingComm...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/comments/comment/ResumeCommentVoteButtons.tsx
apps/portal/src/components/resumes/comments/comment/ResumeCommentVoteButtons.tsx
import clsx from 'clsx'; import { useRouter } from 'next/router'; import { useState } from 'react'; import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/solid'; import { Vote } from '@prisma/client'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import loginPageHref from '~/c...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/shared/ResumeExpandableText.tsx
apps/portal/src/components/resumes/shared/ResumeExpandableText.tsx
import clsx from 'clsx'; import { useLayoutEffect, useRef, useState } from 'react'; type ResumeExpandableTextProps = Readonly<{ text: string; }>; export default function ResumeExpandableText({ text, }: ResumeExpandableTextProps) { const ref = useRef<HTMLSpanElement>(null); const [isExpanded, setIsExpanded] = ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/shared/ResumeSignInButton.tsx
apps/portal/src/components/resumes/shared/ResumeSignInButton.tsx
import clsx from 'clsx'; import Link from 'next/link'; import loginPageHref from '~/components/shared/loginPageHref'; type Props = Readonly<{ className?: string; text: string; }>; export default function ResumeSignInButton({ text, className }: Props) { return ( <div className={clsx('flex justify-center', c...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/shared/ResumeExperienceTypeahead.tsx
apps/portal/src/components/resumes/shared/ResumeExperienceTypeahead.tsx
import type { ComponentProps } from 'react'; import { useState } from 'react'; import type { TypeaheadOption } from '~/ui'; import { Typeahead } from '~/ui'; import { EXPERIENCES } from '~/utils/resumes/resumeFilters'; type BaseProps = Pick< ComponentProps<typeof Typeahead>, | 'disabled' | 'errorMessage' | 'i...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/resumes/submit-form/ResumeSubmissionGuidelines.tsx
apps/portal/src/components/resumes/submit-form/ResumeSubmissionGuidelines.tsx
export default function ResumeSubmissionGuidelines() { return ( <div className="rounded-lg border border-slate-200 bg-slate-50 p-5"> <div className="prose text-sm"> <h2 className="mt-0 text-xl font-medium">Submission Guidelines</h2> <p> Before submitting your resume for review, ple...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/CitiesTypeahead.tsx
apps/portal/src/components/shared/CitiesTypeahead.tsx
import type { ComponentProps } from 'react'; import { useState } from 'react'; import type { TypeaheadOption } from '~/ui'; import { Typeahead } from '~/ui'; import { trpc } from '~/utils/trpc'; type BaseProps = Pick< ComponentProps<typeof Typeahead>, | 'disabled' | 'errorMessage' | 'isLabelHidden' | 'place...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/CountriesTypeahead.tsx
apps/portal/src/components/shared/CountriesTypeahead.tsx
import type { ComponentProps } from 'react'; import { useState } from 'react'; import type { TypeaheadOption } from '~/ui'; import { Typeahead } from '~/ui'; import useCountryOptions from '~/utils/shared/useCountryOptions'; type BaseProps = Pick< ComponentProps<typeof Typeahead>, | 'disabled' | 'errorMessage' ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/JobTitlesTypeahead.tsx
apps/portal/src/components/shared/JobTitlesTypeahead.tsx
import type { ComponentProps } from 'react'; import { useState } from 'react'; import type { TypeaheadOption } from '~/ui'; import { Typeahead } from '~/ui'; import useJobTitleOptions from '~/utils/shared/useJobTitleOptions'; type BaseProps = Pick< ComponentProps<typeof Typeahead>, | 'disabled' | 'errorMessage'...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/loginPageHref.ts
apps/portal/src/components/shared/loginPageHref.ts
export default function loginPageHref(redirectUrl?: string) { return { pathname: '/login', query: { callbackUrl: typeof window !== 'undefined' ? redirectUrl ?? window.location.href : null, }, }; }
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/MonthYearPicker.tsx
apps/portal/src/components/shared/MonthYearPicker.tsx
import clsx from 'clsx'; import { useEffect, useId, useState } from 'react'; import { Select } from '~/ui'; export type Month = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; export type MonthYear = Readonly<{ month: Month; year: number; }>; export type MonthYearOptional = Readonly<{ month: Month | null; ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/Container.tsx
apps/portal/src/components/shared/Container.tsx
import clsx from 'clsx'; import React from 'react'; type Props = Readonly<{ children: React.ReactNode; className?: string; variant?: 'md' | 'sm' | 'xs'; }>; export default function Container({ children, className, variant = 'md', }: Props) { return ( <div className={clsx( 'mx-auto px-4...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/CompaniesTypeahead.tsx
apps/portal/src/components/shared/CompaniesTypeahead.tsx
import type { ComponentProps } from 'react'; import { useState } from 'react'; import type { TypeaheadOption } from '~/ui'; import { Typeahead } from '~/ui'; import useCompanyOptions from '~/utils/shared/useCompanyOptions'; type BaseProps = Pick< ComponentProps<typeof Typeahead>, | 'disabled' | 'errorMessage' ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/CompanyProfileImage.tsx
apps/portal/src/components/shared/CompanyProfileImage.tsx
import clsx from 'clsx'; import { useState } from 'react'; import { BuildingOffice2Icon } from '@heroicons/react/24/outline'; type Props = Readonly<{ alt: string; className: string; src: string; }>; export default function CompanyProfileImage({ alt, className, src }: Props) { const [hasError, setHasError] = us...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/JobTitles.ts
apps/portal/src/components/shared/JobTitles.ts
type JobTitleData = Record< string, Readonly<{ label: string; ranking: number; }> >; export const JobTitleLabels: JobTitleData = { 'ai-engineer': { label: 'Artificial Intelligence (AI) Engineer', ranking: 5 }, 'algorithms-engineer': { label: 'Algorithms Engineer', ranking: 0 }, 'android-engineer': ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/components/shared/icons/GitHubIcon.tsx
apps/portal/src/components/shared/icons/GitHubIcon.tsx
export default function GitHubIcon(props: React.ComponentProps<'svg'>) { return ( <svg fill="currentColor" height="1em" stroke="currentColor" strokeWidth={0} viewBox="0 0 496 512" width="1em" xmlns="http://www.w3.org/2000/svg" {...props}> <path d="M165.9 397.4...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/supabase.ts
apps/portal/src/utils/supabase.ts
import { createClient } from '@supabase/supabase-js'; import { env } from '~/env/server.mjs'; const { SUPABASE_URL, SUPABASE_ANON_KEY } = env; // Create a single supabase client for interacting with the file storage export const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/trpc.ts
apps/portal/src/utils/trpc.ts
// Src/utils/trpc.ts import { createReactQueryHooks } from '@trpc/react'; import type { inferProcedureInput, inferProcedureOutput } from '@trpc/server'; import type { AppRouter } from '~/server/router'; export const trpc = createReactQueryHooks<AppRouter>(); /** * These are helper types to infer the input and outpu...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/JobExperienceLevel.ts
apps/portal/src/utils/JobExperienceLevel.ts
enum JobExperienceLevel { Entry, Mid, Senior, } export function yearsOfExperienceToLevel(years: number): Readonly<{ label: string; level: JobExperienceLevel; }> { if (years <= 2) { return { label: 'Entry Level', level: JobExperienceLevel.Entry, }; } if (years <= 5) { return { ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/mutations.ts
apps/portal/src/utils/questions/mutations.ts
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { trpc } from '../trpc'; export function useAddQuestionToListAsync() { const { event } = useGoogleAnalytics(); const utils = trpc.useContext(); const { mutateAsync: addQuestionToListAsync } = trpc.useMutation( 'questions.lists....
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/useDefaultCompany.ts
apps/portal/src/utils/questions/useDefaultCompany.ts
import type { FilterChoice } from '~/components/questions/filter/FilterSection'; import useCompanyOptions from '../shared/useCompanyOptions'; export default function useDefaultCompany(): FilterChoice | undefined { const { data: companyOptions } = useCompanyOptions('google'); return companyOptions[0]; }
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/RequireAllOrNone.ts
apps/portal/src/utils/questions/RequireAllOrNone.ts
export type RequireAllOrNone<T> = T | { [K in keyof T]?: never };
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/createSlug.ts
apps/portal/src/utils/questions/createSlug.ts
export default function createSlug(content: string) { return content .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)+/g, '') .substring(0, 100); }
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/withHref.tsx
apps/portal/src/utils/questions/withHref.tsx
const withHref = <Props extends Record<string, unknown>>( Component: React.ComponentType<Props>, ) => { return ( props: Props & { href: string; }, ) => { const { href, ...others } = props; return ( <a className="ring-primary-500 rounded-md focus:ring-2 focus-visible:outline-no...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/useSearchParam.ts
apps/portal/src/utils/questions/useSearchParam.ts
import { useRouter } from 'next/router'; import { useCallback, useEffect, useState } from 'react'; type SearchParamOptions<Value> = [Value] extends [string] ? { defaultValues?: Array<Value>; paramToString?: (value: Value) => string | null; stringToParam?: (param: string) => Value | null; } : ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/useFormRegister.ts
apps/portal/src/utils/questions/useFormRegister.ts
import type { ChangeEvent } from 'react'; import { useCallback } from 'react'; import type { FieldValues, UseFormRegister } from 'react-hook-form'; export const useFormRegister = <TFieldValues extends FieldValues>( register: UseFormRegister<TFieldValues>, ) => { const formRegister = useCallback( (...args: Para...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/locationSlug.ts
apps/portal/src/utils/questions/locationSlug.ts
import type { TypeaheadOption } from '~/ui'; import type { Location } from '~/types/questions'; export function locationOptionToSlug( value: Location & TypeaheadOption, ): string { return [ value.countryId, value.stateId, value.cityId, value.id, value.label, value.value, ].join('-'); }
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/companySlug.ts
apps/portal/src/utils/questions/companySlug.ts
import type { FilterChoice, FilterOption, } from '~/components/questions/filter/FilterSection'; export function companyOptionToSlug(option: FilterChoice): string { return `${option.id}_${option.label}`; } export function slugToCompanyOption(slug: string): FilterOption { const [id, label] = slug.split('_'); ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/useProtectedCallback.ts
apps/portal/src/utils/questions/useProtectedCallback.ts
import { useSession } from 'next-auth/react'; import { useCallback, useContext } from 'react'; import { ProtectedContext } from '~/components/questions/protected/ProtectedContextProvider'; export const useProtectedCallback = <T extends Array<unknown>, U>( callback: (...args: T) => U, ) => { const { showDialog } =...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/constants.ts
apps/portal/src/utils/questions/constants.ts
import { QuestionsQuestionType } from '@prisma/client'; import type { FilterChoices } from '~/components/questions/filter/FilterSection'; import { SortOrder, SortType } from '~/types/questions.d'; export const APP_TITLE = 'Questions Bank'; export const COMPANIES: FilterChoices = [ { id: 'Google', label: '...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/useLocationOptions.ts
apps/portal/src/utils/questions/useLocationOptions.ts
import { useMemo } from 'react'; import { trpc } from '../trpc'; export default function useLocationOptions(query: string) { const { data: locations, ...restQuery } = trpc.useQuery([ 'locations.cities.list', { name: query, }, ]); const locationOptions = useMemo(() => { return ( loca...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/relabelQuestionAggregates.ts
apps/portal/src/utils/questions/relabelQuestionAggregates.ts
import type { JobTitleType } from '~/components/shared/JobTitles'; import { getLabelForJobTitleType } from '~/components/shared/JobTitles'; import type { AggregatedQuestionEncounter } from '~/types/questions'; export default function relabelQuestionAggregates({ roleCounts, ...rest }: AggregatedQuestionEncounter) ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/useDefaultLocation.ts
apps/portal/src/utils/questions/useDefaultLocation.ts
import type { FilterChoice } from '~/components/questions/filter/FilterSection'; import useLocationOptions from './useLocationOptions'; import type { Location } from '~/types/questions'; export default function useDefaultLocation(): | (FilterChoice & Location) | undefined { const { data: locationOptions } = us...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/vote/useQuestionVote.ts
apps/portal/src/utils/questions/vote/useQuestionVote.ts
import type { InfiniteData } from 'react-query'; import { trpc } from '~/utils/trpc'; import useVote from './useVote'; import type { Question } from '~/types/questions'; export const useQuestionVote = (id: string) => { const utils = trpc.useContext(); return useVote(id, { idKey: 'questionId', invalidat...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/vote/useQuestionCommentVote.ts
apps/portal/src/utils/questions/vote/useQuestionCommentVote.ts
import type { InfiniteData } from 'react-query'; import { trpc } from '~/utils/trpc'; import useVote from './useVote'; import type { QuestionComment } from '~/types/questions'; export default function useQuestionCommentVote(id: string) { const utils = trpc.useContext(); return useVote(id, { idKey: 'questio...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/vote/useVote.ts
apps/portal/src/utils/questions/vote/useVote.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ import { useCallback } from 'react'; import { Vote } from '@prisma/client'; import { trpc } from '../../trpc'; type UseVoteOptions = { setDownVote: () => void; setNoVote: () => void; setUpVote: () => void; }; type BackendVote = { id: string; vote: Vot...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/vote/useAnswerVote.ts
apps/portal/src/utils/questions/vote/useAnswerVote.ts
import type { InfiniteData } from 'react-query'; import { trpc } from '~/utils/trpc'; import useVote from './useVote'; import type { Answer } from '~/types/questions'; export default function useAnswerVote(id: string) { const utils = trpc.useContext(); return useVote(id, { idKey: 'answerId', invalidate...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/vote/useAnswerCommentVote.ts
apps/portal/src/utils/questions/vote/useAnswerCommentVote.ts
import type { InfiniteData } from 'react-query'; import { trpc } from '~/utils/trpc'; import useVote from './useVote'; import type { AnswerComment } from '~/types/questions'; export default function useAnswerCommentVote(id: string) { const utils = trpc.useContext(); return useVote(id, { idKey: 'answerComme...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/questions/server/aggregate-encounters.ts
apps/portal/src/utils/questions/server/aggregate-encounters.ts
import type { City, Company, Country, QuestionsQuestion, QuestionsQuestionVote, State, } from '@prisma/client'; import { Vote } from '@prisma/client'; import type { AggregatedQuestionEncounter, CountryInfo, Question, } from '~/types/questions'; type AggregatableEncounters = Array<{ city: City | nu...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/form.tsx
apps/portal/src/utils/offers/form.tsx
/* eslint-disable @typescript-eslint/no-explicit-any */ import { FieldError } from '~/components/offers/constants'; /** * Removes empty objects, empty strings, `null`, `undefined`, and `NaN` values from an object. * Does not remove empty arrays. * @param object * @returns object without empty values or objects. ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/string.tsx
apps/portal/src/utils/offers/string.tsx
import type { JobType } from '@prisma/client'; import { JobTypeLabel } from '~/components/offers/constants'; import type { Location } from '~/types/offers'; export function joinWithComma(...strings: Array<string | null | undefined>) { return strings.filter((value) => !!value).join(', '); } export function getLoca...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/randomGenerator.ts
apps/portal/src/utils/offers/randomGenerator.ts
import type { Config } from 'unique-names-generator'; import { countries, names } from 'unique-names-generator'; import { adjectives, animals, colors, uniqueNamesGenerator, } from 'unique-names-generator'; import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); const customConfig: Co...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/zodRegex.ts
apps/portal/src/utils/offers/zodRegex.ts
export const createValidationRegex = ( keywordArray: Array<string>, prepend: string | null | undefined, ) => { const sortingKeysRegex = keywordArray.join('|'); prepend = prepend != null ? prepend : ''; return new RegExp('^' + prepend + '(' + sortingKeysRegex + ')$'); };
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/useSearchParam.ts
apps/portal/src/utils/offers/useSearchParam.ts
import { useRouter } from 'next/router'; import { useCallback, useEffect, useState } from 'react'; type SearchParamOptions<Value> = [Value] extends [string] ? { defaultValues?: Array<Value>; paramToString?: (value: Value) => string | null; stringToParam?: (param: string) => Value | null; } : ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/randomNameGenerator.ts
apps/portal/src/utils/offers/randomNameGenerator.ts
import type { Config } from 'unique-names-generator'; import { adjectives, animals, colors, uniqueNamesGenerator, } from 'unique-names-generator'; import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); const customConfig: Config = { dictionaries: [adjectives, colors, animals], l...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/link.tsx
apps/portal/src/utils/offers/link.tsx
export function getProfileLink(profileId: string, token?: string) { return `${window.location.origin}${getProfilePath(profileId, token)}`; } export function copyProfileLink(profileId: string, token?: string) { navigator.clipboard.writeText(getProfileLink(profileId, token)); } export function getProfilePath(profil...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/time.tsx
apps/portal/src/utils/offers/time.tsx
import { getMonth, getYear } from 'date-fns'; import type { MonthYear } from '~/components/shared/MonthYearPicker'; export function formatDate(value: Date | number | string) { const date = new Date(value); const month = date.toLocaleString('default', { month: 'short' }); const year = date.toLocaleString('defaul...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/currency/CurrencyEnum.tsx
apps/portal/src/utils/offers/currency/CurrencyEnum.tsx
export enum Currency { AED = 'AED', // 'UNITED ARAB EMIRATES DIRHAM' AFN = 'AFN', // 'AFGHAN AFGHANI' ALL = 'ALL', // 'ALBANIAN LEK' AMD = 'AMD', // 'ARMENIAN DRAM' ANG = 'ANG', // 'NETHERLANDS ANTILLEAN GUILDER' AOA = 'AOA', // 'ANGOLAN KWANZA' ARS = 'ARS', // 'ARGENTINE PESO' AUD = 'AUD', // 'AUSTRALI...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/currency/CurrencySelector.tsx
apps/portal/src/utils/offers/currency/CurrencySelector.tsx
import { Select } from '~/ui'; import { Currency } from '~/utils/offers/currency/CurrencyEnum'; const currencyOptions = Object.entries(Currency).map(([key, value]) => ({ label: key, value, })); type Props = Readonly<{ handleCurrencyChange: (currency: string) => void; selectedCurrency: string; }>; export def...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/currency/index.tsx
apps/portal/src/utils/offers/currency/index.tsx
import type { Money } from '~/components/offers/types'; import { Currency } from './CurrencyEnum'; export const baseCurrencyString = Currency.USD.toString(); export function convertMoneyToString(money: Money | undefined) { if (!money) { return '-'; } const { currency, value } = money; if (!value) { r...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/currency/currencyExchange.ts
apps/portal/src/utils/offers/currency/currencyExchange.ts
// API from https://github.com/fawazahmed0/currency-api#readme import fetch from 'cross-fetch'; export const convert = async ( value: number, fromCurrency: string, toCurrency: string, ) => { fromCurrency = fromCurrency.trim().toLowerCase(); toCurrency = toCurrency.trim().toLowerCase(); return await fetch(...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/analysis/analysisGeneration.ts
apps/portal/src/utils/offers/analysis/analysisGeneration.ts
import type { Session } from 'next-auth'; import type { City, Company, Country, OffersAnalysis, OffersAnalysisUnit, OffersBackground, OffersCurrency, OffersExperience, OffersFullTime, OffersIntern, OffersOffer, OffersProfile, Prisma, PrismaClient, State, } from '@prisma/client'; import { J...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/offers/analysis/analysisInclusion.ts
apps/portal/src/utils/offers/analysis/analysisInclusion.ts
export const analysisInclusion = { companyAnalysis: { include: { analysedOffer: { include: { company: true, offersFullTime: { include: { totalCompensation: true, }, }, offersIntern: { include: { m...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/resumes/useSearchParams.ts
apps/portal/src/utils/resumes/useSearchParams.ts
import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; export const useSearchParams = <T>(name: string, defaultValue: T) => { const [isInitialized, setIsInitialized] = useState(false); const router = useRouter(); const [filters, setFilters] = useState(defaultValue); useEffect((...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/resumes/useDebounceValue.ts
apps/portal/src/utils/resumes/useDebounceValue.ts
import { useEffect, useState } from 'react'; export default function useDebounceValue(value: string, delay: number) { const [debouncedValue, setDebouncedValue] = useState(value); useEffect(() => { const handler = setTimeout(() => { setDebouncedValue(value); }, delay); return () => { clearT...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/resumes/resumePrismaUtils.ts
apps/portal/src/utils/resumes/resumePrismaUtils.ts
import type { Resume } from '~/types/resume'; export function resumeGetFilterCounts(data: Array<Resume>) { const roleCounts: Record<string, number> = {}; for (let i = 0; i < data.length; i++) { const { role } = data[i]; if (!(role in roleCounts)) { roleCounts[role] = 1; } else { roleCounts[...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/resumes/resumeFilters.ts
apps/portal/src/utils/resumes/resumeFilters.ts
import type { TypeaheadOption } from '~/ui'; import type { JobTitleType } from '~/components/shared/JobTitles'; import { getLabelForJobTitleType } from '~/components/shared/JobTitles'; import { JobTitleLabels } from '~/components/shared/JobTitles'; export type FilterId = 'experience' | 'location' | 'role'; export typ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/shared/useCompanyOptions.ts
apps/portal/src/utils/shared/useCompanyOptions.ts
import { trpc } from '../trpc'; export default function useCompanyOptions(query: string) { const companies = trpc.useQuery([ 'companies.list', { name: query, }, ]); const { data, ...restQuery } = companies; return { data: data?.map(({ id, name }) => ({ id, label: n...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/shared/useCountryOptions.ts
apps/portal/src/utils/shared/useCountryOptions.ts
import type { Country } from '@prisma/client'; import { trpc } from '../trpc'; function stringPositionComparator(a: string, b: string, query: string): number { const normalizedQueryString = query.trim().toLocaleLowerCase(); const positionA = a.toLocaleLowerCase().indexOf(normalizedQueryString); const positionB ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/utils/shared/useJobTitleOptions.ts
apps/portal/src/utils/shared/useJobTitleOptions.ts
import { JobTitleLabels } from '~/components/shared/JobTitles'; const sortedJobTitleOptions = Object.entries(JobTitleLabels) .map(([slug, { label, ranking }]) => ({ id: slug, label, ranking, value: slug, })) .sort((a, b) => b.ranking - a.ranking); export default function useJobTitleOptions(query...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/types/offers.d.ts
apps/portal/src/types/offers.d.ts
import type { JobType } from '@prisma/client'; export type Profile = { analysis: ProfileAnalysis?; background: Background?; editToken: string?; id: string; isEditable: boolean; isSaved: boolean; offers: Array<ProfileOffer>; profileName: string; }; export type Background = { educations: Array<Educati...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/types/resume.d.ts
apps/portal/src/types/resume.d.ts
export type Resume = { additionalInfo: string?; createdAt: Date; experience: string; id: string; isResolved: boolean; isStarredByUser: boolean; location: string; locationId: string; numComments: number; numStars: number; role: string; title: string; url: string; user: string; };
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/types/index.d.ts
apps/portal/src/types/index.d.ts
export {}; declare global { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions interface Window { // eslint-disable-next-line @typescript-eslint/no-explicit-any gtag: any; } }
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/types/resume-comments.d.ts
apps/portal/src/types/resume-comments.d.ts
import type { ResumesCommentVote, ResumesSection } from '@prisma/client'; /** * Returned by `resumeCommentsRouter` (query for 'resumes.comments.list') and received as prop by `Comment` in `CommentsList` * frontend-friendly representation of the query */ export type ResumeComment = Readonly<{ children: Array<Resum...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/types/next-auth.d.ts
apps/portal/src/types/next-auth.d.ts
import type { DefaultSession } from 'next-auth'; declare module 'next-auth' { /** * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context */ type Session = { user?: DefaultSession['user'] & { id: string; }; }; }
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/types/questions.d.ts
apps/portal/src/types/questions.d.ts
import type { QuestionsQuestionType } from '@prisma/client'; export type Question = { aggregatedQuestionEncounters: AggregatedQuestionEncounter; content: string; id: string; lastSeenAt: Date | null; numAnswers: number; numComments: number; numVotes: number; receivedCount: number; type: QuestionsQuest...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/db/client.ts
apps/portal/src/server/db/client.ts
// Src/server/db/client.ts import { PrismaClient } from '@prisma/client'; import { env } from '~/env/server.mjs'; declare global { // eslint-disable-next-line no-var, init-declarations var prisma: PrismaClient | undefined; } export const prisma = global.prisma || new PrismaClient({ log: env.NODE_EN...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/common/get-server-auth-session.ts
apps/portal/src/server/common/get-server-auth-session.ts
// Wrapper for unstable_getServerSession https://next-auth.js.org/configuration/nextjs import type { GetServerSidePropsContext } from 'next'; // eslint-disable-next-line camelcase import { unstable_getServerSession } from 'next-auth'; import { authOptions as nextAuthOptions } from '~/pages/api/auth/[...nextauth]'; /...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/todos-user-router.ts
apps/portal/src/server/router/todos-user-router.ts
import { z } from 'zod'; import { TodoStatus } from '@prisma/client'; import { createProtectedRouter } from './context'; // Example Todos router that can only be hit if the user requesting is signed in. export const todosUserRouter = createProtectedRouter() .mutation('create', { // Validate that the creation pa...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/todos.ts
apps/portal/src/server/router/todos.ts
import { createRouter } from './context'; export const todosRouter = createRouter().query('list', { async resolve({ ctx }) { return await ctx.prisma.todo.findMany({ include: { user: { select: { name: true, }, }, }, orderBy: { createdAt: 'd...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/protected-example-router.ts
apps/portal/src/server/router/protected-example-router.ts
import { createProtectedRouter } from './context'; // Example router with queries that can only be hit if the user requesting is signed in export const protectedExampleRouter = createProtectedRouter() .query('getSession', { resolve({ ctx }) { return ctx.session; }, }) .query('getSecretMessage', { ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/companies-router.ts
apps/portal/src/server/router/companies-router.ts
import { z } from 'zod'; import { createRouter } from './context'; export const companiesRouter = createRouter().query('list', { input: z.object({ name: z.string(), }), async resolve({ ctx, input }) { return await ctx.prisma.company.findMany({ orderBy: { name: 'desc', }, take: ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/locations-router.ts
apps/portal/src/server/router/locations-router.ts
import { z } from 'zod'; import { createRouter } from './context'; export const locationsRouter = createRouter() .query('cities.list', { input: z.object({ name: z.string(), }), async resolve({ ctx, input }) { return await ctx.prisma.city.findMany({ orderBy: { ranking: 'desc...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/context.ts
apps/portal/src/server/router/context.ts
// Src/server/router/context.ts import type { Session } from 'next-auth'; import * as trpc from '@trpc/server'; import type * as trpcNext from '@trpc/server/adapters/next'; import { getServerAuthSession } from '~/server/common/get-server-auth-session'; import { prisma } from '~/server/db/client'; type CreateContextOp...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/index.ts
apps/portal/src/server/router/index.ts
import superjson from 'superjson'; import { companiesRouter } from './companies-router'; import { createRouter } from './context'; import { locationsRouter } from './locations-router'; import { offersRouter } from './offers/offers'; import { offerAdminRouter } from './offers/offers-admin-router'; import { offersAnalys...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/user-router.ts
apps/portal/src/server/router/user-router.ts
import { z } from 'zod'; import { createProtectedRouter } from './context'; export const userRouter = createProtectedRouter().mutation( 'settings.profile.update', { input: z.object({ email: z.string().optional(), name: z.string().optional(), }), async resolve({ ctx, input }) { const ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-question-router.ts
apps/portal/src/server/router/questions/questions-question-router.ts
import { z } from 'zod'; import { QuestionsQuestionType } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { createQuestionWithAggregateData } from '~/utils/questions/server/aggregate-encounters'; import { createRouter } from '../context'; import { SortOrder, SortType } from '~/types/questions...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-question-comment-user-router.ts
apps/portal/src/server/router/questions/questions-question-comment-user-router.ts
import { z } from 'zod'; import { Vote } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { createProtectedRouter } from '../context'; export const questionsQuestionCommentUserRouter = createProtectedRouter() .mutation('create', { input: z.object({ content: z.string(), questio...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-question-user-router.ts
apps/portal/src/server/router/questions/questions-question-user-router.ts
import { z } from 'zod'; import { QuestionsQuestionType, Vote } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { createProtectedRouter } from '../context'; export const questionsQuestionUserRouter = createProtectedRouter() .mutation('create', { input: z.object({ cityId: z.string()...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-list-router.ts
apps/portal/src/server/router/questions/questions-list-router.ts
import { z } from 'zod'; import { TRPCError } from '@trpc/server'; import { createQuestionWithAggregateData } from '~/utils/questions/server/aggregate-encounters'; import { createProtectedRouter } from '../context'; export const questionsListRouter = createProtectedRouter() .query('getListsByUser', { async res...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-answer-comment-user-router.ts
apps/portal/src/server/router/questions/questions-answer-comment-user-router.ts
import { z } from 'zod'; import { Vote } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { createProtectedRouter } from '../context'; export const questionsAnswerCommentUserRouter = createProtectedRouter() .mutation('create', { input: z.object({ answerId: z.string(), content:...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-answer-user-router.ts
apps/portal/src/server/router/questions/questions-answer-user-router.ts
import { z } from 'zod'; import { Vote } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { createProtectedRouter } from '../context'; export const questionsAnswerUserRouter = createProtectedRouter() .mutation('create', { input: z.object({ content: z.string(), questionId: z.st...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-answer-router.ts
apps/portal/src/server/router/questions/questions-answer-router.ts
import { z } from 'zod'; import { Vote } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { createRouter } from '../context'; import type { Answer } from '~/types/questions'; import { SortOrder, SortType } from '~/types/questions.d'; export const questionsAnswerRouter = createRouter() .query...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-question-encounter-user-router.ts
apps/portal/src/server/router/questions/questions-question-encounter-user-router.ts
import { z } from 'zod'; import { TRPCError } from '@trpc/server'; import { createProtectedRouter } from '../context'; import { SortOrder } from '~/types/questions.d'; export const questionsQuestionEncounterUserRouter = createProtectedRouter() .mutation('create', { input: z.object({ cityId: z.string().nu...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-question-comment-router.ts
apps/portal/src/server/router/questions/questions-question-comment-router.ts
import { z } from 'zod'; import { Vote } from '@prisma/client'; import { createRouter } from '../context'; import type { QuestionComment } from '~/types/questions'; import { SortOrder, SortType } from '~/types/questions.d'; export const questionsQuestionCommentRouter = createRouter().query( 'getQuestionComments', ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-answer-comment-router.ts
apps/portal/src/server/router/questions/questions-answer-comment-router.ts
import { z } from 'zod'; import { Vote } from '@prisma/client'; import { createRouter } from '../context'; import type { AnswerComment } from '~/types/questions'; import { SortOrder, SortType } from '~/types/questions.d'; export const questionsAnswerCommentRouter = createRouter().query( 'getAnswerComments', { ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/questions/questions-question-encounter-router.ts
apps/portal/src/server/router/questions/questions-question-encounter-router.ts
import { z } from 'zod'; import { createAggregatedQuestionEncounter } from '~/utils/questions/server/aggregate-encounters'; import { createRouter } from '../context'; export const questionsQuestionEncounterRouter = createRouter().query( 'getAggregatedEncounters', { input: z.object({ questionId: z.strin...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/offers/offers-comments-router.ts
apps/portal/src/server/router/offers/offers-comments-router.ts
import { z } from 'zod'; import * as trpc from '@trpc/server'; import { createRouter } from '../context'; import type { OffersDiscussion, Reply } from '~/types/offers'; export const offersCommentsRouter = createRouter() .query('getComments', { input: z.object({ profileId: z.string(), }), async re...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/offers/offers-admin-router.ts
apps/portal/src/server/router/offers/offers-admin-router.ts
import { z } from 'zod'; import { JobType } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { adminDashboardOfferDtoMapper, getAdminOffersResponseMapper, } from '~/mappers/offers-mappers'; import { Currency } from '~/utils/offers/currency/CurrencyEnum'; import { convertWithDate } from '~/ut...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/offers/offers-user-profile-router.ts
apps/portal/src/server/router/offers/offers-user-profile-router.ts
import { z } from 'zod'; import * as trpc from '@trpc/server'; import { TRPCError } from '@trpc/server'; import { addToProfileResponseMapper, getUserProfileResponseMapper, } from '~/mappers/offers-mappers'; import { createProtectedRouter } from '../context'; export const offersUserProfileRouter = createProtected...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/offers/offers.ts
apps/portal/src/server/router/offers/offers.ts
import { z } from 'zod'; import { JobType } from '@prisma/client'; import { TRPCError } from '@trpc/server'; import { dashboardOfferDtoMapper, getOffersResponseMapper, } from '~/mappers/offers-mappers'; import { Currency } from '~/utils/offers/currency/CurrencyEnum'; import { convertWithDate } from '~/utils/offers...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/offers/offers-profile-router.ts
apps/portal/src/server/router/offers/offers-profile-router.ts
import crypto from 'crypto'; import { z } from 'zod'; import type { OffersProfile } from '@prisma/client'; import { JobType } from '@prisma/client'; import * as trpc from '@trpc/server'; import { createOfferProfileResponseMapper, profileDtoMapper, } from '~/mappers/offers-mappers'; import { analysisInclusion } fro...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
true
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/offers/offers-analysis-router.ts
apps/portal/src/server/router/offers/offers-analysis-router.ts
import { z } from 'zod'; import { TRPCError } from '@trpc/server'; import { profileAnalysisDtoMapper } from '~/mappers/offers-mappers'; import { analysisInclusion } from '~/utils/offers/analysis/analysisInclusion'; import { createRouter } from '../context'; import { generateAnalysis } from '../../../utils/offers/anal...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/resumes/resumes-star-user-router.ts
apps/portal/src/server/router/resumes/resumes-star-user-router.ts
import { z } from 'zod'; import { createProtectedRouter } from '../context'; export const resumesStarUserRouter = createProtectedRouter() .mutation('unstar', { input: z.object({ resumeId: z.string(), }), async resolve({ ctx, input }) { const { resumeId } = input; const userId = ctx.ses...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/resumes/resumes-comments-votes-user-router.ts
apps/portal/src/server/router/resumes/resumes-comments-votes-user-router.ts
import { z } from 'zod'; import { Vote } from '@prisma/client'; import { createProtectedRouter } from '../context'; export const resumesCommentsVotesUserRouter = createProtectedRouter() .mutation('upsert', { input: z.object({ commentId: z.string(), value: z.nativeEnum(Vote), }), async resolv...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/resumes/resumes-comments-router.ts
apps/portal/src/server/router/resumes/resumes-comments-router.ts
import { z } from 'zod'; import { createRouter } from '../context'; import type { ResumeComment } from '~/types/resume-comments'; export const resumeCommentsRouter = createRouter().query('list', { input: z.object({ resumeId: z.string(), }), async resolve({ ctx, input }) { const { resumeId } = input; ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false
yangshun/tech-interview-handbook
https://github.com/yangshun/tech-interview-handbook/blob/9430396f989730fab83f3ccba16b4955577f107d/apps/portal/src/server/router/resumes/resumes-comments-votes-router.ts
apps/portal/src/server/router/resumes/resumes-comments-votes-router.ts
import { z } from 'zod'; import { Vote } from '@prisma/client'; import { createRouter } from '../context'; import type { ResumeCommentVote } from '~/types/resume-comments'; export const resumesCommentsVotesRouter = createRouter().query('list', { input: z.object({ commentId: z.string(), }), async resolve({ ...
typescript
MIT
9430396f989730fab83f3ccba16b4955577f107d
2026-01-04T15:25:31.531135Z
false