aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-13 20:02:18 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-13 20:02:18 +0100
commitc5a889ce9e216de27d07e79d12500f85d6a89a8b (patch)
treebb8ff1238fdf996399d7e75772707418a17e3015
parent0b3a3db4f9992966706a36ea3025b5159dd2b3ea (diff)
downloadoeffi-web-c5a889ce9e216de27d07e79d12500f85d6a89a8b.tar.gz
oeffi-web-c5a889ce9e216de27d07e79d12500f85d6a89a8b.tar.bz2
oeffi-web-c5a889ce9e216de27d07e79d12500f85d6a89a8b.zip
remove git-submodule nimhafas, add nimhafas as nimble dependency
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules3
-rw-r--r--oeffi.nimble1
-rw-r--r--src/cache.nim3
-rw-r--r--src/cache_types.nim2
-rw-r--r--src/endpoints/api/journeys.nim3
-rw-r--r--src/endpoints/api/moreJourneys.nim3
-rw-r--r--src/endpoints/api/refreshJourney.nim3
-rw-r--r--src/endpoints/api/suggestions.nim2
-rw-r--r--src/endpoints/journeyHandler.nim3
-rw-r--r--src/endpoints/journeysHandler.nim3
-rw-r--r--src/endpoints/searchHandler.nim3
-rw-r--r--src/endpoints/suggestionsHandler.nim3
-rw-r--r--src/formaters/formatFullResponse.nim4
-rw-r--r--src/formaters/formaters.nim2
-rw-r--r--src/formaters/renderJourney.nim4
-rw-r--r--src/formaters/renderJourneys.nim4
m---------src/hafas0
-rw-r--r--src/oeffi.nim4
-rw-r--r--src/types.nim196
-rw-r--r--src/utils.nim3
21 files changed, 35 insertions, 216 deletions
diff --git a/.gitignore b/.gitignore
index 16cd66a..8b944ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ oeffisearch_nojs
cache
data
.DS_Store
+
+oeffi \ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index dca2950..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "src/hafas"]
- path = src/hafas
- url = https://cgit.ctu.cx/hafas.nim
diff --git a/oeffi.nimble b/oeffi.nimble
index 6e36ce4..c4cc55d 100644
--- a/oeffi.nimble
+++ b/oeffi.nimble
@@ -9,3 +9,4 @@ bin = @["oeffi"]
# Dependencies
requires "nim >= 1.0.4"
+requires "https://cgit.ctu.cx/nimhafas"
diff --git a/src/cache.nim b/src/cache.nim
index 66234d6..978de4e 100644
--- a/src/cache.nim
+++ b/src/cache.nim
@@ -1,5 +1,6 @@
import tables, random, os, times, json, asyncfile, asyncdispatch, parseutils
-import types, cache_types
+import nimhafas
+import cache_types, types
randomize()
diff --git a/src/cache_types.nim b/src/cache_types.nim
index b6e81c5..72e63e9 100644
--- a/src/cache_types.nim
+++ b/src/cache_types.nim
@@ -1,5 +1,5 @@
import tables
-import types
+import nimhafas
type
moreJourneysMode* = enum
diff --git a/src/endpoints/api/journeys.nim b/src/endpoints/api/journeys.nim
index 33b7e7c..f3f7210 100644
--- a/src/endpoints/api/journeys.nim
+++ b/src/endpoints/api/journeys.nim
@@ -1,5 +1,6 @@
import json, tables, options, asyncdispatch
-import ../../types, ../../hafas/hafas, ../../cache
+import nimhafas
+import ../../types, ../../cache
when not defined(release):
import hotcodereloading
diff --git a/src/endpoints/api/moreJourneys.nim b/src/endpoints/api/moreJourneys.nim
index eb9b89a..1ec7666 100644
--- a/src/endpoints/api/moreJourneys.nim
+++ b/src/endpoints/api/moreJourneys.nim
@@ -1,5 +1,6 @@
import json, tables, options, asyncdispatch, strutils
-import ../../types, ../../cache_types, ../../hafas/hafas, ../../cache
+import nimhafas
+import ../../types, ../../cache_types, ../../cache
proc moreJourneysEndpoint*(requestData: JsonNode): Future[JsonNode] {.async.} =
var reqId = requestData{"reqId"}.getStr()
diff --git a/src/endpoints/api/refreshJourney.nim b/src/endpoints/api/refreshJourney.nim
index 154c9f1..2275ad5 100644
--- a/src/endpoints/api/refreshJourney.nim
+++ b/src/endpoints/api/refreshJourney.nim
@@ -1,5 +1,6 @@
import json, tables, options, asyncdispatch, strutils
-import ../../types, ../../cache_types, ../../hafas/hafas, ../../cache
+import nimhafas
+import ../../types, ../../cache_types, ../../cache
proc refreshJourneyEndpoint*(requestData: JsonNode): Future[JsonNode] {.async.} =
let reqId = requestData{"reqId"}.getStr()
diff --git a/src/endpoints/api/suggestions.nim b/src/endpoints/api/suggestions.nim
index 6509a27..310af50 100644
--- a/src/endpoints/api/suggestions.nim
+++ b/src/endpoints/api/suggestions.nim
@@ -1,5 +1,5 @@
import json, options, asyncdispatch
-import ../../types, ../../hafas/hafas
+import nimhafas
proc suggestionsEndpoint* (data: JsonNode): Future[JsonNode] {.async.} =
return %* (await suggestions(data.to(SuggestionsParams)))
diff --git a/src/endpoints/journeyHandler.nim b/src/endpoints/journeyHandler.nim
index 219967e..070e576 100644
--- a/src/endpoints/journeyHandler.nim
+++ b/src/endpoints/journeyHandler.nim
@@ -1,6 +1,7 @@
import json, options, strutils, tables
+import nimhafas
import ../asyncWebServer
-import ../utils, ../translations, ../types, ../cache_types, ../cache, ../hafas/hafas
+import ../utils, ../translations, ../types, ../cache_types, ../cache
import ../formaters/renderJourney
proc journeyHandler* (request: Request, server: ServerRef) {.async.} =
diff --git a/src/endpoints/journeysHandler.nim b/src/endpoints/journeysHandler.nim
index 0bd01e4..bebd563 100644
--- a/src/endpoints/journeysHandler.nim
+++ b/src/endpoints/journeysHandler.nim
@@ -1,6 +1,7 @@
import json, asyncdispatch, options, strutils
+import nimhafas
import ../asyncWebServer
-import ../utils, ../translations, ../types, ../cache_types, ../cache, ../hafas/hafas
+import ../utils, ../translations, ../types, ../cache_types, ../cache
import ../formaters/renderJourneys
proc journeysHandler* (request: Request, server: ServerRef) {.async.} =
diff --git a/src/endpoints/searchHandler.nim b/src/endpoints/searchHandler.nim
index 1d4ee6f..2612b71 100644
--- a/src/endpoints/searchHandler.nim
+++ b/src/endpoints/searchHandler.nim
@@ -1,6 +1,7 @@
import json, times, options, strutils
+import nimhafas
import ../asyncWebServer
-import ../utils, ../translations, ../types, ../cache_types, ../cache, ../hafas/hafas
+import ../utils, ../translations, ../types, ../cache_types, ../cache
import ../formaters/formaters, ../formaters/renderJourneys
proc searchHandler* (request: Request, server: ServerRef) {.async.} =
diff --git a/src/endpoints/suggestionsHandler.nim b/src/endpoints/suggestionsHandler.nim
index f78872c..2b060f9 100644
--- a/src/endpoints/suggestionsHandler.nim
+++ b/src/endpoints/suggestionsHandler.nim
@@ -1,6 +1,7 @@
import json, options, strutils
+import nimhafas
import ../asyncWebServer
-import ../types, ../hafas/hafas
+import ../types
import ../formaters/formaters
proc suggestionsHandler* (request: Request, server: ServerRef) {.async.} =
diff --git a/src/formaters/formatFullResponse.nim b/src/formaters/formatFullResponse.nim
index 84b6379..8317cbc 100644
--- a/src/formaters/formatFullResponse.nim
+++ b/src/formaters/formatFullResponse.nim
@@ -1,4 +1,6 @@
-import tables, json, ../types, ../cache_types
+import tables, json
+import nimhafas
+import ../types, ../cache_types
proc formatFullResponse* (cacheObj: CacheObject): JsonNode =
var response = %* {
diff --git a/src/formaters/formaters.nim b/src/formaters/formaters.nim
index 961f848..6b7bbd5 100644
--- a/src/formaters/formaters.nim
+++ b/src/formaters/formaters.nim
@@ -1,5 +1,5 @@
import options, math, times
-import ../types
+import nimhafas
proc formatPoint* (point: Point): string {.exportc.} =
if not point.location.isNone:
diff --git a/src/formaters/renderJourney.nim b/src/formaters/renderJourney.nim
index 0a052ad..d83a87c 100644
--- a/src/formaters/renderJourney.nim
+++ b/src/formaters/renderJourney.nim
@@ -1,6 +1,6 @@
import json, tables, options, math
-import ../types, ../cache_types
-import formaters
+import nimhafas
+import ../types, ../cache_types, formaters
template getPlannedOrPrognosedTime(obj: untyped): int64 =
if not obj.prognosedTime.isNone:
diff --git a/src/formaters/renderJourneys.nim b/src/formaters/renderJourneys.nim
index be75bde..66fda2c 100644
--- a/src/formaters/renderJourneys.nim
+++ b/src/formaters/renderJourneys.nim
@@ -1,6 +1,6 @@
import json, tables, options, sequtils, strutils, algorithm, math
-import ../types, ../cache_types
-import formaters
+import nimhafas
+import ../cache_types, formaters
template getPlannedOrPrognosedTime(obj: untyped): int64 =
if not obj.prognosedTime.isNone:
diff --git a/src/hafas b/src/hafas
deleted file mode 160000
-Subproject e815bbfd2ef4f49c4e3a757739a60d802bcc53f
diff --git a/src/oeffi.nim b/src/oeffi.nim
index dc8ac3a..bfb2ce5 100644
--- a/src/oeffi.nim
+++ b/src/oeffi.nim
@@ -13,7 +13,9 @@ import endpoints/api/journeys
import endpoints/api/moreJourneys
import endpoints/api/refreshJourney
-import types, hafas/hafas, formaters/formaters
+import nimhafas
+
+import types, formaters/formaters
proc removePidFile() =
if getEnv("PID_FILE") != "":
diff --git a/src/types.nim b/src/types.nim
index 00868d1..9945523 100644
--- a/src/types.nim
+++ b/src/types.nim
@@ -1,4 +1,3 @@
-import options
import httpcore
type
@@ -7,198 +6,5 @@ type
msg*: string
headers*: HttpHeaders
- Stop* = object
- id*: string
- name*: string
- location*: Location
- products*: Products
- station*: Option[Station]
-
- Station* = object
- id*: int
- name*: string
- location*: Location
- products*: Products
-
- Location* = object
- latitude*: float
- longitude*: float
- name*: Option[string]
- address*: Option[string]
- id*: Option[string]
-
- Product* = enum
- nationalExp, national, regionalExp, regional, suburban, bus, ferry, subway, tram, taxi
-
- Mode* = enum
- Train, Bus, Watercraft, Taxi, Walking
-
- Products* = object
- nationalExp*: bool
- national*: bool
- regionalExp*: bool
- regional*: bool
- suburban*: bool
- bus*: bool
- ferry*: bool
- subway*: bool
- tram*: bool
- taxi*: bool
-
- Point* = object
- stop*: Option[Stop]
- location*: Option[Location]
-
- Journey* = object
- refreshToken*: string
- lastUpdated*: int64
- legs*: seq[Leg]
- cycle*: Option[Cycle]
- price*: Option[Price]
-
- LegPart* = object
- point*: Point
- plannedTime*: int64
- prognosedTime*: Option[int64]
- plannedPlatform*: Option[string]
- prognosedPlatform*: Option[string]
-
- Leg* = object
- isWalking*: bool
- isTransfer*: bool
- cancelled*: bool
- departure*: LegPart
- arrival*: LegPart
- polyline*: Option[Polyline]
- distance*: Option[int] # required for isWalking or isTransfer
- tripId*: Option[string] # required for not isWalking and not isTranfer
- line*: Option[Line] # required for not isWalking and not isTranfer
- direction*: Option[string] # required for not isWalking and not isTranfer
- cycle*: Option[Cycle]
- stopovers*: Option[seq[Stopover]]
- remarks*: Option[seq[Remark]]
-
- Line* = object
- id*: string
- name*: string
- mode*: Mode
- product*: Product
- tripNum*: string
- productName*: string
- fullProductName*: string
- operator*: Option[Operator]
- additionalName*: Option[string]
- trainType*: Option[string]
- trainTypeShort*: Option[string]
-
- Operator* = object
- id*: string
- name*: string
-
- Cycle* = object
- min*: Option[int]
- max*: Option[int]
- nr*: Option[int]
-
- Price* = object
- amount*: float
- currency*: Option[string]
-
- StopoverPart* = object
- plannedTime*: Option[int64]
- prognosedTime*: Option[int64]
- plannedPlatform*: Option[string]
- prognosedPlatform*: Option[string]
-
- Stopover* = object
- stop*: Stop
- cancelled*: bool
- departure*: StopoverPart
- arrival*: StopoverPart
-
- Remark* = object
- `type`*: Option[string]
- code*: Option[string]
- summary*: Option[string]
- text*: Option[string]
- tripId*: Option[string]
-
- JourneysResponse* = object
- earlierRef*: string
- laterRef*: string
- journeys*: seq[Journey]
-
- Accessibility* = enum
- none, partial, complete
-
- SuggestionsParams* = object
- query*: string
- results*: Option[int] #default value: 10
- stations*: Option[bool] #default value: true
- poi*: Option[bool] #default value: true
- addresses*: Option[bool] #default value: true
-
- JourneysParams* = object
- fromPoint*: Point
- toPoint*: Point
- viaPoint*: Option[Point] #default value: null support in hafas backend: ✅
- earlierRef*: Option[string] #default value: null support in hafas backend: ✅
- laterRef*: Option[string] #default value: null support in hafas backend: ✅
- results*: Option[int] #default value: 5 support in hafas backend: ✅
- stopovers*: Option[bool] #default value: false support in hafas backend: ✅
- polylines*: Option[bool] #default value: false support in hafas backend: ✅
- remarks*: Option[bool] #default value: true support in hafas backend:
- bikeFriendly*: Option[bool] #default value: false support in hafas backend:
- tickets*: Option[bool] #default value: false support in hafas backend: ✅
- startWithWalking*: Option[bool] #default value: true support in hafas backend: ✅
- scheduledDays*: Option[bool]
- accessibility*: Option[Accessibility] #default value: none support in hafas backend: ✅
- transfers*: Option[int] #default value: -1 support in hafas backend: ✅
- transferTime*: Option[int] #default value: 00 support in hafas backend: ✅
- arrival*: Option[int64] #default value: null support in hafas backend: ✅
- departure*: Option[int64] #default value: null support in hafas backend: ✅
- products*: Option[Products] #default value: all true support in hafas backend: ✅
-
- RefreshJourneyParams* = object
- refreshToken*: string
- stopovers*: Option[bool] #default value: false support in hafas backend: ✅
- polylines*: Option[bool] #default value: false support in hafas backend: ✅
- tickets*: Option[bool] #default value: false support in hafas backend: ✅
-
- Polyline* = object
- `type`*: string
- features*: seq[Feature]
-
- Feature* = object
- `type`*: string
- properties*: Option[Stop]
- geometry*: FeatureGeometry
-
- FeatureGeometry* = object
- `type`*: string
- coordinates*: seq[float]
-
-
notFoundException* = object of CatchableError
- errorException* = object of CatchableError
-
- hafasExceptionKind* = enum
- SERVER_ERROR, ACCESS_DENIED, INVALID_REQUEST, NOT_FOUND
-
- hafasException* = ref object of CatchableError
- code*: hafasExceptionKind
- message*: string
- statusCode*: HttpCode
-
-const MODES* = [
- Train, # nationalExp
- Train, # national
- Train, # regionalExp
- Train, # regional
- Train, # suburban
- Bus, # bus
- Watercraft, # ferry
- Train, # subway
- Train, # tram
- Taxi, # taxi
-]
+ errorException* = object of CatchableError \ No newline at end of file
diff --git a/src/utils.nim b/src/utils.nim
index 2b5dcee..19bc532 100644
--- a/src/utils.nim
+++ b/src/utils.nim
@@ -1,5 +1,6 @@
import json, asyncdispatch, asynchttpserver, options, strutils, httpcore
-import types, translations, hafas/hafas
+import nimhafas
+import types, translations
import moustachu, moustachu_context
proc getPoint* (name: string): Future[Point] {.async} =