trainfinder 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # TrainFinder CLI
2
+
3
+ `TrainFinder`는 한국의 **국내 기차(고속선) 정보**를 조회할 수 있는 **터미널용 CLI 라이브러리**입니다.
4
+ 출발역/도착역과 날짜 기반으로 기차 조회를 할 수 있습니다.
5
+
6
+ ---
7
+
8
+ ## ⚡ 설치
9
+
10
+ ```bash
11
+ npm install -g trainfinder
12
+ ```
13
+
14
+ ## 기차 종류 조회
15
+ ktx, ktx산천A, ktx산천B, ktx이음, srt, ktx청룡
16
+
17
+ ```bash
18
+ trainfinder trainlist
19
+ ```
20
+
21
+ ## 기차역 조회
22
+ ```bash
23
+ trainfinder stationlist
24
+ ```
25
+
26
+ ## 기차역 존재 유무 조회
27
+ ```bash
28
+ trainfinder station --st <역이름>
29
+
30
+ # 예시
31
+ trainfinder station --st 수서
32
+ ```
33
+
34
+ ## 기차 조회
35
+
36
+ 출발역, 도착역, 날짜를 기반으로 기차 조회
37
+
38
+ - 옵션 설명
39
+ --dep : 출발역 코드
40
+
41
+ --arr : 도착역 코드
42
+
43
+ --date : 조회할 날짜 (기본값: 오늘 날짜)
44
+
45
+ --train : 열차 종류 (기본값: ktx)
46
+
47
+
48
+ ```bash
49
+ trainfinder search --dep <출발역 이름> --arr <도착역 이름> --date <YYYYMMDD> --train <열차종류>
50
+ ```
51
+
52
+ ```bash
53
+ # 예시
54
+ trainfinder search --dep 서울 --arr 오송 --date 20251212 --train ktx
55
+ ```
56
+
57
+
58
+
@@ -0,0 +1,6 @@
1
+ import { AppService } from './app.service';
2
+ export declare class AppController {
3
+ private readonly appService;
4
+ constructor(appService: AppService);
5
+ getHello(): string;
6
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AppController = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const app_service_1 = require("./app.service");
15
+ let AppController = class AppController {
16
+ constructor(appService) {
17
+ this.appService = appService;
18
+ }
19
+ getHello() {
20
+ return this.appService.getHello();
21
+ }
22
+ };
23
+ exports.AppController = AppController;
24
+ __decorate([
25
+ (0, common_1.Get)(),
26
+ __metadata("design:type", Function),
27
+ __metadata("design:paramtypes", []),
28
+ __metadata("design:returntype", String)
29
+ ], AppController.prototype, "getHello", null);
30
+ exports.AppController = AppController = __decorate([
31
+ (0, common_1.Controller)(),
32
+ __metadata("design:paramtypes", [app_service_1.AppService])
33
+ ], AppController);
34
+ //# sourceMappingURL=app.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,+CAA2C;AAGpC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGvD,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF,CAAA;AAPY,sCAAa;AAIxB;IADC,IAAA,YAAG,GAAE;;;;6CAGL;wBANU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,aAAa,CAOzB"}
@@ -0,0 +1,2 @@
1
+ export declare class AppModule {
2
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AppModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const app_controller_1 = require("./app.controller");
12
+ const app_service_1 = require("./app.service");
13
+ const train_module_1 = require("./train/train.module");
14
+ let AppModule = class AppModule {
15
+ };
16
+ exports.AppModule = AppModule;
17
+ exports.AppModule = AppModule = __decorate([
18
+ (0, common_1.Module)({
19
+ imports: [
20
+ train_module_1.TrainModule,
21
+ ],
22
+ controllers: [app_controller_1.AppController],
23
+ providers: [app_service_1.AppService],
24
+ })
25
+ ], AppModule);
26
+ //# sourceMappingURL=app.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,uDAAmD;AAS5C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAPrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,0BAAW;SACZ;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG"}
@@ -0,0 +1,3 @@
1
+ export declare class AppService {
2
+ getHello(): string;
3
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AppService = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ let AppService = class AppService {
12
+ getHello() {
13
+ return 'Hello World!';
14
+ }
15
+ };
16
+ exports.AppService = AppService;
17
+ exports.AppService = AppService = __decorate([
18
+ (0, common_1.Injectable)()
19
+ ], AppService);
20
+ //# sourceMappingURL=app.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,QAAQ;QACN,OAAO,cAAc,CAAC;IACxB,CAAC;CACF,CAAA;AAJY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAItB"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ #!/usr/bin/env node
3
+ "use strict";
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const commander_1 = require("commander");
6
+ const train_service_1 = require("./train/train.service");
7
+ const train_parse_service_1 = require("./train/train-parse.service");
8
+ const program = new commander_1.Command();
9
+ const trainParseService = new train_parse_service_1.TrainParseService();
10
+ const trainService = new train_service_1.TrainService(trainParseService);
11
+ program
12
+ .name('train')
13
+ .description('KTX/SRT CLI')
14
+ .version('1.0.0');
15
+ program
16
+ .command('trainlist')
17
+ .description('기차 종류 전체조회')
18
+ .action(() => {
19
+ trainService.trainList();
20
+ });
21
+ program
22
+ .command('search')
23
+ .description('출발/도착/날짜/기차종류 기반 기차 조회')
24
+ .option('--dep <dep>', '출발역 ID')
25
+ .option('--arr <arr>', '도착역 ID')
26
+ .option('--date <date>', '날짜 YYYYMMDD', '20230405')
27
+ .option('--train <train>', '열차종류', '00')
28
+ .action((opts) => {
29
+ trainService.searchTrain(opts.dep, opts.arr, opts.date, opts.train);
30
+ });
31
+ program
32
+ .command('station')
33
+ .description('기차역 존재 유무 확인')
34
+ .option('--st <st>', '검색역')
35
+ .action((opts) => {
36
+ trainService.findStation(opts.st);
37
+ });
38
+ program
39
+ .command('stationlist')
40
+ .description('기차역 전체조회')
41
+ .action((opts) => {
42
+ trainService.stationList();
43
+ });
44
+ program.parse();
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,yDAAqD;AACrD,qEAAgE;AAEhE,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,MAAM,iBAAiB,GAAG,IAAI,uCAAiB,EAAE,CAAC;AAClD,MAAM,YAAY,GAAG,IAAI,4BAAY,CAAC,iBAAiB,CAAC,CAAC;AAEzD,OAAO;KACJ,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CAAC,aAAa,CAAC;KAC1B,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,YAAY,CAAC;KACzB,MAAM,CAAC,GAAG,EAAE;IACX,YAAY,CAAC,SAAS,EAAE,CAAC;AAC3B,CAAC,CAAC,CAAA;AAEJ,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,wBAAwB,CAAC;KACrC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC;KAC/B,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC;KAC/B,MAAM,CAAC,eAAe,EAAE,aAAa,EAAE,UAAU,CAAC;KAClD,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,IAAI,CAAC;KACvC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACf,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,cAAc,CAAC;KAC3B,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC;KAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACd,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,aAAa,CAAC;KACtB,WAAW,CAAC,UAAU,CAAC;KACvB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACf,YAAY,CAAC,WAAW,EAAE,CAAC;AAC7B,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/main.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@nestjs/core");
4
+ const app_module_1 = require("./app.module");
5
+ async function bootstrap() {
6
+ const app = await core_1.NestFactory.create(app_module_1.AppModule);
7
+ await app.listen(3000);
8
+ }
9
+ bootstrap();
10
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"}
@@ -0,0 +1,170 @@
1
+ {
2
+ "trainNames": [
3
+ "ktx",
4
+ "ktx산천A",
5
+ "ktx산천B",
6
+ "ktx이음",
7
+ "srt",
8
+ "ktx청룡"
9
+ ],
10
+ "vehicleMapping": [
11
+ { "vehiclekndid": "00", "vehiclekndnm": "KTX" },
12
+ { "vehiclekndid": "07", "vehiclekndnm": "KTX-산천(A-type)" },
13
+ { "vehiclekndid": "10", "vehiclekndnm": "KTX-산천(B-type)" },
14
+ { "vehiclekndid": "16", "vehiclekndnm": "KTX-이음" },
15
+ { "vehiclekndid": "17", "vehiclekndnm": "SRT" },
16
+ { "vehiclekndid": "19", "vehiclekndnm": "KTX-청룡" }
17
+ ],
18
+ "nodeList": [
19
+ {
20
+ "seoul": [
21
+ { "nodeid": "NAT130126", "nodename": "청량리" },
22
+ { "nodeid": "NAT010000", "nodename": "서울" },
23
+ { "nodeid": "NAT010032", "nodename": "용산" },
24
+ { "nodeid": "NATH30000", "nodename": "수서" },
25
+ { "nodeid": "NAT010091", "nodename": "영등포" },
26
+ { "nodeid": "NAT020040", "nodename": "상봉" }
27
+ ]
28
+ },
29
+ {
30
+ "incheon": [
31
+ { "nodeid": "NATC10580", "nodename": "인천공항T1" }
32
+ ]
33
+ },
34
+ {
35
+ "gyeonggi": [
36
+ { "nodeid": "NAT110147", "nodename": "행신" },
37
+ { "nodeid": "NAT010415", "nodename": "수원" },
38
+ { "nodeid": "NATH10219", "nodename": "광명" },
39
+ { "nodeid": "NATH30326", "nodename": "동탄" },
40
+ { "nodeid": "NATH30536", "nodename": "평택지제" },
41
+ { "nodeid": "NAT250007", "nodename": "판교" },
42
+ { "nodeid": "NAT280090", "nodename": "가남" },
43
+ { "nodeid": "NAT250428", "nodename": "부발" }
44
+ ]
45
+ },
46
+ {
47
+ "gangwon": [
48
+ { "nodeid": "NAT020864", "nodename": "서원주" },
49
+ { "nodeid": "NAT020947", "nodename": "원주" },
50
+ { "nodeid": "NAT021033", "nodename": "만종" },
51
+ { "nodeid": "NATN10428", "nodename": "둔내" },
52
+ { "nodeid": "NATN10230", "nodename": "횡성" },
53
+ { "nodeid": "NATN10787", "nodename": "진부" },
54
+ { "nodeid": "NATN10625", "nodename": "평창" },
55
+ { "nodeid": "NAT601936", "nodename": "강릉" },
56
+ { "nodeid": "NAT601774", "nodename": "정동진" },
57
+ { "nodeid": "NAT601485", "nodename": "동해" }
58
+ ]
59
+ },
60
+ {
61
+ "daejeon": [
62
+ { "nodeid": "NAT011668", "nodename": "대전" },
63
+ { "nodeid": "NAT030057", "nodename": "서대전" },
64
+ { "nodeid": "NAT011524", "nodename": "신탄진" }
65
+ ]
66
+ },
67
+ {
68
+ "chungnam": [
69
+ { "nodeid": "NAT050044", "nodename": "오송" },
70
+ { "nodeid": "NATH20438", "nodename": "공주" },
71
+ { "nodeid": "NAT030254", "nodename": "계룡" },
72
+ { "nodeid": "NAT030508", "nodename": "논산" }
73
+ ]
74
+ },
75
+ {
76
+ "chungbuk": [
77
+ { "nodeid": "NAT280212", "nodename": "감곡장호원" },
78
+ { "nodeid": "NAT280358", "nodename": "앙성온천" },
79
+ { "nodeid": "NAT280666", "nodename": "살미" },
80
+ { "nodeid": "NAT280751", "nodename": "수안보온천" },
81
+ { "nodeid": "NAT280814", "nodename": "연풍" },
82
+ { "nodeid": "NAT050827", "nodename": "충주" },
83
+ { "nodeid": "NAT021549", "nodename": "제천" },
84
+ { "nodeid": "NAT021784", "nodename": "단양" }
85
+ ]
86
+ },
87
+ {
88
+ "busan": [
89
+ { "nodeid": "NAT014445", "nodename": "부산" },
90
+ { "nodeid": "NAT750046", "nodename": "부전" },
91
+ { "nodeid": "NAT014150", "nodename": "물금" },
92
+ { "nodeid": "NAT014281", "nodename": "구포" }
93
+ ]
94
+ },
95
+ {
96
+ "gyeongnam": [
97
+ { "nodeid": "NATH13717", "nodename": "울산" },
98
+ { "nodeid": "NAT013841", "nodename": "밀양" },
99
+ { "nodeid": "NAT013841", "nodename": "밀양" },
100
+ { "nodeid": "NAT880177", "nodename": "진영" },
101
+ { "nodeid": "NAT880281", "nodename": "창원중앙" },
102
+ { "nodeid": "NAT880310", "nodename": "창원" },
103
+ { "nodeid": "NAT880345", "nodename": "마산" },
104
+ { "nodeid": "NAT880766", "nodename": "반성" },
105
+ { "nodeid": "NAT881014", "nodename": "진주" }
106
+ ]
107
+ },
108
+ {
109
+ "daegu": [
110
+ { "nodeid": "NAT013239", "nodename": "대구" },
111
+ { "nodeid": "NAT013271", "nodename": "동대구" },
112
+ { "nodeid": "NAT013189", "nodename": "서대구" }
113
+ ]
114
+ },
115
+ {
116
+ "gyeongbuk": [
117
+ { "nodeid": "NAT022053", "nodename": "풍기" },
118
+ { "nodeid": "NAT022188", "nodename": "영주" },
119
+ { "nodeid": "NAT022558", "nodename": "안동" },
120
+ { "nodeid": "NAT022844", "nodename": "의성" },
121
+ { "nodeid": "NAT023449", "nodename": "영천" },
122
+ { "nodeid": "NATH12383", "nodename": "김천구미" },
123
+ { "nodeid": "NAT280927", "nodename": "문경" },
124
+ { "nodeid": "NATH13421", "nodename": "경주" },
125
+ { "nodeid": "NAT8B0351", "nodename": "포항" }
126
+ ]
127
+ },
128
+ {
129
+ "jeonbuk": [
130
+ { "nodeid": "NAT030879", "nodename": "익산" },
131
+ { "nodeid": "NAT040257", "nodename": "전주" },
132
+ { "nodeid": "NAT031056", "nodename": "김제" },
133
+ { "nodeid": "NAT040868", "nodename": "남원" },
134
+ { "nodeid": "NAT031314", "nodename": "정읍" },
135
+ { "nodeid": "NAT040536", "nodename": "임실" },
136
+ { "nodeid": "NAT040667", "nodename": "오수" }
137
+ ]
138
+ },
139
+ {
140
+ "jeonnam": [
141
+ { "nodeid": "NAT031638", "nodename": "장성" },
142
+ { "nodeid": "NAT031857", "nodename": "광주송정" },
143
+ { "nodeid": "NAT032563", "nodename": "목포" },
144
+ { "nodeid": "NAT031998", "nodename": "나주" },
145
+ { "nodeid": "NAT041072", "nodename": "곡성" },
146
+ { "nodeid": "NAT041285", "nodename": "구례구" },
147
+ { "nodeid": "NAT041595", "nodename": "순천" },
148
+ { "nodeid": "NAT041993", "nodename": "여수EXPO" }
149
+ ]
150
+ }
151
+ ],
152
+ "city": [
153
+ { "citycode": 11, "cityname": "서울특별시" },
154
+ { "citycode": 12, "cityname": "세종특별시" },
155
+ { "citycode": 21, "cityname": "부산광역시" },
156
+ { "citycode": 22, "cityname": "대구광역시" },
157
+ { "citycode": 23, "cityname": "인천광역시" },
158
+ { "citycode": 24, "cityname": "광주광역시" },
159
+ { "citycode": 25, "cityname": "대전광역시" },
160
+ { "citycode": 26, "cityname": "울산광역시" },
161
+ { "citycode": 31, "cityname": "경기도" },
162
+ { "citycode": 32, "cityname": "강원도" },
163
+ { "citycode": 33, "cityname": "충청북도" },
164
+ { "citycode": 34, "cityname": "충청남도" },
165
+ { "citycode": 35, "cityname": "전라북도" },
166
+ { "citycode": 36, "cityname": "전라남도" },
167
+ { "citycode": 37, "cityname": "경상북도" },
168
+ { "citycode": 38, "cityname": "경상남도" }
169
+ ]
170
+ }
@@ -0,0 +1,11 @@
1
+ export declare class TrainParseService {
2
+ constructor();
3
+ trainList(): Promise<void>;
4
+ parseToNodeId(trainName: string): Promise<string>;
5
+ trainDepArrFinder(depName: string, arrName: string): Promise<{
6
+ depNodeId: any;
7
+ arrNodeId: any;
8
+ }>;
9
+ findStation(station: String): Promise<any>;
10
+ stationList(): Promise<any[]>;
11
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TrainParseService = void 0;
7
+ const train_data_json_1 = __importDefault(require("./train-data.json"));
8
+ class TrainParseService {
9
+ constructor() { }
10
+ async trainList() {
11
+ const trainList = train_data_json_1.default.trainNames;
12
+ trainList.forEach(train => {
13
+ console.log(train);
14
+ });
15
+ }
16
+ async parseToNodeId(trainName) {
17
+ const trainNames = train_data_json_1.default.trainNames;
18
+ const vehicleMapping = train_data_json_1.default.vehicleMapping;
19
+ const match = vehicleMapping.find(v => v.vehiclekndnm.replace(/-/g, '').toLowerCase() === trainName.toLowerCase());
20
+ if (!match) {
21
+ console.error("❌ 잘못된 기차 이름:", trainName);
22
+ console.log("입력 가능 전체 기차종류:", trainNames.join(', '));
23
+ }
24
+ return match ? String(match.vehiclekndid) : '00';
25
+ }
26
+ async trainDepArrFinder(depName, arrName) {
27
+ const depNode = await this.findStation(depName);
28
+ const arrNode = await this.findStation(arrName);
29
+ if (!depNode) {
30
+ console.log(`출발역 "${depName}"을(를) 찾을 수 없습니다. 역명을 다시 확인해 주세요.`);
31
+ }
32
+ if (!arrNode) {
33
+ console.log(`도착역 "${arrName}"을(를) 찾을 수 없습니다. 역명을 다시 확인해 주세요.`);
34
+ }
35
+ const depNodeId = depNode.nodeid;
36
+ const arrNodeId = arrNode.nodeid;
37
+ return {
38
+ depNodeId,
39
+ arrNodeId,
40
+ };
41
+ }
42
+ async findStation(station) {
43
+ for (const region of train_data_json_1.default.nodeList) {
44
+ const regionKey = Object.keys(region)[0];
45
+ const nodes = region[regionKey];
46
+ const foundStation = nodes.find(e => e.nodename.toLowerCase().trim() === station.toLowerCase().trim());
47
+ if (foundStation) {
48
+ return foundStation;
49
+ }
50
+ }
51
+ return null;
52
+ }
53
+ async stationList() {
54
+ const allStations = [];
55
+ for (const region of train_data_json_1.default.nodeList) {
56
+ const regionKey = Object.keys(region)[0];
57
+ const nodes = region[regionKey];
58
+ nodes.forEach(e => {
59
+ allStations.push(e.nodename);
60
+ });
61
+ }
62
+ return allStations;
63
+ }
64
+ }
65
+ exports.TrainParseService = TrainParseService;
66
+ //# sourceMappingURL=train-parse.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"train-parse.service.js","sourceRoot":"","sources":["../../src/train/train-parse.service.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export declare class TrainModule {
2
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TrainModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const train_service_1 = require("./train.service");
12
+ const train_parse_service_1 = require("./train-parse.service");
13
+ let TrainModule = class TrainModule {
14
+ };
15
+ exports.TrainModule = TrainModule;
16
+ exports.TrainModule = TrainModule = __decorate([
17
+ (0, common_1.Module)({
18
+ providers: [train_service_1.TrainService, train_parse_service_1.TrainParseService],
19
+ })
20
+ ], TrainModule);
21
+ //# sourceMappingURL=train.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"train.module.js","sourceRoot":"","sources":["../../src/train/train.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAC/C,+DAA0D;AAKnD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAHvB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,4BAAY,EAAE,uCAAiB,CAAC;KAC7C,CAAC;GACW,WAAW,CAAG"}
@@ -0,0 +1,13 @@
1
+ import { TrainParseService } from './train-parse.service';
2
+ export declare class TrainService {
3
+ private readonly trainParseService;
4
+ private serviceKey;
5
+ constructor(trainParseService: TrainParseService);
6
+ formatDateTime(dateTime: number): string;
7
+ trainList(): Promise<void>;
8
+ today(date: string): Promise<void>;
9
+ searchTrain(depName: string, arrName: string, date: string, trainName: string): Promise<void>;
10
+ cityCodeList(cityCode: string): Promise<void>;
11
+ findStation(station: string): Promise<void>;
12
+ stationList(): Promise<void>;
13
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TrainService = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class TrainService {
9
+ constructor(trainParseService) {
10
+ this.trainParseService = trainParseService;
11
+ this.serviceKey = 'd2a259fae046ba1b65a3c083fdd80de2a781e37eb27f939d758af1de25f606f9';
12
+ }
13
+ formatDateTime(dateTime) {
14
+ const dateTimeString = dateTime.toString();
15
+ const year = dateTimeString.slice(0, 4);
16
+ const month = dateTimeString.slice(4, 6);
17
+ const day = dateTimeString.slice(6, 8);
18
+ const hour = dateTimeString.slice(8, 10);
19
+ const minute = dateTimeString.slice(10, 12);
20
+ return `${year}-${month}-${day} ${hour}:${minute}`;
21
+ }
22
+ async trainList() {
23
+ return await this.trainParseService.trainList();
24
+ }
25
+ async today(date) {
26
+ const now = new Date();
27
+ const kstOffset = 9 * 60;
28
+ now.setMinutes(now.getMinutes() + now.getTimezoneOffset() + kstOffset);
29
+ const currentDate = now.toISOString().slice(0, 10).replace(/-/g, '');
30
+ if (date < currentDate) {
31
+ throw new Error('The provided date is earlier than the current date.');
32
+ }
33
+ return;
34
+ }
35
+ async searchTrain(depName, arrName, date, trainName) {
36
+ var _a, _b, _c, _d;
37
+ const url = 'http://apis.data.go.kr/1613000/TrainInfoService/getStrtpntAlocFndTrainInfo';
38
+ this.today(date);
39
+ const trainGradeCode = await this.trainParseService.parseToNodeId(trainName);
40
+ const nodeId = await this.trainParseService.trainDepArrFinder(depName, arrName);
41
+ const depPlaceId = nodeId.depNodeId;
42
+ const arrPlaceId = nodeId.arrNodeId;
43
+ const params = new URLSearchParams({
44
+ serviceKey: this.serviceKey,
45
+ _type: 'json',
46
+ depPlaceId,
47
+ arrPlaceId,
48
+ depPlandTime: date,
49
+ trainGradeCode,
50
+ });
51
+ const response = await axios_1.default.get(`${url}?${params.toString()}`, { responseType: 'json' });
52
+ const items = ((_d = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.body) === null || _c === void 0 ? void 0 : _c.items) === null || _d === void 0 ? void 0 : _d.item) || [];
53
+ if (!items.length) {
54
+ console.log('조회된 열차가 없습니다.');
55
+ }
56
+ console.log('=== 🚆 기차 조회 결과 ===');
57
+ items.forEach((item) => {
58
+ console.log('-------------조회--------------');
59
+ console.log(`열차번호: ${item.trainno}`);
60
+ console.log(`출발지: ${item.depplacename}`);
61
+ console.log(`출발 시간: ${this.formatDateTime(item.depplandtime)}`);
62
+ console.log(`도착지: ${item.arrplacename}`);
63
+ console.log(`도착 시간: ${this.formatDateTime(item.arrplandtime)}`);
64
+ console.log(`종류: ${item.traingradename}`);
65
+ console.log('-----------------------------');
66
+ });
67
+ }
68
+ async cityCodeList(cityCode) {
69
+ var _a, _b, _c, _d;
70
+ const url = 'http://apis.data.go.kr/1613000/TrainInfoService/getCtyAcctoTrainSttnList';
71
+ const params = new URLSearchParams({
72
+ numOfRows: "100",
73
+ serviceKey: this.serviceKey,
74
+ _type: 'json',
75
+ cityCode,
76
+ });
77
+ const response = await axios_1.default.get(`${url}?${params.toString()}`, { responseType: 'json' });
78
+ const items = ((_d = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.body) === null || _c === void 0 ? void 0 : _c.items) === null || _d === void 0 ? void 0 : _d.item) || [];
79
+ console.log(cityCode);
80
+ console.log('=== 🏢 기차역 목록 ===');
81
+ console.log(items);
82
+ }
83
+ async findStation(station) {
84
+ const exactlyStation = await this.trainParseService.findStation(station);
85
+ if (exactlyStation) {
86
+ console.log(`"${station}"은 존재하는 역 입니다.`);
87
+ }
88
+ else {
89
+ console.log('"trainfinder stationlist" 명령어로 존재하는 역을 확인해 보세요.');
90
+ }
91
+ }
92
+ async stationList() {
93
+ const list = await this.trainParseService.stationList();
94
+ list.forEach((item) => {
95
+ console.log(item);
96
+ });
97
+ }
98
+ }
99
+ exports.TrainService = TrainService;
100
+ //# sourceMappingURL=train.service.js.map