Skip to content

Commit

Permalink
chore(api): remove tabs and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
manekenpix committed Feb 27, 2024
1 parent fabeecd commit 13162c0
Show file tree
Hide file tree
Showing 69 changed files with 2,185 additions and 2,232 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"editor.insertSpaces": false,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
Expand Down
2 changes: 1 addition & 1 deletion api/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"useTabs": true,
"useTabs": false,
"tabWidth": 2
}
26 changes: 13 additions & 13 deletions api/src/app.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';

describe('AppController', () => {
let app: TestingModule;
let app: TestingModule;

beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});

describe('getHello', () => {
it('should return {"hello": "world"}', () => {
const appController = app.get(AppController);
expect(appController.getHello()).toEqual({ hello: 'world' });
});
});
describe('getHello', () => {
it('should return {"hello": "world"}', () => {
const appController = app.get(AppController);
expect(appController.getHello()).toEqual({ hello: 'world' });
});
});
});
10 changes: 5 additions & 5 deletions api/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { AppService } from './app.service';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(private readonly appService: AppService) {}

@Get()
getHello() {
return this.appService.getHello();
}
@Get()
getHello() {
return this.appService.getHello();
}
}
34 changes: 17 additions & 17 deletions api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ import { EmailModule } from './email/email.module';
import { ImageModule } from './image/image.module';

@Module({
imports: [ConfigModule, UsersModule, ListsModule, EmailModule, ImageModule],
controllers: [AppController],
providers: [
{
provide: APP_GUARD,
useClass: JwtAuthGuard,
},
AppService,
{
provide: APP_PIPE,
useValue: new ValidationPipe({
whitelist: true,
}),
},
PrismaService,
JwtService,
],
imports: [ConfigModule, UsersModule, ListsModule, EmailModule, ImageModule],
controllers: [AppController],
providers: [
{
provide: APP_GUARD,
useClass: JwtAuthGuard,
},
AppService,
{
provide: APP_PIPE,
useValue: new ValidationPipe({
whitelist: true,
}),
},
PrismaService,
JwtService,
],
})
export class AppModule {}
6 changes: 3 additions & 3 deletions api/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
getHello() {
return { hello: 'world' };
}
getHello() {
return { hello: 'world' };
}
}
4 changes: 2 additions & 2 deletions api/src/email/email.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EmailService } from './email.service';
import { ConfigService } from '@nestjs/config';

@Module({
providers: [EmailService, ConfigService],
exports: [EmailService],
providers: [EmailService, ConfigService],
exports: [EmailService],
})
export class EmailModule {}
20 changes: 10 additions & 10 deletions api/src/email/email.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { Test, TestingModule } from '@nestjs/testing';
import { EmailService } from './email.service';

describe.skip('EmailService', () => {
let service: EmailService;
let service: EmailService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [EmailService],
}).compile();
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [EmailService],
}).compile();

service = module.get<EmailService>(EmailService);
});
service = module.get<EmailService>(EmailService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
156 changes: 78 additions & 78 deletions api/src/email/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import * as FormData from 'form-data';
import { List, User } from '@prisma/client';

type EmailData = {
from: string;
to: string;
cc?: string;
subject: string;
html: string;
from: string;
to: string;
cc?: string;
subject: string;
html: string;
};

let mailgunApiKey: string;
Expand All @@ -19,47 +19,47 @@ let isProduction: boolean;

@Injectable()
export class EmailService {
private mailgunClient: IMailgunClient;

constructor(private readonly configService: ConfigService) {
mailgunApiKey = this.configService.get<string>('MAILGUN_KEY') as string;
mailgunDomain = this.configService.get<string>('MAILGUN_DOMAIN') as string;
isProduction = this.configService.get<string>('NODE_ENV') === 'production';

if (!mailgunApiKey || !mailgunDomain) {
throw new Error('Mailgun API key or domain is not configured');
}

const mailgun = new Mailgun(FormData);
this.mailgunClient = mailgun.client({
username: 'api',
key: mailgunApiKey,
});
}

private async sendEmail(messageData: EmailData) {
if (isProduction) {
try {
const fire = await this.mailgunClient.messages.create(
mailgunDomain,
messageData,
);

return fire;
} catch (error) {
throw new InternalServerErrorException(
'Error attempting to send email',
);
}
}
}

async sendSignupEmail(recipient: string, username: string) {
const email = {
from: 'CineSync <[email protected]>',
to: recipient,
subject: 'Welcome to CineSync!',
html: `
private mailgunClient: IMailgunClient;

constructor(private readonly configService: ConfigService) {
mailgunApiKey = this.configService.get<string>('MAILGUN_KEY') as string;
mailgunDomain = this.configService.get<string>('MAILGUN_DOMAIN') as string;
isProduction = this.configService.get<string>('NODE_ENV') === 'production';

if (!mailgunApiKey || !mailgunDomain) {
throw new Error('Mailgun API key or domain is not configured');
}

const mailgun = new Mailgun(FormData);
this.mailgunClient = mailgun.client({
username: 'api',
key: mailgunApiKey,
});
}

private async sendEmail(messageData: EmailData) {
if (isProduction) {
try {
const fire = await this.mailgunClient.messages.create(
mailgunDomain,
messageData,
);

return fire;
} catch (error) {
throw new InternalServerErrorException(
'Error attempting to send email',
);
}
}
}

async sendSignupEmail(recipient: string, username: string) {
const email = {
from: 'CineSync <[email protected]>',
to: recipient,
subject: 'Welcome to CineSync!',
html: `
<style>
@import url('https://fonts.cdnfonts.com/css/courier-prime');
p {
Expand All @@ -75,20 +75,20 @@ export class EmailService {
<p>With love,</p>
<p>The CineSync Team</p>
`,
};
};

await this.sendEmail(email);
}
await this.sendEmail(email);
}

async sendListSharingEmail(users: User[], list: List) {
const [owner, sharee] = users;
async sendListSharingEmail(users: User[], list: List) {
const [owner, sharee] = users;

const email = {
from: 'CineSync <[email protected]>',
to: sharee.email,
cc: owner.email,
subject: 'A user has shared a list with you on CineSync!',
html: `
const email = {
from: 'CineSync <[email protected]>',
to: sharee.email,
cc: owner.email,
subject: 'A user has shared a list with you on CineSync!',
html: `
<style>
@import url('https://fonts.cdnfonts.com/css/courier-prime');
p {
Expand All @@ -103,17 +103,17 @@ export class EmailService {
<p>With love,</p>
<p>The CineSync Team</p>
`,
};
};

await this.sendEmail(email);
}
await this.sendEmail(email);
}

async sendListCommentEmail(creator: string, list: List, commenter: string) {
const email = {
from: 'CineSync <[email protected]>',
to: creator,
subject: 'A user has commented on one of your lists on CineSync!',
html: `
async sendListCommentEmail(creator: string, list: List, commenter: string) {
const email = {
from: 'CineSync <[email protected]>',
to: creator,
subject: 'A user has commented on one of your lists on CineSync!',
html: `
<style>
@import url('https://fonts.cdnfonts.com/css/courier-prime');
p {
Expand All @@ -128,17 +128,17 @@ export class EmailService {
<p>With love,</p>
<p>The CineSync Team</p>
`,
};
};

await this.sendEmail(email);
}
await this.sendEmail(email);
}

async sendAccountDeletionEmail(recipient: string) {
const email = {
from: 'CineSync <[email protected]>',
to: recipient,
subject: 'Your account has been deleted on CineSync',
html: `
async sendAccountDeletionEmail(recipient: string) {
const email = {
from: 'CineSync <[email protected]>',
to: recipient,
subject: 'Your account has been deleted on CineSync',
html: `
<style>
@import url('https://fonts.cdnfonts.com/css/courier-prime');
p {
Expand All @@ -153,8 +153,8 @@ export class EmailService {
<p>With love,</p>
<p>The CineSync Team</p>
`,
};
};

await this.sendEmail(email);
}
await this.sendEmail(email);
}
}
Loading

0 comments on commit 13162c0

Please sign in to comment.