Skip to content

Commit bddaa7c

Browse files
Merge pull request #181 from CollActionteam/undo_reverts
Undo reverts
2 parents 874e64f + 6e01d8b commit bddaa7c

50 files changed

Lines changed: 818 additions & 208 deletions

Some content is hidden

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

.env.example

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ FIREBASE_AUTH_DOMAIN =
1515
FIREBASE_PROJECT_ID =
1616
GOOGLE_APPLICATION_CREDENTIALS = './serviceAccountKey.json'
1717

18-
# AWS Related
19-
AWS_BUCKET_NAME = collaction-development
20-
AWS_BUCKET_REGION = eu-central-1
21-
AWS_S3_ACCESS_KEY_ID =
22-
AWS_S3_SECRET_ACCESS_KEY =
18+
# Azure Related
19+
AZURE_CONNECTION =
20+
AZURE_CONTAINER =

package-lock.json

Lines changed: 219 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"migration:revert": "npm run typeorm:cli -- migration:revert -d src/ormconfig.ts"
2929
},
3030
"dependencies": {
31+
"@azure/storage-blob": "^12.14.0",
3132
"@nestjs/common": "^9.0.3",
3233
"@nestjs/config": "^2.3.1",
3334
"@nestjs/core": "^9.0.3",
@@ -63,6 +64,7 @@
6364
"@nestjs/testing": "^9.0.3",
6465
"@types/express": "^4.17.17",
6566
"@types/jest": "29.5.0",
67+
"@types/multer": "^1.4.7",
6668
"@types/node": "^18.15.11",
6769
"@types/supertest": "^2.0.12",
6870
"@typescript-eslint/eslint-plugin": "^5.57.1",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { Body, Controller, Get, Param, Post, Put } from '@nestjs/common';
2+
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
3+
import { ICQRSHandler } from '@common/cqrs';
4+
import { Forum } from '@domain/forum';
5+
import { CreateForumDto, ForumDto, ForumPermissionDto, UpdateForumPermissionDto } from '@infrastructure/forum';
6+
import { CreateForumCommand, FetchAllForums, GetForumHierarchy, UpdateForumPermissionsCommand } from '@modules/forum';
7+
import { CurrentUser, FirebaseGuard } from '@modules/auth/decorators';
8+
import { Identifiable } from '@domain/core';
9+
import { AuthUser } from '@domain/auth/entity';
10+
import { IdentifiableResponse } from '@api/rest/core';
11+
import { UserRole } from '@domain/auth/enum';
12+
13+
@Controller('v1/forum')
14+
@ApiTags('Forum')
15+
export class ForumController {
16+
constructor(private readonly cqrsHandler: ICQRSHandler) {}
17+
18+
@Post()
19+
@FirebaseGuard(UserRole.ADMIN)
20+
@ApiOperation({ summary: 'Create a forum' })
21+
@ApiResponse({
22+
status: 201,
23+
description: '',
24+
type: IdentifiableResponse,
25+
})
26+
@ApiBody({ type: CreateForumDto, description: "Creates a new forum and it's permissions" })
27+
async createForum(@CurrentUser() authUser: AuthUser, @Body() forumDto: CreateForumDto): Promise<Identifiable> {
28+
return await this.cqrsHandler.execute(CreateForumCommand, {
29+
data: forumDto,
30+
userRole: authUser.customClaims.role,
31+
});
32+
}
33+
34+
@Get()
35+
@ApiOperation({ summary: 'Fetch all forums' })
36+
@ApiResponse({
37+
status: 200,
38+
description: 'Returns all forums',
39+
type: [ForumDto],
40+
})
41+
async getAllForums(): Promise<Forum[]> {
42+
return await this.cqrsHandler.fetch(FetchAllForums, {});
43+
}
44+
45+
@Get(':forumId')
46+
@ApiOperation({ summary: 'Fetch forum and all its children' })
47+
@ApiResponse({
48+
status: 200,
49+
description: 'Fetch forum and all its children',
50+
type: [ForumDto],
51+
})
52+
async getForumHierarchy(@Param('forumId') id: string): Promise<Forum[]> {
53+
return await this.cqrsHandler.fetch(GetForumHierarchy, id);
54+
}
55+
56+
@Put(':forumId')
57+
@ApiOperation({ summary: 'Update a forums permissions' })
58+
@ApiResponse({
59+
status: 201,
60+
description: '',
61+
type: ForumPermissionDto,
62+
})
63+
async updateForumPermissions(
64+
@Param('forumId') id: string,
65+
@Body() updateForumPermissionBody: UpdateForumPermissionDto,
66+
): Promise<Identifiable> {
67+
return await this.cqrsHandler.execute(UpdateForumPermissionsCommand, { forumId: id, data: updateForumPermissionBody });
68+
}
69+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './forum.controller';

src/api/rest/profiles/v1/controller/profile.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CurrentUser, FirebaseGuard } from '@modules/auth/decorators';
1111
import { AuthUser } from '@domain/auth/entity';
1212
import { Profile } from '@domain/profile';
1313
import { UserRole } from '@domain/auth/enum';
14-
import { UploadImageTypeEnum } from '@modules/core/s3/enum';
14+
import { UploadImageTypeEnum } from '@modules/core';
1515

1616
@Controller('v1/profiles')
1717
@ApiTags('Profiles')

src/api/rest/rest.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { CommitmentController } from './commitments';
1111
import { AuthenticationController } from './auth';
1212
import { ContactController } from './contact';
1313
import { ThreadController } from './threads';
14+
import { ForumController } from './forum/v1/controller';
1415

1516
@Module({
1617
imports: [InfrastructureModule, CQRSModule],
@@ -22,6 +23,7 @@ import { ThreadController } from './threads';
2223
CommitmentController,
2324
ThreadController,
2425
ContactController,
26+
ForumController,
2527
],
2628
providers: [CrowdActionService, ProfileService, AuthService],
2729
exports: [CrowdActionService, ProfileService, AuthService],

src/api/rest/threads/v1/controller/thread.controller.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import { CreateThreadDto, PaginatedThreadResponseDto } from '@infrastructure/thr
77
import { PaginationDto } from '@infrastructure/pagination';
88
import { AuthUser } from '@domain/auth/entity';
99
import { ICQRSHandler } from '@common/cqrs';
10-
import { Identifiable } from '@domain/core';
10+
import { Identifiable, IPaginatedList } from '@domain/core';
1111
import { CreateThreadCommand } from '@modules/thread/cqrs/command';
1212
import { ListThreadsByForumQuery } from '@modules/thread';
13-
import { IPaginatedList } from '@domain/core';
1413
import { IThread } from '@domain/thread';
1514

1615
@Controller('/v1/threads')

src/core/blob-client.interface.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { BlockBlobUploadResponse } from '@azure/storage-blob';
2+
3+
export abstract class IBlobClientRepository {
4+
abstract upload(params: any, imageName: string): Promise<BlockBlobUploadResponse>;
5+
}

src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export * from './repository.interface';
2-
export * from './s3-client.interface';
2+
export * from './blob-client.interface';

0 commit comments

Comments
 (0)