Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
feat: update author create
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2000 committed May 18, 2020
1 parent c949e89 commit 9c189de
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/server/src/modules/author/author.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { AuthorService } from './author.service';
{
DTOClass: AuthorDto,
EntityClass: AuthorEntity,
ServiceClass: AuthorService,
create: { disabled: true },
},
],
services: [AuthorService],
}),
],
providers: [AuthorService],
Expand Down
11 changes: 9 additions & 2 deletions packages/server/src/modules/author/author.service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-useless-constructor */
import { QueryService } from '@nestjs-query/core';
import { TypeOrmQueryService } from '@nestjs-query/query-typeorm';
import { InjectRepository } from '@nestjs/typeorm';
Expand All @@ -8,12 +9,18 @@ import { AuthorEntity } from '@entities/author.entity';
@QueryService(AuthorEntity)
export class AuthorService extends TypeOrmQueryService<AuthorEntity> {
constructor(
@InjectRepository(AuthorEntity) authorRepository: Repository<AuthorEntity>
@InjectRepository(AuthorEntity) authorRepository: Repository<AuthorEntity>,
) {
super(authorRepository);
}

async findOrCreate(name: string): Promise<AuthorEntity> {
async findOrCreate(
name: string | undefined,
): Promise<AuthorEntity | undefined> {
if (!name) {
return undefined;
}

const authors: AuthorEntity[] = await this.query({
filter: { name: { eq: name } },
});
Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/modules/episode/episode.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { EpisodeService } from './episode.service';
{
DTOClass: EpisodeDto,
EntityClass: EpisodeEntity,
ServiceClass: EpisodeService,
create: { disabled: true },
},
],
services: [EpisodeService],
}),
],
providers: [EpisodeService],
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/modules/episode/episode.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export class EpisodeService extends TypeOrmQueryService<EpisodeEntity> {

episode.title = item.title;
episode.publication = new Date(item.pubDate);
episode.url = item.enclosure.url;
episode.filesize = item.enclosure.length;
episode.url = item.enclosure?.url;
episode.filesize = item.enclosure?.length;
episode.guid = item.guid;
episode.type = item.enclosure.type;
episode.type = item.enclosure?.type;
episode.description = item.content;
episode.image = item.itunes.image;
episode.explicit = item.itunes.explicit === 'clean';
Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/modules/queue/queue.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { QueueService } from './queue.service';
{
DTOClass: QueueEntity,
EntityClass: QueueEntity,
ServiceClass: QueueService,
update: { disabled: true },
},
],
services: [QueueService],
}),
],
providers: [QueueService],
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/modules/queue/queue.service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-useless-constructor */
import { QueryService } from '@nestjs-query/core';
import { TypeOrmQueryService } from '@nestjs-query/query-typeorm';
import { Repository } from 'typeorm';
Expand Down

0 comments on commit 9c189de

Please sign in to comment.