Skip to content

Commit 098abfc

Browse files
authored
[Reputation Oracle] refactor: user module (#3174)
1 parent dffbfd9 commit 098abfc

60 files changed

Lines changed: 1362 additions & 1209 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/apps/reputation-oracle/server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"ts-loader": "^9.2.3",
9696
"ts-node": "^10.9.2",
9797
"tsconfig-paths": "4.2.0",
98+
"type-fest": "^4.37.0",
9899
"typescript": "^5.6.3"
99100
},
100101
"lint-staged": {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Controller, Get, Redirect } from '@nestjs/common';
2+
import { ApiExcludeEndpoint } from '@nestjs/swagger';
3+
import { Public } from './common/decorators';
4+
5+
@Controller()
6+
export class AppController {
7+
@Get('/')
8+
@Public()
9+
@Redirect('/swagger', 301)
10+
@ApiExcludeEndpoint()
11+
public swagger(): string {
12+
return 'OK';
13+
}
14+
}

packages/apps/reputation-oracle/server/src/app.module.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Module } from '@nestjs/common';
1+
import { ClassSerializerInterceptor, Module } from '@nestjs/common';
22
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
33
import { ConfigModule } from '@nestjs/config';
44
import { ScheduleModule } from '@nestjs/schedule';
@@ -32,6 +32,7 @@ import { NDAModule } from './modules/nda/nda.module';
3232
import { StorageModule } from './modules/storage/storage.module';
3333

3434
import Environment from './utils/environment';
35+
import { AppController } from './app.controller';
3536

3637
@Module({
3738
providers: [
@@ -43,10 +44,21 @@ import Environment from './utils/environment';
4344
provide: APP_PIPE,
4445
useClass: HttpValidationPipe,
4546
},
47+
/**
48+
* Interceptors are called:
49+
* - for request: in direct order
50+
* - for response: in reverse order
51+
*
52+
* So order matters here for serialization.
53+
*/
4654
{
4755
provide: APP_INTERCEPTOR,
4856
useClass: TransformInterceptor,
4957
},
58+
{
59+
provide: APP_INTERCEPTOR,
60+
useClass: ClassSerializerInterceptor,
61+
},
5062
{
5163
provide: APP_FILTER,
5264
useClass: ExceptionFilter,
@@ -87,5 +99,6 @@ import Environment from './utils/environment';
8799
WebhookIncomingModule,
88100
WebhookOutgoingModule,
89101
],
102+
controllers: [AppController],
90103
})
91104
export class AppModule {}

packages/apps/reputation-oracle/server/src/common/enums/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ export * from './job';
22
export * from './reputation';
33
export * from './webhook';
44
export * from './collection';
5-
export * from './site-key';
65
export * from './hcaptcha';

packages/apps/reputation-oracle/server/src/common/enums/site-key.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/apps/reputation-oracle/server/src/common/enums/user.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/apps/reputation-oracle/server/src/common/guards/signature.auth.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ describe('SignatureAuthGuard', () => {
6969
const guard = new SignatureAuthGuard([role]);
7070

7171
const { privateKey, address } = generateEthWallet();
72-
EscrowUtils.getEscrow = jest.fn().mockResolvedValueOnce({
72+
73+
(EscrowUtils.getEscrow as jest.Mock).mockResolvedValueOnce({
7374
[name]: address,
7475
});
7576

@@ -99,7 +100,7 @@ describe('SignatureAuthGuard', () => {
99100
const guard = new SignatureAuthGuard([AuthSignatureRole.JOB_LAUNCHER]);
100101

101102
const { privateKey, address } = generateEthWallet();
102-
EscrowUtils.getEscrow = jest.fn().mockResolvedValueOnce({
103+
(EscrowUtils.getEscrow as jest.Mock).mockResolvedValueOnce({
103104
launcher: address,
104105
});
105106
const signature = await signMessage(
@@ -136,7 +137,7 @@ describe('SignatureAuthGuard', () => {
136137
]);
137138

138139
const { privateKey, address } = generateEthWallet();
139-
EscrowUtils.getEscrow = jest.fn().mockResolvedValueOnce({
140+
(EscrowUtils.getEscrow as jest.Mock).mockResolvedValueOnce({
140141
launcher: address,
141142
exchangeOracle: address,
142143
});
@@ -172,7 +173,7 @@ describe('SignatureAuthGuard', () => {
172173
]);
173174

174175
const { privateKey } = generateEthWallet();
175-
EscrowUtils.getEscrow = jest.fn().mockResolvedValueOnce({
176+
(EscrowUtils.getEscrow as jest.Mock).mockResolvedValueOnce({
176177
launcher: '',
177178
exchangeOracle: '',
178179
recordingOracle: '',

packages/apps/reputation-oracle/server/src/common/interfaces/base.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/apps/reputation-oracle/server/src/common/interfaces/cron-job.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
BeforeInsert,
3-
BeforeUpdate,
4-
Column,
5-
PrimaryGeneratedColumn,
6-
} from 'typeorm';
1+
import { Column, PrimaryGeneratedColumn } from 'typeorm';
72

83
export abstract class BaseEntity {
94
@PrimaryGeneratedColumn()
@@ -14,17 +9,4 @@ export abstract class BaseEntity {
149

1510
@Column({ type: 'timestamptz' })
1611
updatedAt: Date;
17-
18-
@BeforeInsert()
19-
protected beforeInsert(): void {
20-
const date = new Date();
21-
this.createdAt = date;
22-
this.updatedAt = date;
23-
}
24-
25-
@BeforeUpdate()
26-
protected beforeUpdate(): void {
27-
const date = new Date();
28-
this.updatedAt = date;
29-
}
3012
}

0 commit comments

Comments
 (0)