Skip to content

Commit dad1cf8

Browse files
authored
Merge pull request #185 from CollActionteam/development
Development to Production
2 parents f084323 + e966fdd commit dad1cf8

87 files changed

Lines changed: 1287 additions & 239 deletions

File tree

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",

src/api/rest/commitments/v1/controller/commitment.controller.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { Body, Controller, Delete, Param, Patch, Post } from '@nestjs/common';
2-
import { ApiBody, ApiTags } from '@nestjs/swagger';
1+
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common';
2+
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
33
import { ICQRSHandler } from '@common/cqrs';
44
import { CreateCommitmentCommand, DeleteCommitmentCommand, UpdateCommitmentCommand } from '@modules/commitment';
5-
import { Identifiable } from '@domain/core';
6-
import { CreateCommitmentDto, UpdateCommitmentDto } from '@infrastructure/commitment';
5+
import { Identifiable, IPaginatedList } from '@domain/core';
6+
import { CreateCommitmentDto, PaginatedCommitmentResponse, UpdateCommitmentDto } from '@infrastructure/commitment';
77
import { FirebaseGuard } from '@modules/auth/decorators';
88
import { UserRole } from '@domain/auth/enum';
9+
import { PaginationDto } from '@infrastructure/pagination';
10+
import { ListCommitmentsQuery } from '@modules/commitment/cqrs/query/list-commitments.query';
11+
import { ICommitment } from '@domain/commitment';
912

1013
@Controller('v1/commitments')
1114
@ApiTags('Commitment')
@@ -31,4 +34,15 @@ export class CommitmentController {
3134
async updateCommitment(@Param('id') id: string, @Body() updateDto: UpdateCommitmentDto): Promise<Identifiable> {
3235
return await this.cqrsHandler.execute(UpdateCommitmentCommand, { id, updateDto });
3336
}
37+
@Get()
38+
@ApiOperation({ summary: 'Retrieve a paginated list of Commitments' })
39+
@ApiResponse({
40+
status: 200,
41+
description: 'Returns the found Commitments if any',
42+
type: PaginatedCommitmentResponse,
43+
})
44+
@FirebaseGuard(UserRole.MODERATOR, UserRole.ADMIN)
45+
async getAllCommitments(@Query() pagination: PaginationDto, @Query('tags') tags: string[]): Promise<IPaginatedList<ICommitment>> {
46+
return this.cqrsHandler.fetch(ListCommitmentsQuery, { ...pagination, filter: { tags } });
47+
}
3448
}

src/api/rest/crowdactions/v1/controller/crowdaction.controller.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import { Body, Controller, Get, Param, Post, Query, UploadedFiles, UseIntercepto
22
import { ApiBody, ApiConsumes, ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
33
import { FileFieldsInterceptor } from '@nestjs/platform-express';
44
import { Identifiable, IPaginatedList } from '@domain/core';
5-
import { CrowdAction, CrowdActionStatusEnum, ICrowdAction } from '@domain/crowdaction';
5+
import {
6+
CrowdAction,
7+
CrowdActionStatusEnum,
8+
ICrowdAction,
9+
joinStatusToFilter,
10+
statusToFilter,
11+
statusesToFilter,
12+
} from '@domain/crowdaction';
613
import { ICQRSHandler } from '@common/cqrs';
714
import { CreateCrowdActionDto, FilterCrowdActionDto, GetCrowdActionDto, PaginatedCrowdActionResponse } from '@infrastructure/crowdaction';
815
import {
@@ -33,20 +40,23 @@ export class CrowdActionController {
3340
})
3441
async getAllCrowdActions(
3542
@Query() { page, pageSize }: PaginationDto,
36-
@Query() { id, status, joinStatus, startAt, joinEndAt, endAt, category, subcategory, slug }: FilterCrowdActionDto,
43+
@Query() { id, status, joinStatus, slug }: FilterCrowdActionDto,
3744
): Promise<IPaginatedList<GetCrowdActionDto>> {
38-
const filter: any = {
45+
let filter: any = {
3946
id: id !== undefined ? { in: id } : undefined,
40-
status: status !== undefined ? { in: status } : undefined,
41-
joinStatus: joinStatus !== undefined ? { in: joinStatus } : undefined,
42-
startAt: startAt !== undefined ? { in: startAt } : undefined,
43-
joinEndAt: joinEndAt !== undefined ? { in: joinEndAt } : undefined,
44-
endAt: endAt !== undefined ? { in: endAt } : undefined,
45-
category: category !== undefined ? { in: category } : undefined,
46-
subcategory: subcategory !== undefined ? { in: subcategory } : undefined,
4747
slug: slug !== undefined ? { in: slug } : undefined,
4848
};
4949

50+
if (status != undefined) {
51+
const statusFilter = status instanceof Array ? statusesToFilter(status) : statusToFilter(status);
52+
filter = { ...filter, ...statusFilter };
53+
}
54+
55+
if (joinStatus != undefined) {
56+
const joinStatusFilter = joinStatusToFilter(joinStatus);
57+
filter['joinEndAt'] = joinStatusFilter.joinEndAt;
58+
}
59+
5060
for (const param in filter) {
5161
if (filter[param] === undefined) delete filter[param];
5262
}
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';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './post.controller';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Controller, Get, Param, Query } from '@nestjs/common';
2+
import { ApiTags } from '@nestjs/swagger';
3+
import { ICQRSHandler } from '@common/cqrs';
4+
import { PaginationDto } from '@infrastructure/pagination';
5+
import { ListPostsByThreadQuery } from '@modules/post/cqrs/query/list-posts-by-thread.query';
6+
7+
@Controller('v1/posts')
8+
@ApiTags('Posts')
9+
export class PostController {
10+
constructor(private readonly cqrsHandler: ICQRSHandler) {}
11+
12+
@Get(':threadId')
13+
async getPostsByThread(@Param('threadId') threadId: string, @Query() { page, pageSize }: PaginationDto) {
14+
const foundPosts = await this.cqrsHandler.fetch(ListPostsByThreadQuery, { page, pageSize, filter: { threadId } });
15+
return { pageInfo: foundPosts.pageInfo, items: foundPosts.items };
16+
}
17+
}

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')

0 commit comments

Comments
 (0)