File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ class API extends ApplicationAPI {
3939 ...sharedRouters ,
4040 Routers . RouteV2Router ,
4141 ] ,
42+ v3 : [
43+ ...sharedRouters ,
44+ Routers . RouteV3Router ,
45+ ] ,
4246 } ;
4347 }
4448}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import PlaceIDCoordinatesRouter from './v1/PlaceIDCoordinatesRouter';
1212import RouteRouter from './v1/RouteRouter' ;
1313import RouteSelectedRouter from './v1/RouteSelectedRouter' ;
1414import RouteV2Router from './v2/RouteRouter' ;
15+ import RouteV3Router from './v3/RouteRouter' ;
1516import SearchRouter from './v1/SearchRouter' ;
1617import TrackingRouter from './v1/TrackingRouter' ;
1718
@@ -30,6 +31,7 @@ export default {
3031 RouteRouter,
3132 RouteSelectedRouter,
3233 RouteV2Router,
34+ RouteV3Router,
3335 SearchRouter,
3436 TrackingRouter,
3537} ;
Original file line number Diff line number Diff line change 1+ // @flow
2+ import type Request from 'express' ;
3+ import AnalyticsUtils from '../../utils/AnalyticsUtils' ;
4+ import ApplicationRouter from '../../appdev/ApplicationRouter' ;
5+ import LogUtils from '../../utils/LogUtils' ;
6+ import RouteUtils from '../../utils/RouteUtils' ;
7+
8+ class RouteRouter extends ApplicationRouter < Object > {
9+ constructor ( ) {
10+ super ( [ 'POST' ] ) ;
11+ }
12+
13+ getPath ( ) : string {
14+ return '/route/' ;
15+ }
16+
17+ async content ( req : Request ) : Promise < Object > {
18+ const {
19+ destinationName,
20+ end,
21+ arriveBy,
22+ originName,
23+ start,
24+ time,
25+ uid,
26+ } = req . body ;
27+
28+ const isArriveBy = ( arriveBy === '1' || arriveBy === true || arriveBy === 'true' || arriveBy === 'True' ) ;
29+
30+ const isOriginBusStop = await RouteUtils . isBusStop ( originName ) ;
31+ const originBusStopName = isOriginBusStop ? originName : null ;
32+ const sectionedRoutes = await RouteUtils . getSectionedRoutes (
33+ originName ,
34+ destinationName ,
35+ end ,
36+ start ,
37+ time ,
38+ isArriveBy ,
39+ originBusStopName ,
40+ ) ;
41+ const routes = RouteUtils . flatten ( Object . values ( sectionedRoutes ) ) ;
42+ if ( routes . length > 0 ) {
43+ const request = {
44+ isArriveBy,
45+ destinationName,
46+ end : routes [ 0 ] . endCoords ,
47+ originName,
48+ routeId : routes [ 0 ] . routeId ,
49+ start : routes [ 0 ] . startCoords ,
50+ time,
51+ uid,
52+ } ;
53+ LogUtils . log ( { category : 'routeRequest' , request } ) ;
54+ }
55+ AnalyticsUtils . assignRouteIdsAndCache ( routes ) ;
56+
57+ return sectionedRoutes ;
58+ }
59+ }
60+
61+ export default new RouteRouter ( ) . router ;
You can’t perform that action at this time.
0 commit comments