-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I have an endpoint that looks approximately like this:
SAS.Auth [SAS.Cookie] LoggedIn :> Capture "tournamentId" TournamentId :> "start" :> Post '[JSON] (Entity Tournament)
Unfortunately, attempt to generate JS for this API does not typecheck. The error is:
app\Main.hs:24:14: error:
* No instance for (servant-foreign-0.15.4:Servant.Foreign.Internal.HasForeign
NoTypes NoContent StartTournamentApi)
arising from a use of `jsForAPI'
* In the expression:
jsForAPI (Proxy :: Proxy StartTournamentApi) jquery
In an equation for `js':
js = jsForAPI (Proxy :: Proxy StartTournamentApi) jquery
In the expression:
do let js = jsForAPI (Proxy :: Proxy StartTournamentApi) jquery
TIO.writeFile "static/js/api.js" js
|
24 | let js = jsForAPI (Proxy :: Proxy StartTournamentApi) jquery
I assume that js generator should completely ignore auth requirement because XMLHttpRequest sends cookies which are used for authentication.
The workaround I found is to create a following instance:
instance HasForeign lang ftype api => HasForeign lang ftype (Auth auths val :> api) where
type Foreign ftype (Auth auths val :> api) = Foreign ftype api
foreignFor lang ftype Proxy = foreignFor lang ftype (Proxy :: Proxy api)
Metadata
Metadata
Assignees
Labels
No labels