Skip to content

Commit

Permalink
deploy: 3.2333.1-beta (#10)
Browse files Browse the repository at this point in the history
* deploy: 3.2333.1-beta

* fix: Dockerfile base image
  • Loading branch information
h4l-yup authored Aug 16, 2023
1 parent d44974c commit d0bab17
Show file tree
Hide file tree
Showing 1,331 changed files with 120,274 additions and 21,078 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/20738369/138070075-d990fd46-971f-4eb3-87f2-2e36d8503ce0.png">
<img src="./assets/cover.png">
<h1 align="center">ABC User Feedback</h1>
</p>

Expand Down Expand Up @@ -49,7 +49,7 @@ cd abc-user-feedback
yarn install
```

2. Spin up all required infrastructure (Mysql, Elasticsearch, etc.) using Docker Compose:
2. Spin up all required infrastructure (Mysql, Opensearch, etc.) using Docker Compose:

```bash
docker-compose -f docker-compose.infra.yml up -d
Expand Down
16 changes: 11 additions & 5 deletions apps/api/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
JWT_SECRET= # required

MYSQL_PRIMARY_URL= # default: mysql://userfeedback:userfeedback@localhost:13306/userfeedback
MYSQL_SECONDARY_URL= # default: mysql://userfeedback:userfeedback@localhost:13306/userfeedback
MYSQL_SECONDARY_URLS= # default: ["mysql://userfeedback:userfeedback@localhost:13306/userfeedback"]

SMTP_HOST= # default: localhost
SMTP_PORT= # default: 25
Expand All @@ -10,9 +10,15 @@ SMTP_PASSWORD= # default: ''
SMTP_SENDER= # default: [email protected]
SMTP_BASE_URL= # default: http://localhost:3000

ES_NODE= # default: http://localhost:9200
ES_USERNAME= # default: ""
ES_PASSWORD= # default: ""
OS_USE= # default: false
OS_NODE= # default: http://localhost:9200
OS_USERNAME= # default: ""
OS_PASSWORD= # default: ""

APP_PORT= # default: 4000
APP_ADDRESS= # default: 0.0.0.0
APP_ADDRESS= # default: 0.0.0.0

AUTO_MIGRATION= # default: false

MASTER_API_KEY= # default: none
BASE_URL= # default: http://localhost:3000
1 change: 0 additions & 1 deletion apps/api/.eslintignore

This file was deleted.

16 changes: 2 additions & 14 deletions apps/api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: ['ufb'],
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: ['plugin:@typescript-eslint/recommended', 'custom'],
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
ignorePatterns: ['jest.config.js', 'jest.setup.js', 'migrations'],
};
35 changes: 19 additions & 16 deletions apps/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,25 @@ npm run migration:run

## Environment Variables

| Environment | Description | Default Value |
| ------------------- | ----------------------------------------- | -------------------------------------------------------------- |
| JWT_SECRET | JWT secret | # required |
| MYSQL_PRIMARY_URL | mysql url | mysql://userfeedback:userfeedback@localhost:13306/userfeedback |
| MYSQL_SECONDARY_URL | mysql url | mysql://userfeedback:userfeedback@localhost:13306/userfeedback |
| SMTP_HOST | smtp server host | localhost |
| SMTP_PORT | smtp server port | 25 |
| SMTP_USERNAME | smtp auth username | |
| SMTP_PASSWORD | smtp auth password | |
| SMTP_SENDER | mail sender email | [email protected] |
| SMTP_BASE_URL | 메일에서 리다이렉트할 기본 유저피드백 URL | http://localhost:3000 |
| APP_PORT | the post that the server is running on | 4000 |
| APP_ADDRESS | the address that the server is running on | 0.0.0.0 |
| ES_NODE | elasticsearch node url | http://localhost:9200 |
| ES_USERNAME | elasticsearch username if exists | |
| ES_PASSWORD | elasticsearch password if exists | |
| Environment | Description | Default Value |
| -------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| JWT_SECRET | JWT secret | # required |
| MYSQL_PRIMARY_URL | mysql url | mysql://userfeedback:userfeedback@localhost:13306/userfeedback |
| MYSQL_SECONDARY_URLS | mysql sub urls (must be json array format) | ["mysql://userfeedback:userfeedback@localhost:13306/userfeedback"] |
| SMTP_HOST | smtp server host | localhost |
| SMTP_PORT | smtp server port | 25 |
| SMTP_USERNAME | smtp auth username | |
| SMTP_PASSWORD | smtp auth password | |
| SMTP_SENDER | mail sender email | [email protected] |
| SMTP_BASE_URL | default UserFeedback URL for mail to be redirected | http://localhost:3000 |
| APP_PORT | the post that the server is running on | 4000 |
| APP_ADDRESS | the address that the server is running on | 0.0.0.0 |
| OS_NODE | opensearch node url | http://localhost:9200 |
| OS_USERNAME | opensearch username if exists | |
| OS_PASSWORD | opensearch password if exists | |
| AUTO_MIGRATION | set 'true' if you want to make the database migration automatically | |
| MASTER_API_KEY | set a key if you want to make a master key for creating feedback | |
| NODE_OPTIONS | set some options if you want to add for node execution (e.g. max_old_space_size) | |

## Learn More

Expand Down
13 changes: 13 additions & 0 deletions apps/api/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ jest.mock('typeorm-transactional', () => ({
initializeTransactionalContext: () => {},
addTransactionalDataSource: (res) => res,
}));
jest.mock('nestjs-typeorm-paginate', () => ({
paginate: (_, option) => {
return {
meta: {
itemCount: 1,
totalItems: (option.page - 1) * option.limit + 1,
pageCount: option.page,
currentPage: option.page,
},
items: [],
};
},
}));
94 changes: 47 additions & 47 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,88 +7,88 @@
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"dev": "nest start --watch",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"test": "jest --detectOpenHandles",
"test:watch": "jest --watch --detectOpenHandles",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json --runInBand --detectOpenHandles",
"typeorm": "ts-node --project ./tsconfig.json -r tsconfig-paths/register ../../node_modules/typeorm/cli -d src/configs/modules/typeorm-config/typeorm-config.datasource.ts",
"typeorm": "ts-node --project ./tsconfig.json -r tsconfig-paths/register ./node_modules/typeorm/cli -d src/configs/modules/typeorm-config/typeorm-config.datasource.ts",
"migration:generate": "npm run typeorm -- migration:generate src/configs/modules/typeorm-config/migrations/$npm_config_name",
"migration:run": "npm run typeorm -- migration:run"
"migration:run": "npm run typeorm -- migration:run",
"migration:revert": "npm run typeorm -- migration:revert"
},
"dependencies": {
"@elastic/elasticsearch": "7.10.0",
"@fastify/static": "^6.9.0",
"@nestjs-modules/mailer": "^1.8.1",
"@nestjs/axios": "^1.0.1",
"@nestjs/common": "^9.0.0",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.0.0",
"@nestjs/elasticsearch": "^9.0.0",
"@nestjs/jwt": "^10.0.1",
"@nestjs/mongoose": "^9.2.1",
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/platform-fastify": "^9.3.8",
"@nestjs/swagger": "^6.1.4",
"@fastify/static": "^6.10.2",
"@nestjs-modules/mailer": "^1.9.1",
"@nestjs/common": "^9.4.2",
"@nestjs/config": "^2.3.2",
"@nestjs/core": "^9.4.2",
"@nestjs/jwt": "^10.0.3",
"@nestjs/mongoose": "^9.2.2",
"@nestjs/passport": "^9.0.3",
"@nestjs/platform-express": "^9.4.2",
"@nestjs/platform-fastify": "^9.4.2",
"@nestjs/swagger": "^6.3.0",
"@nestjs/terminus": "^9.2.2",
"@nestjs/typeorm": "^9.0.1",
"@willsoto/nestjs-prometheus": "^5.1.0",
"@opensearch-project/opensearch": "^1.2.0",
"@willsoto/nestjs-prometheus": "^5.1.2",
"axios": "^1.4.0",
"bcrypt": "^5.1.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"mongoose": "^6.8.1",
"mongoose-transaction-decorator": "^1.0.1",
"mysql2": "^3.1.2",
"nestjs-typeorm-paginate": "^4.0.3",
"nodemailer": "^6.8.0",
"dayjs": "^1.11.9",
"mysql2": "^3.3.3",
"nestjs-cls": "^3.5.0",
"nestjs-pino": "^3.2.0",
"nestjs-typeorm-paginate": "^4.0.4",
"nodemailer": "^6.9.3",
"passport": "^0.6.0",
"passport-custom": "^1.1.1",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"prom-client": "^14.1.1",
"pino-http": "^8.3.3",
"pino-pretty": "^10.0.0",
"prom-client": "^14.2.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
"rxjs": "^7.8.1",
"source-map-support": "^0.5.21",
"typeorm": "^0.3.12",
"typeorm": "^0.3.17",
"typeorm-naming-strategies": "^4.1.0",
"typeorm-transactional": "^0.4.1",
"xlsx": "^0.18.5",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.0/xlsx-0.20.0.tgz",
"yup": "^0.32.11"
},
"devDependencies": {
"@faker-js/faker": "^7.6.0",
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@swc-node/jest": "^1.5.5",
"@swc/core": "^1.3.26",
"@nestjs/cli": "^9.5.0",
"@nestjs/schematics": "^9.2.0",
"@nestjs/testing": "^9.4.2",
"@swc-node/jest": "^1.6.5",
"@swc/core": "^1.3.62",
"@types/bcrypt": "^5.0.0",
"@types/express": "^4.17.13",
"@types/express": "^4.17.17",
"@types/jest": "29.2.4",
"@types/node": "18.11.18",
"@types/nodemailer": "^6.4.7",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-custom": "*",
"@types/nodemailer": "^6.4.8",
"@types/supertest": "^2.0.12",
"@ufb/tsconfig": "0.0.0",
"eslint": "^8.42.0",
"eslint-config-ufb": "0.0.0",
"jest": "29.3.1",
"mockdate": "^3.0.5",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"prettier": "^2.8.8",
"supertest": "^6.3.3",
"ts-jest": "29.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig": "*",
"tsconfig-paths": "^4.1.2",
"typescript": "^4.7.4"
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^4.9.5"
}
}
64 changes: 47 additions & 17 deletions apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,88 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
import { ClsModule } from 'nestjs-cls';
import { LoggerModule } from 'nestjs-pino';

import { appConfig, appConfigSchema } from './configs/app.config';
import {
elasticsearchConfig,
elasticsearchSchema,
} from './configs/elasticsearch.config';
import { jwtConfig, jwtConfigSchema } from './configs/jwt.config';
import {
ElasticsearchConfigModule,
MailerConfigModule,
OpensearchConfigModule,
TypeOrmConfigModule,
} from './configs/modules';
import { mySqlConfigSchema, mysqlConfig } from './configs/mysql.config';
import {
opensearchConfig,
opensearchSchema,
} from './configs/opensearch.config';
import { smtpConfig, smtpConfigSchema } from './configs/smtp.config';
import { AuthModule } from './domains/auth/auth.module';
import { ChannelModule } from './domains/channel/channel/channel.module';
import { FieldModule } from './domains/channel/field/field.module';
import { OptionModule } from './domains/channel/option/option.module';
import { FeedbackModule } from './domains/feedback/feedback.module';
import { RoleModule } from './domains/role/role.module';
import { HealthModule } from './domains/health/health.module';
import { HistoryModule } from './domains/history/history.module';
import { MigrationModule } from './domains/migration/migration.module';
import { ApiKeyModule } from './domains/project/api-key/api-key.module';
import { IssueTrackerModule } from './domains/project/issue-tracker/issue-tracker.module';
import { IssueModule } from './domains/project/issue/issue.module';
import { MemberModule } from './domains/project/member/member.module';
import { ProjectModule } from './domains/project/project/project.module';
import { RoleModule } from './domains/project/role/role.module';
import { TenantModule } from './domains/tenant/tenant.module';
import { UserModule } from './domains/user/user.module';

const domainModules = [
AuthModule,
ChannelModule,
FieldModule,
OptionModule,
FeedbackModule,
HealthModule,
MigrationModule,
ApiKeyModule,
IssueTrackerModule,
IssueModule,
ProjectModule,
RoleModule,
TenantModule,
UserModule,
AuthModule,
FeedbackModule,
MemberModule,
HistoryModule,
];

@Module({
imports: [
TypeOrmConfigModule,
ElasticsearchConfigModule,
OpensearchConfigModule,
MailerConfigModule,
PrometheusModule.register(),
ConfigModule.forRoot({
isGlobal: true,
load: [
appConfig,
elasticsearchConfig,
smtpConfig,
jwtConfig,
mysqlConfig,
],
load: [appConfig, opensearchConfig, smtpConfig, jwtConfig, mysqlConfig],
validate: (config) => ({
...appConfigSchema.validateSync(config),
...elasticsearchSchema.validateSync(config),
...opensearchSchema.validateSync(config),
...smtpConfigSchema.validateSync(config),
...jwtConfigSchema.validateSync(config),
...mySqlConfigSchema.validateSync(config),
}),
validationOptions: { abortEarly: true },
}),
LoggerModule.forRoot({
pinoHttp: {
transport: { target: 'pino-pretty', options: { singleLine: true } },
autoLogging: {
ignore: (req: any) => req.originalUrl === '/api/health',
},
},
}),
ClsModule.forRoot({
global: true,
middleware: { mount: true },
}),
...domainModules,
],
})
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/common/dtos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
export { PaginationDto } from './pagination.dto';
export { PaginationRequestDto } from './pagination-request.dto';
export { PaginationResponseDto } from './pagination-response.dto';
export { TimeRange } from './time-range.dto';
2 changes: 1 addition & 1 deletion apps/api/src/common/dtos/pagination-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ export abstract class PaginationResponseDto<T> implements Pagination<T> {
@Type(() => PaginationMetaDto)
meta: PaginationMetaDto;

abstract items: any[];
abstract items: T[];
}
Loading

0 comments on commit d0bab17

Please sign in to comment.