Skip to content

Commit

Permalink
refactor services
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-sa committed Aug 24, 2024
1 parent 8539d7f commit c1d52d1
Show file tree
Hide file tree
Showing 79 changed files with 427 additions and 461 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
"rules": {
"@typescript-eslint/no-empty-interface": ["warn"],
"@typescript-eslint/no-empty-function": ["warn"]
}
},
{
"files": ["*.js", "*.jsx"],
Expand Down
11 changes: 0 additions & 11 deletions accounting-service-api/README.md

This file was deleted.

26 changes: 0 additions & 26 deletions accounting-service-api/src/lib/entities.ts

This file was deleted.

26 changes: 0 additions & 26 deletions accounting-service-api/src/lib/replies.ts

This file was deleted.

29 changes: 0 additions & 29 deletions accounting-service-api/src/lib/services.ts

This file was deleted.

6 changes: 0 additions & 6 deletions accounting-service/.env

This file was deleted.

3 changes: 0 additions & 3 deletions accounting-service/.env.prod

This file was deleted.

21 changes: 0 additions & 21 deletions accounting-service/src/account.repository.ts

This file was deleted.

54 changes: 0 additions & 54 deletions accounting-service/src/accounting.service.ts

This file was deleted.

3 changes: 0 additions & 3 deletions accounting-service/src/config.ts

This file was deleted.

19 changes: 0 additions & 19 deletions accounting-service/src/main.ts

This file was deleted.

4 changes: 2 additions & 2 deletions api-gateway/src/accounting/accounting.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createModule } from '@deepkit/app';
import { provideRestateServiceProxy } from 'deepkit-restate';

import { AccountingServiceApi } from '@ftgo/accounting-service-api';
import { PaymentServiceApi } from '@ftgo/payment-service-api';

import { AccountingController } from './accounting.controller';

export class AccountingModule extends createModule({
controllers: [AccountingController],
providers: [provideRestateServiceProxy<AccountingServiceApi>()],
providers: [provideRestateServiceProxy<PaymentServiceApi>()],
}) {}
4 changes: 2 additions & 2 deletions api-gateway/src/consumer/consumer.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createModule } from '@deepkit/app';
import { provideRestateServiceProxy } from 'deepkit-restate';

import { ConsumerServiceApi } from '@ftgo/consumer-service-api';
import { CustomerServiceApi } from '@ftgo/customer-service-api';

import { ConsumerController } from './consumer.controller';

export class ConsumerModule extends createModule({
controllers: [ConsumerController],
providers: [provideRestateServiceProxy<ConsumerServiceApi>()],
providers: [provideRestateServiceProxy<CustomerServiceApi>()],
}) {}
30 changes: 11 additions & 19 deletions common/src/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ import {
TypeClass,
} from '@deepkit/type';
import { RestateContextStorage, RestateCustomContext } from 'deepkit-restate';
import {
DatabaseQueryModel,
DeleteResult,
OrmEntity,
PatchResult,
} from '@deepkit/orm';
import { DatabaseQueryModel, OrmEntity } from '@deepkit/orm';

import { Database } from '@ftgo/common';
import { Database } from './database';

export class RestateRepository<E extends OrmEntity> {
readonly #type: TypeClass;
Expand All @@ -30,11 +25,8 @@ export class RestateRepository<E extends OrmEntity> {
return this.contextStorage.getStore()!;
}

async delete(
filter: DatabaseQueryModel<E>['filter'],
): Promise<DeleteResult<E>> {
// TODO: serde
return await this.#ctx.run<DeleteResult<E>>(() =>
async delete(filter: DatabaseQueryModel<E>['filter']): Promise<void> {
await this.#ctx.run(() =>
this.database.query(this.#type.classType).filter(filter).deleteOne(),
);
}
Expand All @@ -53,18 +45,18 @@ export class RestateRepository<E extends OrmEntity> {
async patch(
filter: DatabaseQueryModel<E>['filter'],
changes: ChangesInterface<E> | DeepPartial<E>,
): Promise<PatchResult<E>> {
// TODO: serde
return await this.#ctx.run<PatchResult<E>>(() =>
this.database
): Promise<E> {
return await this.#ctx.run<E>(async () => {
const { returning } = await this.database
.query(this.#type.classType)
.filter(filter)
.patchOne(changes),
);
.patchOne(changes);
return returning as E;
}, this.#type);
}

async create(...args: ConstructorParameters<ClassType<E>>): Promise<E> {
return await this.#ctx.run(async () => {
return await this.#ctx.run<E>(async () => {
const et = new this.#type.classType(...args);
await this.database.persist(et);
return et;
Expand Down
11 changes: 0 additions & 11 deletions consumer-service-api/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions consumer-service-api/src/lib/entities.ts

This file was deleted.

5 changes: 0 additions & 5 deletions consumer-service-api/src/lib/events.ts

This file was deleted.

5 changes: 0 additions & 5 deletions consumer-service/.env

This file was deleted.

3 changes: 0 additions & 3 deletions consumer-service/src/config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions consumer-service/src/consumer.repository.ts

This file was deleted.

43 changes: 0 additions & 43 deletions consumer-service/src/consumer.service.ts

This file was deleted.

File renamed without changes.
Loading

0 comments on commit c1d52d1

Please sign in to comment.