generated from aulasoftwarelibre/nx-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
josefrnandezz
committed
Sep 28, 2022
1 parent
a77db31
commit 6c3b3d7
Showing
26 changed files
with
1,907 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<p>Hola,</p> | ||
<p>Este evento se ha cancelado:</p> | ||
<p> | ||
{{ name }} | ||
</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p>Hey {{ name }},</p> | ||
<p>Please click below to confirm your email</p> | ||
<p> | ||
<a href="{{ url }}">Confirm</a> | ||
</p> | ||
|
||
<p>If you did not request this email you can safely ignore it.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { EventDTO } from '@melomaniapp/contracts/event'; | ||
import { MailService } from '@melomaniapp/nestjs/mailer'; | ||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs'; | ||
import { InjectModel } from '@nestjs/mongoose'; | ||
import { Model } from 'mongoose'; | ||
|
@@ -11,10 +13,14 @@ export class EventWasCancelledProjection | |
{ | ||
constructor( | ||
@InjectModel(EVENTS_PROJECTION) | ||
private readonly events: Model<EventDocument> | ||
private readonly events: Model<EventDocument>, | ||
private readonly mailService: MailService | ||
) {} | ||
|
||
async handle(event: EventWasCancelled) { | ||
await this.events.findByIdAndDelete(event.aggregateId).exec(); | ||
const eventDto = await this.events | ||
.findByIdAndDelete(event.aggregateId) | ||
.lean<EventDTO>(); | ||
await this.mailService.sendEventWasCanceled(['[email protected]'], eventDto); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
libs/nestjs/event/src/infrastructure/read-model/events/event-was-created.projection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# nestjs-mailer | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test nestjs-mailer` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
displayName: 'nestjs-mailer', | ||
preset: '../../../jest.preset.js', | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
}, | ||
}, | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]sx?$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
coverageDirectory: '../../../coverage/libs/nestjs/mailer', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './lib/mailer.module'; | ||
export * from './lib/mailer.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Global, Module } from '@nestjs/common'; | ||
import { MailerModule } from '@nestjs-modules/mailer'; | ||
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter'; | ||
import { join } from 'path'; | ||
|
||
import { mailProvider, MailService } from './mailer.service'; | ||
|
||
@Global() | ||
@Module({ | ||
imports: [ | ||
MailerModule.forRoot({ | ||
transport: 'smtp://localhost:1025', | ||
defaults: { | ||
from: '"No Reply" <[email protected]>', | ||
}, | ||
template: { | ||
dir: join(__dirname, 'assets/templates'), | ||
adapter: new HandlebarsAdapter(), // or new PugAdapter() or new EjsAdapter() | ||
options: { | ||
strict: true, | ||
}, | ||
}, | ||
}), | ||
], | ||
providers: [MailService], | ||
exports: [MailService], | ||
}) | ||
export class MailModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { UserDto } from '@melomaniapp/contracts/user'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { MailerService } from '@nestjs-modules/mailer'; | ||
import { EventDTO } from '@melomaniapp/contracts/event'; | ||
|
||
export const MAIL_SERVICE = 'MAIL_SERVICE'; | ||
|
||
@Injectable() | ||
export class MailService { | ||
constructor(private mailerService: MailerService) {} | ||
|
||
async sendUserConfirmation(user: UserDto, token: string) { | ||
const url = `example.com/auth/confirm?token=${token}`; | ||
|
||
await this.mailerService.sendMail({ | ||
to: user.email, | ||
// from: '"Support Team" <[email protected]>', // override default from | ||
subject: 'Welcome to Nice App! Confirm your Email', | ||
template: './confirmation', // `.hbs` extension is appended automatically | ||
context: { | ||
// ✏️ filling curly brackets with content | ||
name: user.username, | ||
url, | ||
}, | ||
}); | ||
} | ||
|
||
async sendEventWasCanceled(emails: string[], event: EventDTO) { | ||
await this.mailerService.sendMail({ | ||
to: emails, | ||
// from: '"Support Team" <[email protected]>', // override default from | ||
subject: 'Evento cancelado', | ||
template: './cancelado', // `.hbs` extension is appended automatically | ||
context: { | ||
name: event.name, | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
export const mailProvider = { | ||
provide: MAIL_SERVICE, | ||
useClass: MailService, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"], | ||
"target": "es6" | ||
}, | ||
"exclude": ["**/*.spec.ts", "**/*.test.ts"], | ||
"include": ["**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": [ | ||
"**/*.test.ts", | ||
"**/*.spec.ts", | ||
"**/*.test.tsx", | ||
"**/*.spec.tsx", | ||
"**/*.test.js", | ||
"**/*.spec.js", | ||
"**/*.test.jsx", | ||
"**/*.spec.jsx", | ||
"**/*.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
export * from './lib/components/AccountMenu/AccountMenu'; | ||
export * from './lib/components/CityDropdown/CityDropdown'; | ||
export * from './lib/components/Establishment/EstablishmentForm/EstablishmentForm'; | ||
export * from './lib/components/FollowButton/FollowButton'; | ||
export * from './lib/components/Genre/GenreFilter/GenreFilter'; | ||
export * from './lib/components/Genre/GenreItem/GenreItem'; | ||
export * from './lib/components/Genre/GenreList/GenreList'; | ||
export * from './lib/components/IconText/IconText'; | ||
export * from './lib/components/ProfileHeader/ProfileHeader'; | ||
export * from './lib/components/ProfileSwitcher/ProfileSwitcher'; | ||
export * from './lib/components/FollowButton/FollowButton'; | ||
export * from './lib/components/SignIn/SignIn'; | ||
export * from './lib/components/CityDropdown/CityDropdown'; | ||
export * from './lib/components/IconText/IconText'; | ||
export * from './lib/utils'; | ||
export * from './lib/components/ProfileHeader/ProfileHeader'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Select, Spin } from 'antd'; | ||
import React from 'react'; | ||
import { useCities } from '@melomaniapp/hooks'; | ||
|
||
const { Option } = Select; | ||
|
||
export interface CityDropdownProps { | ||
selectedCity?: string; | ||
onChangeHandler?: (value: string) => void; | ||
} | ||
|
||
export const CityDropdown: React.FC<CityDropdownProps> = ({ | ||
selectedCity, | ||
onChangeHandler, | ||
}) => { | ||
const { data: cities, isLoading } = useCities(); | ||
|
||
if (isLoading) { | ||
<div style={{ display: 'flex', alignItems: 'center' }}> | ||
<Spin size="large" style={{ margin: 'auto' }} />; | ||
</div>; | ||
} | ||
|
||
return ( | ||
<Select | ||
placeholder="Ciudad" | ||
showSearch={false} | ||
defaultValue={selectedCity} | ||
showArrow | ||
onChange={onChangeHandler} | ||
> | ||
{cities?.map((city) => ( | ||
<Option key={city} value={city}> | ||
{city} | ||
</Option> | ||
))} | ||
</Select> | ||
); | ||
}; | ||
|
||
export default CityDropdown; |
Oops, something went wrong.