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
2 changes: 1 addition & 1 deletion src/app/handleCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as router from '@/lib/router';
import { Future } from '@/lib/Future';
import { Result, Failure } from '@/lib/Result';
import { Repositories, Projections, allProjections } from '@/app/projections';
import { Services } from '@/app/services';
import { Services } from '@/app/integrations';
import { WithProjectionStore } from '@/app/projectionStore';
import { WithEventStore } from '@/app/eventStore';

Expand Down
38 changes: 36 additions & 2 deletions src/app/integrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { type Dependencies, configureDependencies };
export { type Dependencies, configureDependencies, type Services };

import env from '@/app/environment';
import { Postgres, defaultPoolSettings } from '@/lib/postgres';
Expand All @@ -7,11 +7,12 @@ import {
MongoProjectionStore,
WithProjectionStore,
} from '@/app/projectionStore';
import { EmailService } from '@/app/services/email';
import { FileStorageService } from '@/app/services/file-storage';
import { ServerApiVersion } from 'mongodb';
import * as eventStore from '@/app/eventStore';
import { PostgresEventStore, WithEventStore } from '@/app/eventStore';
import { schemas } from '@/app/events';
import { Services, initializeServices } from '@/app/services';
import { Repositories, initializeRepositories } from '@/app/projections';

type Dependencies = {
Expand All @@ -21,6 +22,11 @@ type Dependencies = {
repositories: Repositories;
};

type Services = {
fileStorage: FileStorageService;
email: EmailService;
};

async function configureDependencies(): Promise<Dependencies> {
const postgres = new Postgres({
user: env.EVENT_STORE_USER,
Expand Down Expand Up @@ -87,3 +93,31 @@ async function configureDependencies(): Promise<Dependencies> {
repositories,
};
}

function initializeServices(): Services {
const url = new URL(env.S3_ENDPOINT_URL);
return {
fileStorage: new FileStorageService({
endPoint: url.hostname,
port: url.port
? parseInt(url.port)
: url.protocol === 'https:'
? 443
: 80,
useSSL: url.protocol === 'https:',
accessKey: env.S3_ACCESS_KEY,
secretKey: env.S3_SECRET_KEY,
region: env.S3_REGION,
}),
email: new EmailService({
host: env.SMTP_HOST,
port: env.SMTP_PORT,
secure: true,
auth: {
user: env.SMTP_USERNAME,
pass: env.SMTP_PASSWORD,
},
defaultFrom: env.SMTP_FROM_EMAIL,
}),
};
}
41 changes: 0 additions & 41 deletions src/app/services/index.ts

This file was deleted.