Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const backendProject = {
"^@backend/servers(/(.*)$)?": "<rootDir>/packages/backend/src/servers/$1",
"^@backend/sync(/(.*)$)?": "<rootDir>/packages/backend/src/sync/$1",
"^@backend/user(/(.*)$)?": "<rootDir>/packages/backend/src/user/$1",
"^@backend/waitlist(/(.*)$)?": "<rootDir>/packages/backend/src/waitlist/$1",
"^@backend/__tests__(/(.*)$)?":
"<rootDir>/packages/backend/src/__tests__/$1",
},
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/.env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ SUPERTOKENS_KEY=UNIQUE_KEY_FROM_YOUR_SUPERTOKENS_ACCOUNT
# integration during signup will be skipped

# EMAILER_API_SECRET=UNIQUE_SECRET_FROM_YOUR_KIT_ACCOUNT
# EMAILER_WAITLIST_TAG_ID=YOUR_WAITLIST_TAG_ID
# EMAILER_WAITLIST_INVITE_TAG_ID=YOUR_WAITLIST_INVITE_TAG_ID
# EMAILER_USER_TAG_ID=YOUR_USER_TAG_ID

####################################################
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/src/__tests__/backend.test.init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ process.env["CHANNEL_EXPIRATION_MIN"] = "5";
process.env["SUPERTOKENS_URI"] = "http://localhost:3000";
process.env["SUPERTOKENS_KEY"] = "sTKey";
process.env["EMAILER_API_SECRET"] = "emailerApiSecret";
process.env["EMAILER_WAITLIST_TAG_ID"] = "1234567";
process.env["EMAILER_WAITLIST_INVITE_TAG_ID"] = "7654321";
process.env["EMAILER_USER_TAG_ID"] = "910111213";
process.env["TOKEN_GCAL_NOTIFICATION"] = "secretToken1";
process.env["TOKEN_COMPASS_SYNC"] = "secretToken2";
8 changes: 1 addition & 7 deletions packages/backend/src/__tests__/drivers/util.driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ import { WithId } from "mongodb";
import { Schema_User } from "@core/types/user.types";
import { SyncDriver } from "@backend/__tests__/drivers/sync.driver";
import { UserDriver } from "@backend/__tests__/drivers/user.driver";
import { WaitListDriver } from "@backend/__tests__/drivers/waitlist.driver";

export class UtilDriver {
static async setupTestUser(): Promise<{ user: WithId<Schema_User> }> {
const user = await UserDriver.createUser();

await Promise.all([
SyncDriver.createSync(user, true),
WaitListDriver.saveWaitListRecord(
WaitListDriver.createWaitListRecord(user),
),
]);
await SyncDriver.createSync(user, true);

return { user };
}
Expand Down
31 changes: 0 additions & 31 deletions packages/backend/src/__tests__/drivers/waitlist.driver.ts

This file was deleted.

24 changes: 3 additions & 21 deletions packages/backend/src/__tests__/helpers/mock.db.queries.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Filter } from "mongodb";
import { Event_Core, Schema_Event } from "@core/types/event.types";
import { Schema_Waitlist } from "@core/types/waitlist/waitlist.types";
import { Collections } from "@backend/common/constants/collections";
import { type Filter } from "mongodb";
import { type Event_Core, type Schema_Event } from "@core/types/event.types";
import mongoService from "@backend/common/services/mongo.service";
import { Event_API } from "@backend/common/types/backend.event.types";
import { getNormalizedEmail } from "@backend/waitlist/service/waitlist.service.util";
import { type Event_API } from "@backend/common/types/backend.event.types";

export const getCategorizedEventsInDb = async (
filter?: Filter<Omit<Schema_Event, "_id">>,
Expand All @@ -26,21 +23,6 @@ export const getEventsInDb = async (
.toArray()) as unknown as Event_API[];
};

export const getEmailsOnWaitlist = async () => {
const waitlist = (await mongoService.db
.collection(Collections.WAITLIST)
.find()
.toArray()) as unknown as Schema_Waitlist[];

const emails = waitlist.map((w) => w.email);
return emails;
};

export const isEmailOnWaitlist = async (email: string) => {
const normalizedEmail = getNormalizedEmail(email);
return (await getEmailsOnWaitlist()).includes(normalizedEmail);
};

export const isEventCollectionEmpty = async (
filter: Filter<Omit<Schema_Event, "_id">> = {},
) => {
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/common/constants/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export const Collections = {
PRIORITY: IS_DEV ? "_dev.priority" : "priority",
SYNC: IS_DEV ? "_dev.sync" : "sync",
USER: IS_DEV ? "_dev.user" : "user",
WAITLIST: IS_DEV ? "_dev.waitlist" : "waitlist",
WATCH: IS_DEV ? "_dev.watch" : "watch",
};
4 changes: 0 additions & 4 deletions packages/backend/src/common/constants/env.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const EnvSchema = z
GOOGLE_CLIENT_SECRET: z.string().nonempty(),
DB: z.string().nonempty(),
EMAILER_SECRET: z.string().nonempty().optional(),
EMAILER_WAITLIST_TAG_ID: z.string().nonempty().optional(),
EMAILER_WAITLIST_INVITE_TAG_ID: z.string().nonempty().optional(),
EMAILER_USER_TAG_ID: z.string().nonempty().optional(),
MONGO_URI: z.string().nonempty(),
NODE_ENV: z.nativeEnum(NodeEnv),
Expand Down Expand Up @@ -57,8 +55,6 @@ const processEnv = {
GOOGLE_CLIENT_SECRET: process.env["GOOGLE_CLIENT_SECRET"],
DB: IS_DEV ? "dev_calendar" : "prod_calendar",
EMAILER_SECRET: process.env["EMAILER_API_SECRET"],
EMAILER_WAITLIST_TAG_ID: process.env["EMAILER_WAITLIST_TAG_ID"],
EMAILER_WAITLIST_INVITE_TAG_ID: process.env["EMAILER_WAITLIST_INVITE_TAG_ID"],
EMAILER_USER_TAG_ID: process.env["EMAILER_USER_TAG_ID"],
MONGO_URI: process.env["MONGO_URI"],
NODE_ENV: _nodeEnv,
Expand Down
8 changes: 0 additions & 8 deletions packages/backend/src/common/constants/env.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,3 @@ import { ENV } from "./env.constants";
export const isMissingUserTagId = () => {
return !ENV.EMAILER_SECRET || !ENV.EMAILER_USER_TAG_ID;
};

export const isMissingWaitlistTagId = () => {
return !ENV.EMAILER_SECRET || !ENV.EMAILER_WAITLIST_TAG_ID;
};

export const isMissingWaitlistInviteTagId = () => {
return !ENV.EMAILER_SECRET || !ENV.EMAILER_WAITLIST_INVITE_TAG_ID;
};
20 changes: 0 additions & 20 deletions packages/backend/src/common/errors/waitlist/waitlist.errors.ts

This file was deleted.

36 changes: 12 additions & 24 deletions packages/backend/src/common/services/mongo.service.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { backOff } from "exponential-backoff";
import {
ClientSession,
ClientSessionOptions,
Collection,
ConnectionClosedEvent,
ConnectionReadyEvent,
Db,
type ClientSession,
type ClientSessionOptions,
type Collection,
type ConnectionClosedEvent,
type ConnectionReadyEvent,
type Db,
MongoClient,
ObjectId,
} from "mongodb";
import { Logger } from "@core/logger/winston.logger";
import { Schema_Calendar } from "@core/types/calendar.types";
import { Schema_Event } from "@core/types/event.types";
import { Schema_Priority } from "@core/types/priority.types";
import { Schema_Sync } from "@core/types/sync.types";
import { Schema_User } from "@core/types/user.types";
import { Schema_Waitlist } from "@core/types/waitlist/waitlist.types";
import { Schema_Watch } from "@core/types/watch.types";
import { type Schema_Calendar } from "@core/types/calendar.types";
import { type Schema_Event } from "@core/types/event.types";
import { type Schema_Priority } from "@core/types/priority.types";
import { type Schema_Sync } from "@core/types/sync.types";
import { type Schema_User } from "@core/types/user.types";
import { type Schema_Watch } from "@core/types/watch.types";
import { waitUntilEvent } from "@core/util/wait-until-event.util";
import { Collections } from "@backend/common/constants/collections";
import { ENV } from "@backend/common/constants/env.constants";
Expand All @@ -31,7 +30,6 @@ interface InternalClient {
priority: Collection<Omit<Schema_Priority, "_id">>;
sync: Collection<Schema_Sync>;
user: Collection<Schema_User>;
waitlist: Collection<Schema_Waitlist>;
watch: Collection<Schema_Watch>;
}

Expand Down Expand Up @@ -87,15 +85,6 @@ class MongoService {
return this.#accessInternalCollectionProps("user");
}

/**
* waitlist
*
* mongo collection
*/
get waitlist(): InternalClient["waitlist"] {
return this.#accessInternalCollectionProps("waitlist");
}

/**
* watch
*
Expand Down Expand Up @@ -143,7 +132,6 @@ class MongoService {
),
sync: db.collection<Schema_Sync>(Collections.SYNC),
user: db.collection<Schema_User>(Collections.USER),
waitlist: db.collection<Schema_Waitlist>(Collections.WAITLIST),
watch: db.collection<Schema_Watch>(Collections.WATCH),
};
}
Expand Down
6 changes: 2 additions & 4 deletions packages/backend/src/servers/express/express.server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import express, { Application } from "express";
import express, { type Application } from "express";
import helmet from "helmet";
import {
errorHandler as supertokensErrorHandler,
middleware as supertokensMiddleware,
} from "supertokens-node/framework/express";
import { AuthRoutes } from "@backend/auth/auth.routes.config";
import { CalendarRoutes } from "@backend/calendar/calendar.routes.config";
import { CommonRoutesConfig } from "@backend/common/common.routes.config";
import { type CommonRoutesConfig } from "@backend/common/common.routes.config";
import corsWhitelist from "@backend/common/middleware/cors.middleware";
import { httpLoggingMiddleware } from "@backend/common/middleware/http.logger.middleware";
import { requestMiddleware } from "@backend/common/middleware/promise.middleware";
Expand All @@ -18,7 +18,6 @@ import { EventRoutes } from "@backend/event/event.routes.config";
import { PriorityRoutes } from "@backend/priority/priority.routes.config";
import { SyncRoutes } from "@backend/sync/sync.routes.config";
import { UserRoutes } from "@backend/user/user.routes.config";
import { WaitlistRoutes } from "@backend/waitlist/waitlist.routes.config";

export const initExpressServer = () => {
/* Express Configuration */
Expand All @@ -43,7 +42,6 @@ export const initExpressServer = () => {
routes.push(new EventRoutes(app));
routes.push(new SyncRoutes(app));
routes.push(new CalendarRoutes(app));
routes.push(new WaitlistRoutes(app));

app.use(supertokensErrorHandler()); // Keep this after routes

Expand Down
Loading