mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
update server context to only include the notification repository
This commit is contained in:
26
src/index.ts
26
src/index.ts
@@ -9,6 +9,7 @@ import { ETANotificationScheduler } from "./notifications/schedulers/ETANotifica
|
||||
import { loadShuttleTestData } from "./loaders/loadShuttleTestData";
|
||||
import { AppleNotificationSender } from "./notifications/senders/AppleNotificationSender";
|
||||
import { InMemoryNotificationRepository } from "./repositories/InMemoryNotificationRepository";
|
||||
import { NotificationRepository } from "./repositories/NotificationRepository";
|
||||
|
||||
const typeDefs = readFileSync("./schema.graphqls", "utf8");
|
||||
|
||||
@@ -19,25 +20,32 @@ async function main() {
|
||||
introspection: process.env.NODE_ENV !== "production",
|
||||
});
|
||||
|
||||
const repository = new UnoptimizedInMemoryShuttleRepository();
|
||||
const shuttleRepository = new UnoptimizedInMemoryShuttleRepository();
|
||||
|
||||
let notificationRepository: NotificationRepository;
|
||||
let notificationService: ETANotificationScheduler;
|
||||
if (process.argv.length > 2 && process.argv[2] == "integration-testing") {
|
||||
console.log("Using integration testing setup")
|
||||
await loadShuttleTestData(repository);
|
||||
await loadShuttleTestData(shuttleRepository);
|
||||
|
||||
const appleNotificationSender = new AppleNotificationSender(false);
|
||||
const inMemoryNotificationRepository = new InMemoryNotificationRepository();
|
||||
notificationRepository = new InMemoryNotificationRepository();
|
||||
notificationService = new ETANotificationScheduler(
|
||||
repository,
|
||||
inMemoryNotificationRepository,
|
||||
shuttleRepository,
|
||||
notificationRepository,
|
||||
appleNotificationSender
|
||||
);
|
||||
} else {
|
||||
const repositoryDataUpdater = new TimedApiBasedShuttleRepositoryLoader(
|
||||
repository
|
||||
shuttleRepository,
|
||||
);
|
||||
await repositoryDataUpdater.start();
|
||||
notificationService = new ETANotificationScheduler(repository);
|
||||
|
||||
notificationRepository = new InMemoryNotificationRepository();
|
||||
notificationService = new ETANotificationScheduler(
|
||||
shuttleRepository,
|
||||
notificationRepository
|
||||
);
|
||||
}
|
||||
|
||||
const { url } = await startStandaloneServer(server, {
|
||||
@@ -46,8 +54,8 @@ async function main() {
|
||||
},
|
||||
context: async () => {
|
||||
return {
|
||||
repository,
|
||||
notificationService,
|
||||
shuttleRepository,
|
||||
notificationRepository,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user