Skip to content

2way-line-service — Repository Map

บทนี้เป็นแผนที่ไฟล์ของ 2way-line-service (branch: master, 52 tracked files)


แผนที่โฟลเดอร์ระดับ repo

2way-line-service/                     (branch: master)
├── package.json                       # name=vtrc-restfull-v2 (ไม่ตรงชื่อ repo)
├── .env.example                       # PORT=8200, DB_*, LINE_AUTH_TOKEN, CENTRALIZE_SERVER
├── config/configuration.ts            # port, jwt, db, lineToken, contentStatus maps
├── docs/document.config.ts            # Swagger; default port 8200
├── libs/
│   ├── jwt/{jwt-auth.guard,jwt.strategy}.ts
│   ├── exception/http-exception.filter.ts
│   ├── log/logs.middleware.ts
│   └── common/{base64-to-file,validator-date}.ts
├── src/
│   ├── main.ts
│   ├── app.module.ts                  # ConfigModule + LineModule เท่านั้น
│   ├── app.controller.ts              # empty
│   ├── app.service.ts
│   ├── dto/                           # announce, common, complaint, employee, line, survey, user
│   ├── entities/                      # 11 entity files — ไม่ถูกโหลด (ไม่มี TypeORM root)
│   └── modules/line/
│       ├── line.module.ts
│       ├── line.controller.ts         # 4 endpoints ทั้งหมด @Public()
│       └── line.service.ts            # axios → api.line.me
├── Dockerfile                         # node:16-alpine
├── docker-compose.yml                 # 8200:8200
├── endpoint.txt                       # scratch API notes (announce/complaint/…)
├── lineText.text                      # scratch LINE helper + hardcoded token
└── test/

Boot sequence

1. NestFactory.create(AppModule, I3GatewayLogger)
       │  main.ts:13-15

2. port = ConfigService.get('port') || 3000
       │  main.ts:19

3. setGlobalPrefix(`${BASE_PATH}api/v1`)
       │  main.ts:21-23

4. bodyParser 50mb
       │  main.ts:24-25

5. Global filter / JwtAuthGuard / ValidationPipe
       │  main.ts:26-28

6. enableCors origin=*
       │  main.ts:29-33

7. Swagger `${BASE_PATH}docs`
       │  main.ts:35-36

8. listen(port, '0.0.0.0')
       │  main.ts:37-40

ไม่มี ScheduleModule / cron — ต่างจาก 2way-batch

AppController ว่าง (app.controller.ts:3)


AppModule — สิ่งที่ถูกโหลดจริง

typescript
@Module({
  imports: [
    ConfigModule.forRoot({ load: [configuration], isGlobal: true }),
    LineModule,
  ],
  controllers: [AppController],
  providers: [AppService, JwtStrategy],
})

แหล่ง: app.module.ts:9-19

ไม่มี:

  • TypeOrmModule
  • ScheduleModule
  • modules อื่นของ skeleton (announces/surveys/…)

LineModule

typescript
@Module({
  providers: [LineService],
  controllers: [LineController],
})

แหล่ง: line.module.ts:5-8

LineService ใช้ Axios.default เป็น HTTP client ภายใน (line.service.ts:13-17) — ไม่ใช้ @nestjs/axios (dependency นี้ก็ไม่มีใน package.json ของ line-service)


Controller routes (ภายใต้ global prefix)

@Controller('Line') (line.controller.ts:9) → base path ${BASE_PATH}api/v1/Line

MethodPath relativeHandlerAuth
POST/pushMassage@Public() line.controller.ts:13-16
POST/multiCastmultiCastMessage@Public() :19-22
POST/nextPagenextPageLine@Public() :25-28
DELETE/previousPagepreviousPageLine@Public() :31-34

Swagger tags: @ApiTags('Line') + @ApiBearerAuth() ที่ class (line.controller.ts:7-8) — Bearer เป็นแค่ metadata ของ Swagger; runtime ข้าม JWT เพราะ @Public()

รายละเอียด request/response → 02-core-pipeline


DTOs ที่ใช้จริง vs ค้าง

ใช้จริงใน Line controller (dto/line.dto.ts):

ClassFieldsอ้างอิง
LinePushMsgDtoreplyToken, messages:4-12
LinePushMsgMultiDtoto[], messages:14-22
NextPageDtouserId, isChula?:24-32
PreviousPageDtouserId:34-38

DTO ไฟล์อื่นใน src/dto/ (announce/complaint/survey/…) ไม่มี importer ใน Line path — ค้างจาก skeleton


Entities ที่ไม่ได้โหลด

มี 11 ไฟล์ใต้ src/entities/ (เช่น t_content.entity.ts, m_content_flow.entity.ts, …) แต่ไม่มี TypeOrmModule — TypeORM ไม่ได้ connect และไม่ sync

configuration.ts ยังประกาศ db.* จาก env (configuration.ts:4-10) และ .env.example มี DB_* (.env.example:7-12) — ไม่มี consumer ใน runtime path ของ Line


Config keys

KeyEnvใช้จริงใน LineService?อ้างอิง
portPORTใช่ (listen)configuration.ts:2
jwtSecretKeySECRET_KEYผ่าน JwtStrategy ถ้ามี non-public routeconfiguration.ts:3
db.*DB_*ไม่configuration.ts:4-10
lineTokenLINE_AUTH_TOKENใช่ (Authorization Bearer)configuration.ts:11, line.service.ts:30,60,93,119
contentStatus.*staticไม่ใน LineServiceconfiguration.ts:12-206

CENTRALIZE_SERVER อยู่ใน .env.example:16 แต่ ไม่มีการอ้างอิงใน *.ts ของ repo (ตรวจด้วย search ทั้ง workspace ของ service)

อย่าคัดลอกค่า SECRET_KEY / LINE_AUTH_TOKEN / DB_PASSWORD จาก .env.example ลงเอกสาร — ไฟล์นั้นมีค่าคล้าย secret จริง


Auth libs

ส่วนพฤติกรรมอ้างอิง
Global JwtAuthGuardข้ามถ้า @Public()main.ts:27, libs/jwt/jwt-auth.guard.ts:15-23
Public decoratorSetMetadata('isPublic', true)jwt-auth.guard.ts:39-41
JwtStrategyBearer + jwtSecretKeylibs/jwt/jwt.strategy.ts:11-15

ทั้ง 4 LINE endpoints เป็น public → JWT ไม่ได้ปกป้อง business surface


Scratch / note files

ไฟล์เนื้อหาโดยสรุปถูก import?
endpoint.txtรายการ path ของ announce/employee/complaint/surveyไม่
lineText.texthelper pushMassage/replyMessage + token คงที่ในไฟล์ไม่

สิ่งที่อยู่นอกขอบเขตบทนี้