Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export class CreateArticleCommandHandler
implements ICommandHandler<CreateArticleCommand>
{
private readonly sqs: AWS.SQS;
private readonly awsRegion: string = process.env.AWS_REGION;
private readonly queueUrl: string = process.env.AWS_SQS_QUEUE_URL;
private readonly awsRegion: string =
process.env.AWS_REGION || "ap-southeast-1";
private readonly queueUrl: string =
process.env.AWS_SQS_QUEUE_URL || "ARTICLE_QUEUE_URL";

constructor(
@Inject(ARTICLE_REPOSITORY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./article.service";
export * from "./tag.service";
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import {
Entity,
Index,
JoinColumn,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
} from "typeorm";

import { UserEntity } from "@user/core/entities/user.entity";
import { IArticle } from "../interfaces/article.interface";
import { BlockEntity } from "./block.entity";
import { CommentEntity } from "./comment.entity";
Expand Down Expand Up @@ -50,8 +47,8 @@ export class ArticleEntity {
@Column("simple-array")
tagList: string[];

@ManyToOne((type) => UserEntity, (user) => user.articles)
author: UserEntity;
@Column({ name: "authorId" })
authorId: number;

@OneToMany((type) => CommentEntity, (comment) => comment.article, {
eager: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {
Entity,
PrimaryGeneratedColumn,
BeforeUpdate,
Column,
Entity,
ManyToOne,
BeforeUpdate,
PrimaryGeneratedColumn,
} from "typeorm";
import { UserEntity } from "@user/core/entities/user.entity";
import { ArticleEntity } from "./article.entity";
import { IComment } from "../interfaces/article.interface";
import { ArticleEntity } from "./article.entity";

@Entity("comment")
export class CommentEntity {
Expand Down Expand Up @@ -35,6 +34,6 @@ export class CommentEntity {
@ManyToOne((type) => ArticleEntity, (article) => article.comments)
article: ArticleEntity;

@ManyToOne(() => UserEntity, (user) => user.comments)
author: UserEntity;
@Column({ name: "authorId" })
authorId: number;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./article.entity";
export * from "./block.entity";
export * from "./comment.entity";
export * from "./tag.entity";
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity('tag')
@Entity("tag")
export class TagEntity {

@PrimaryGeneratedColumn()
id: number;

@Column()
tag: string;

}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./article.interface";
export * from "./block.interface";
export * from "./tag.interface";
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// src/application/port/article.port.ts
import {
DeepPartial,
DeleteResult,
FindConditions,
FindManyOptions,
FindOneOptions,
QueryRunner,
Expand All @@ -19,7 +17,6 @@ export interface ArticlePort {
): SelectQueryBuilder<ArticleEntity>;

find(options?: FindManyOptions<ArticleEntity>): Promise<ArticleEntity[]>;
find(conditions?: FindConditions<ArticleEntity>): Promise<ArticleEntity[]>;

findOne(
id?: string | number,
Expand All @@ -29,7 +26,7 @@ export interface ArticlePort {
options?: FindOneOptions<ArticleEntity>
): Promise<ArticleEntity | undefined>;
findOne(
conditions?: FindConditions<ArticleEntity>,
conditions?: FindOneOptions<ArticleEntity>,
options?: FindOneOptions<ArticleEntity>
): Promise<ArticleEntity | undefined>;

Expand All @@ -49,6 +46,6 @@ export interface ArticlePort {
| string[]
| number
| number[]
| FindConditions<ArticleEntity>
| FindOneOptions<ArticleEntity>
): Promise<DeleteResult>;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./article.port";
export * from "./comment.port";
export * from "./block.port";
export * from "./comment.port";
export * from "./tag.port";
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { FindConditions, FindManyOptions } from "typeorm";
import { FindManyOptions } from "typeorm";

import { TagEntity } from "../entities";

export interface TagPort {
find(options?: FindManyOptions<TagEntity>): Promise<TagEntity[]>;
find(conditions?: FindConditions<TagEntity>): Promise<TagEntity[]>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export const ARTICLE_REPOSITORY = "ARTICLE_REPOSITORY";
export const BLOCK_REPOSITORY = "BLOCK_REPOSITORY";

export const COMMENT_REPOSITORY = "COMMENT_REPOSITORY";

export const TAG_REPOSITORY = "TAG_REPOSITORY";
8 changes: 8 additions & 0 deletions apps/article/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { ArticleModule } from './article.module';

async function bootstrap() {
const app = await NestFactory.create(ArticleModule);
await app.listen(3000);
}
bootstrap();
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./article.controller";
export * from "./tag.controller";
24 changes: 24 additions & 0 deletions apps/article/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { ArticleModule } from './../src/article.module';

describe('ArticleController (e2e)', () => {
let app: INestApplication;

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [ArticleModule],
}).compile();

app = moduleFixture.createNestApplication();
await app.init();
});

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});
9 changes: 9 additions & 0 deletions apps/article/test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
9 changes: 9 additions & 0 deletions apps/article/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": false,
"outDir": "../../dist/apps/article"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions apps/media/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { MediaModule } from './media.module';

async function bootstrap() {
const app = await NestFactory.create(MediaModule);
await app.listen(3000);
}
bootstrap();
File renamed without changes.
24 changes: 24 additions & 0 deletions apps/media/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { MediaModule } from './../src/media.module';

describe('MediaController (e2e)', () => {
let app: INestApplication;

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [MediaModule],
}).compile();

app = moduleFixture.createNestApplication();
await app.init();
});

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});
9 changes: 9 additions & 0 deletions apps/media/test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
9 changes: 9 additions & 0 deletions apps/media/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": false,
"outDir": "../../dist/apps/media"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions apps/profile/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { ProfileModule } from './profile.module';

async function bootstrap() {
const app = await NestFactory.create(ProfileModule);
await app.listen(3000);
}
bootstrap();
22 changes: 22 additions & 0 deletions apps/profile/src/profile.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ProfileController } from './profile.controller';
import { ProfileService } from './profile.service';

describe('ProfileController', () => {
let profileController: ProfileController;

beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [ProfileController],
providers: [ProfileService],
}).compile();

profileController = app.get<ProfileController>(ProfileController);
});

describe('root', () => {
it('should return "Hello World!"', () => {
expect(profileController.getHello()).toBe('Hello World!');
});
});
});
8 changes: 8 additions & 0 deletions apps/profile/src/profile.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class ProfileService {
getHello(): string {
return 'Hello World!';
}
}
24 changes: 24 additions & 0 deletions apps/profile/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { ProfileModule } from './../src/profile.module';

describe('ProfileController (e2e)', () => {
let app: INestApplication;

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [ProfileModule],
}).compile();

app = moduleFixture.createNestApplication();
await app.init();
});

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});
9 changes: 9 additions & 0 deletions apps/profile/test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
9 changes: 9 additions & 0 deletions apps/profile/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": false,
"outDir": "../../dist/apps/profile"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions apps/user/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NestFactory } from '@nestjs/core';
import { UserModule } from './user.module';

async function bootstrap() {
const app = await NestFactory.create(UserModule);
await app.listen(3000);
}
bootstrap();
File renamed without changes.
24 changes: 24 additions & 0 deletions apps/user/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { UserModule } from './../src/user.module';

describe('UserController (e2e)', () => {
let app: INestApplication;

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [UserModule],
}).compile();

app = moduleFixture.createNestApplication();
await app.init();
});

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});
9 changes: 9 additions & 0 deletions apps/user/test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
Loading