Skip to content

Commit 1e7d509

Browse files
committed
feat: event scope
1 parent d8d2cd0 commit 1e7d509

Some content is hidden

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

64 files changed

+845
-10
lines changed

apps/server/src/app.module.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { SharedDatabaseModule, SharedResourceModule } from '@devmx/shared-resource';
22
import { PresentationResourceModule } from '@devmx/presentation-resource';
3-
import { AccountResourceModule } from '@devmx/account-resource';
43
import { LocationResourceModule } from '@devmx/location-resource';
4+
import { AccountResourceModule } from '@devmx/account-resource';
5+
import { EventResourceModule } from '@devmx/event-resource';
56
import { ServeStaticModule } from '@nestjs/serve-static';
67
import { Module } from '@nestjs/common';
78
import { env } from './envs/env';
@@ -13,7 +14,8 @@ import { env } from './envs/env';
1314
SharedDatabaseModule,
1415
AccountResourceModule,
1516
PresentationResourceModule,
16-
LocationResourceModule
17+
LocationResourceModule,
18+
EventResourceModule
1719
]
1820
})
1921
export class AppModule {}

packages/account/resource/src/lib/controllers/accounts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
import 'multer';
4242

4343
@ApiBearerAuth()
44-
@ApiTags('Accounts')
44+
@ApiTags('Contas')
4545
@Controller('accounts')
4646
export class AccountsController {
4747
constructor(private readonly accountsFacade: AccountsFacade) {}

packages/account/resource/src/lib/controllers/auth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
AccessTokenDto,
1212
} from '@devmx/account-data-source';
1313

14-
@ApiTags('Auth')
14+
@ApiTags('Autenticação')
1515
@Controller('auth')
1616
export class AuthController {
1717
constructor(private authFacade: AuthFacade) {}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"extends": ["../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
},
17+
{
18+
"files": ["*.json"],
19+
"parser": "jsonc-eslint-parser",
20+
"rules": {
21+
"@nx/dependency-checks": [
22+
"error",
23+
{
24+
"ignoredFiles": ["{projectRoot}/eslint.config.{js,cjs,mjs}"]
25+
}
26+
]
27+
}
28+
}
29+
]
30+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
displayName: 'event-data-source',
3+
preset: '../../../jest.preset.js',
4+
testEnvironment: 'node',
5+
transform: {
6+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
7+
},
8+
moduleFileExtensions: ['ts', 'js', 'html'],
9+
coverageDirectory: '../../../coverage/packages/event/data-source',
10+
};
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@devmx/event-data-source",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"tslib": "^2.3.0"
6+
},
7+
"type": "commonjs",
8+
"main": "./src/index.js",
9+
"typings": "./src/index.d.ts",
10+
"private": true
11+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "event-data-source",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "packages/event/data-source/src",
5+
"projectType": "library",
6+
"tags": ["type:data"],
7+
"targets": {
8+
"build": {
9+
"executor": "@nx/js:tsc",
10+
"outputs": ["{options.outputPath}"],
11+
"options": {
12+
"outputPath": "dist/packages/event/data-source",
13+
"main": "packages/event/data-source/src/index.ts",
14+
"tsConfig": "packages/event/data-source/tsconfig.lib.json",
15+
"assets": []
16+
}
17+
}
18+
}
19+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './lib/event-providers';
2+
export * from './lib/schemas';
3+
export * from './lib/facades';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2+
import { IsBoolean, IsOptional, IsString } from 'class-validator';
3+
import { EventFormat } from '@devmx/shared-api-interfaces';
4+
5+
export class CreateEventDto {
6+
@IsString()
7+
@ApiProperty()
8+
title: string;
9+
10+
@IsString()
11+
@ApiProperty()
12+
description: string;
13+
14+
@IsString()
15+
@ApiProperty({
16+
type: 'enum',
17+
enum: ['in-person', 'online', 'mixed'],
18+
example: 'in-person',
19+
})
20+
format: EventFormat;
21+
22+
@IsString()
23+
@ApiProperty()
24+
date: string;
25+
26+
@IsString()
27+
@ApiProperty()
28+
time: string;
29+
30+
@IsString()
31+
@IsOptional()
32+
@ApiPropertyOptional()
33+
cover = '';
34+
35+
@IsBoolean()
36+
@IsOptional()
37+
@ApiPropertyOptional()
38+
visible = false;
39+
40+
@IsString()
41+
@ApiProperty()
42+
address: string;
43+
44+
city?: string;
45+
46+
location?: string;
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { CityDto, LocationDto } from '@devmx/location-data-source';
2+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
3+
import { PresentationDto } from '@devmx/presentation-data-source';
4+
import { EventFormat } from '@devmx/shared-api-interfaces';
5+
import { Type } from 'class-transformer';
6+
7+
export class EventDto {
8+
@ApiProperty()
9+
id: string;
10+
11+
@ApiProperty()
12+
title: string;
13+
14+
@ApiProperty()
15+
description: string;
16+
17+
@ApiProperty({
18+
type: 'enum',
19+
enum: ['in-person', 'online', 'mixed'],
20+
example: 'in-person',
21+
})
22+
format: EventFormat;
23+
24+
@ApiProperty()
25+
date: string;
26+
27+
@ApiProperty()
28+
time: string;
29+
30+
@ApiProperty()
31+
cover: string;
32+
33+
@ApiProperty()
34+
visible: boolean;
35+
36+
@ApiProperty({ type: () => [PresentationDto]})
37+
@Type(() => PresentationDto)
38+
presentations: PresentationDto[];
39+
40+
@ApiProperty()
41+
address: string;
42+
43+
@ApiPropertyOptional({ type: () => CityDto})
44+
@Type(() => CityDto)
45+
city?: CityDto;
46+
47+
@ApiPropertyOptional({ type: () => LocationDto})
48+
@Type(() => LocationDto)
49+
location?: LocationDto;
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './create-event';
2+
export * from './event';
3+
export * from './update-event';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { CreateEventDto } from './create-event';
2+
import { PartialType } from '@nestjs/mapped-types';
3+
4+
export class UpdateEventDto extends PartialType(CreateEventDto) {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { provideEventsFacade, provideEventsService } from "./providers";
2+
import { provideFindEventsUseCase } from "./providers/use-cases";
3+
4+
export function provideEvents() {
5+
return [
6+
provideEventsService(),
7+
8+
provideFindEventsUseCase(),
9+
10+
provideEventsFacade()
11+
]
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { PageDto, QueryParamsDto } from '@devmx/shared-data-source';
2+
import { FindEventsUseCase } from '@devmx/event-domain/server';
3+
import { Event } from '@devmx/shared-api-interfaces';
4+
import { plainToInstance } from 'class-transformer';
5+
import { EventDto } from '../dtos';
6+
7+
export class EventsFacade {
8+
constructor(private findEventsUseCase: FindEventsUseCase) {}
9+
10+
async find(params: QueryParamsDto<Event>) {
11+
params.filter = { ...params.filter, visible: true };
12+
const { data, items, pages } = await this.findEventsUseCase.execute(params);
13+
const presentations = plainToInstance(EventDto, data);
14+
return new PageDto(presentations, items, pages);
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './events';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createServerProvider } from '@devmx/shared-data-source';
2+
import { EventsFacade } from '../facades';
3+
import { FindEventsUseCase } from '@devmx/event-domain/server';
4+
5+
export function provideEventsFacade() {
6+
return createServerProvider(EventsFacade, [FindEventsUseCase]);
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './facades';
2+
export * from './services';
3+
export * from './use-cases';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createServiceProvider } from '@devmx/shared-data-source';
2+
import { EventsService } from '@devmx/event-domain/server';
3+
import { getModelToken } from '@nestjs/mongoose';
4+
import { EventsServiceImpl } from '../services';
5+
import { EventCollection } from '../schemas';
6+
7+
export function provideEventsService() {
8+
return createServiceProvider(EventsService, EventsServiceImpl, [
9+
getModelToken(EventCollection.name),
10+
]);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { EventsService, FindEventsUseCase } from '@devmx/event-domain/server';
2+
import { createUseCaseProvider } from '@devmx/shared-data-source';
3+
4+
export function provideFindEventsUseCase() {
5+
return createUseCaseProvider(FindEventsUseCase, [EventsService]);
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { PresentationCollection } from '@devmx/presentation-data-source';
2+
import { Event, EventFormat } from '@devmx/shared-api-interfaces';
3+
import { createSchema } from '@devmx/shared-data-source';
4+
import { Prop, Schema } from '@nestjs/mongoose';
5+
import mongoose, { Document } from 'mongoose';
6+
import {
7+
PointSchema,
8+
CityCollection,
9+
PointCollection,
10+
} from '@devmx/location-data-source';
11+
12+
@Schema()
13+
export class EventCollection extends Document implements Event {
14+
override id: string;
15+
16+
@Prop({ type: String, required: true })
17+
title: string;
18+
19+
@Prop({ type: String, default: '' })
20+
description: string;
21+
22+
@Prop({
23+
type: String,
24+
enum: ['in-person', 'online', 'mixed'],
25+
default: 'in-person',
26+
})
27+
format: EventFormat;
28+
29+
@Prop({ type: String, required: true, default: '' })
30+
date: string;
31+
32+
@Prop({ type: String, required: true, default: '' })
33+
time: string;
34+
35+
@Prop({ default: '' })
36+
cover: string;
37+
38+
@Prop({ default: false })
39+
visible: boolean;
40+
41+
@Prop({
42+
type: [
43+
{
44+
type: mongoose.Schema.Types.ObjectId,
45+
ref: PresentationCollection.name,
46+
},
47+
],
48+
})
49+
presentations: PresentationCollection[];
50+
51+
@Prop({
52+
type: String,
53+
required: true,
54+
})
55+
address: string;
56+
57+
@Prop({
58+
type: mongoose.Schema.Types.ObjectId,
59+
ref: CityCollection.name,
60+
})
61+
city?: CityCollection;
62+
63+
@Prop({
64+
type: PointSchema,
65+
index: '2dsphere',
66+
})
67+
location?: PointCollection;
68+
}
69+
70+
export const EventSchema = createSchema(EventCollection);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './event';

0 commit comments

Comments
 (0)