All files / app routes.ts

77.5% Statements 155/200
85.71% Branches 12/14
66.66% Functions 14/21
89.23% Lines 116/130

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219            90x 90x   93x   90x 90x 90x 90x 90x   90x   90x   90x   90x 90x 90x 90x 90x 90x 90x 90x 90x 90x 90x 90x 90x   90x 90x   90x 90x 90x   90x 90x 90x 90x   90x     90x               90x       90x 5x 5x     59x 59x       90x   547x 547x     90x 90x   90x 90x 2x 90x 90x 90x     90x 101x       101x 90x           125x     90x         90x                 90x 90x 90x 90x   90x 90x     90x 159x   90x 90x     90x 90x     90x 90x     90x 90x 27x   90x 90x 90x 16x 224x 230x 90x 6x   90x 90x                 90x       50x 90x 6x   90x 90x   90x 90x   1x 1x                 90x 22x 90x   90x 54x 90x 1x 90x 331x 90x 41x 90x   90x   90x   90x   90x   1x 90x   90x 70x  
/*
The source of truth for URLs is
//docs/urls.md
Please make sure this file stays in sync with that file as well as
//app/backend/src/couchers/urls.py
*/
import { ReferenceType } from "proto/references_pb";
import SearchFilters, { parseSearchFiltersToQuery } from "utils/searchFilters";
 
export const baseRoute = "/";
 
export const githubURL = "https://github.com/Couchers-org/couchers";
export const instagramURL = "https://www.instagram.com/couchersorg";
export const redditURL = "https://www.reddit.com/r/couchers/";
export const facebookURL = "https://www.facebook.com/Couchers.org";
export const helpCenterURL = "https://help.couchers.org";
export const githubUpdatesURL =
  "https://github.com/Couchers-org/couchers/commits/develop";
export const newsletterSignupURL =
  "https://newsletter.couchers.org/subscription/form";
 
export const translateJobURL = "https://couchers.org/volunteer/translator";
 
export const landingRoute = "/landing";
export const dashboardRoute = "/dashboard";
export const blogRoute = "/blog";
export const faqRoute = "/faq";
export const missionRoute = "/mission";
export const foundationRoute = "/foundation";
export const planRoute = "/plan";
export const teamRoute = "/team";
export const donationsRoute = "/donate";
export const builtWithRoute = "/open-source";
export const contactRoute = "/contact";
export const roadmapRoute = "/roadmap";
export const whatIsCouchSurfingRoute = "/what-is-couch-surfing";
 
export const loginRoute = "/login";
export const resetPasswordRoute = "/password-reset";
 
export const signupRoute = "/signup";
export const inviteRoute = "/invite";
export const inviteCodesRoute = "/invite-codes";
 
export const settingsRoute = "/account-settings";
export const notificationSettingsRoute = `${settingsRoute}/notifications`;
export const loginsSettingsRoute = `${settingsRoute}/logins`;
export const strongVerificationRoute = "/strong-verification";
 
export const translateRoute = "/translate";
 
// profile
export const userTabs = [
  "about",
  "mod",
  "home",
  "references",
  "favorites",
  "photos",
] as const;
export const editUserTabs = ["about", "home"] as const;
export type UserTab = (typeof userTabs)[number];
export type EditUserTab = (typeof editUserTabs)[number];
 
const profileBaseRoute = "/profile";
export function routeToProfile(tab?: UserTab) {
  return `${profileBaseRoute}${tab ? `/${tab}` : ""}`;
}
 
export function routeToEditProfile(tab?: EditUserTab) {
  return `${profileBaseRoute}/edit${tab ? `/${tab}` : ""}`;
}
 
// user
const userBaseRoute = "/user";
 
export function routeToUser(username: string, tab?: UserTab) {
  return `${userBaseRoute}/${username}${tab ? `/${tab}` : ""}`;
}
 
export const messagesRoute = "/messages";
export const messageTypeStrings = ["chats", "hosting", "surfing"] as const;
export type MessageType = (typeof messageTypeStrings)[number];
export const groupChatsRoute = `${messagesRoute}/chats`;
export const routeToCreateMessage = (username: string) =>
  `${groupChatsRoute}?to=${username}`;
const hostRequestRoute = `${messagesRoute}/request`;
export const routeToGroupChat = (id: number) => `${groupChatsRoute}/${id}`;
export const routeToHostRequest = (id: number) => `${hostRequestRoute}/${id}`;
 
// REFERENCES
export const leaveReferenceBaseRoute = "/leave-reference";
export const routeToLeaveReference = (
  referenceType: ReferenceTypeRouteStrings,
  userId: number,
  hostRequestId?: number,
) => `${leaveReferenceBaseRoute}/${referenceType}/${userId}/${hostRequestId}`;
export const referenceTypeRouteStrings = [
  "friend",
  "surfed",
  "hosted",
] as const;
type ReferenceTypeRouteStrings = (typeof referenceTypeRouteStrings)[number];
export const referenceTypeRoute: Record<
  ReferenceType,
  ReferenceTypeRouteStrings
> = {
  [ReferenceType.REFERENCE_TYPE_FRIEND]: "friend",
  [ReferenceType.REFERENCE_TYPE_SURFED]: "surfed",
  [ReferenceType.REFERENCE_TYPE_HOSTED]: "hosted",
};
export const referenceStepStrings = [
  "did-stay",
  "private-feedback",
  "reference",
  "submit",
  "thank-you",
] as const;
export type ReferenceStep = (typeof referenceStepStrings)[number];
 
export const eventsRoute = "/events";
export const communitiesRoute = "/communities";
export const logoutRoute = "/logout";
export const connectionsRoute = "/connections";
 
export const searchRoute = "/search";
export const routeToSearch = (filters: SearchFilters) =>
  `${searchRoute}?${parseSearchFiltersToQuery(filters)}`;
 
export const jailRoute = "/restricted";
export const tosRoute = "/terms";
 
const placeBaseRoute = "/place";
export const routeToPlace = (id: number, slug: string) =>
  `${placeBaseRoute}/${id}/${slug}`;
 
const guideBaseRoute = "/guide";
export const routeToGuide = (id: number, slug: string) =>
  `${guideBaseRoute}/${id}/${slug}`;
 
const groupBaseRoute = "/group";
export const routeToGroup = (id: number, slug: string) =>
  `${groupBaseRoute}/${id}/${slug}`;
 
export const discussionBaseRoute = "/discussion";
export const routeToDiscussion = (id: number, slug: string) =>
  `${discussionBaseRoute}/${id}/${slug}`;
 
export const eventBaseRoute = "/event";
export const newEventRoute = `${eventBaseRoute}/new`;
export const routeToNewEvent = (communityId?: number) =>
  `${newEventRoute}${communityId ? `?communityId=${communityId}` : ""}`;
export const routeToEvent = (id: number, slug: string) =>
  `${eventBaseRoute}/${id}/${slug}`;
export const routeToEditEvent = (id: number, slug: string) =>
  `${routeToEvent(id, slug)}/edit`;
 
const communityBaseRoute = "/community";
export const communityTabs = [
  "overview",
  "info",
  "discussions",
  "events",
  "members",
] as const;
export type CommunityTab = (typeof communityTabs)[number];
 
export const routeToCommunity = (
  id: number,
  slug: string,
  page?: CommunityTab,
) => `${communityBaseRoute}/${id}/${slug}${page ? `/${page}` : ""}`;
export const routeToEditCommunityPage = (id: number, slug: string) =>
  `${routeToCommunity(id, slug, "info")}/edit`;
 
export const composingDiscussionHash = "new";
export const volunteerRoute = "/volunteer";
 
const badgesRoute = "/badges";
export const routeToBadge = (id: string) => `${badgesRoute}/${id}`;
 
export function adminPanelUserLink(username: string) {
  return `${process.env.NEXT_PUBLIC_CONSOLE_BASE_URL}/admin/user/${username}`;
}
 
//mod
export function routeToModUser(username: string, tab?: UserTab) {
  return `/mod/user/${username}${tab ? `/${tab}` : ""}`;
}
 
export const howToRespondRequestGuideUrl =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1715125658-what-are-some-things-i-should-think-about-before-responding-to-a-request";
export const howToWriteRequestGuideUrl =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1725943310-quick-reference-writing-great-requests";
export const howToDonateUrl =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1715125658-how-do-i-donate-money-to-couchers-org";
export const howToCompleteProfileUrl =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1725919152-why-do-i-need-to-complete-my-profile-to-use-some-features";
export const howToInviteCommunityUrl =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1720304409-how-does-the-invite-the-community-feature-work";
export const howToMakeGreatProfileUrl =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1725919197-how-do-i-create-a-great-profile";
export const helpCenterReportContentURL =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1715125657-how-do-i-report-someone-or-something-that-violates-the-community-guidelines-or-terms-of-use-to_u";
export const helpCenterPrivateFeedbackUrl =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1747589427-providing-private-feedback-when-leaving-a-reference";
export const helpCenterHowToLeaveGoodReferenceUrl =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1717360836-how-to";
export const helpCenterCommunityBuilderURL =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1743977410-what-is-a-community-builder";
export const communityGuidelinesURL =
  "https://help.couchers.org/hc/couchersorg-help-center/articles/1715121703-couchers-org-community-guidelines";
// Note: Url must end with financials year digits
export const latestFinancialsURL =
  "/blog/2025/04/20/couchers-inc-financials-2024";
 
export const communityCreationFormURL = (username?: string) =>
  `https://forms.monday.com/forms/d7b6f1bd47a092e23b63f6ef9db1594b?r=use1&username=${username || ""}`;