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 — สิ่งที่ถูกโหลดจริง
@Module({
imports: [
ConfigModule.forRoot({ load: [configuration], isGlobal: true }),
LineModule,
],
controllers: [AppController],
providers: [AppService, JwtStrategy],
})แหล่ง: app.module.ts:9-19
ไม่มี:
TypeOrmModuleScheduleModule- modules อื่นของ skeleton (announces/surveys/…)
LineModule
@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
| Method | Path relative | Handler | Auth |
|---|---|---|---|
| POST | / | pushMassage | @Public() line.controller.ts:13-16 |
| POST | /multiCast | multiCastMessage | @Public() :19-22 |
| POST | /nextPage | nextPageLine | @Public() :25-28 |
| DELETE | /previousPage | previousPageLine | @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):
| Class | Fields | อ้างอิง |
|---|---|---|
LinePushMsgDto | replyToken, messages | :4-12 |
LinePushMsgMultiDto | to[], messages | :14-22 |
NextPageDto | userId, isChula? | :24-32 |
PreviousPageDto | userId | :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
| Key | Env | ใช้จริงใน LineService? | อ้างอิง |
|---|---|---|---|
port | PORT | ใช่ (listen) | configuration.ts:2 |
jwtSecretKey | SECRET_KEY | ผ่าน JwtStrategy ถ้ามี non-public route | configuration.ts:3 |
db.* | DB_* | ไม่ | configuration.ts:4-10 |
lineToken | LINE_AUTH_TOKEN | ใช่ (Authorization Bearer) | configuration.ts:11, line.service.ts:30,60,93,119 |
contentStatus.* | static | ไม่ใน LineService | configuration.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 decorator | SetMetadata('isPublic', true) | jwt-auth.guard.ts:39-41 |
JwtStrategy | Bearer + jwtSecretKey | libs/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.text | helper pushMassage/replyMessage + token คงที่ในไฟล์ | ไม่ |
สิ่งที่อยู่นอกขอบเขตบทนี้
- Trace push + rich menu → 02-core-pipeline
- LINE API URLs + caller จาก 2way-api → 03-persistence-integrations
- Debt IDs → 04-scorecard