Giter Club home page Giter Club logo

servant-static-th's Introduction

Servant.Static.TH

Build Status Hackage Stackage LTS Stackage Nightly BSD3 license

servant-static-th allows you to embed a directory of static files in your application and serve them from your Servant server

For documentation and usage examples, see the documentation on Hackage.

servant-static-th's People

Contributors

arowm avatar cdepillabout avatar spencertipping avatar vendamere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

servant-static-th's Issues

Compressed assets

Hi,

I wonder if it's possible to modify the public API of this library in a way that would allow embedding of compressed assets? The idea is to apply the most aggressive gzip compression on JS/CSS assets as part of a build pipeline, so that they are served directly as gzipped resources without having to spend CPU cycles on on-the-fly encoding.

Unknown extension type "map"

These are source-map files for minified / uglified CSS/JS files. There should probably be a config option in the user-facing API which controls whether these files should be served, or not.

Serving root path

Is there a way to configure servant-static-th to map particular file to / path? Based on the documentation there doesn't seem to be a way to do this currently. Is there a way around this limitation?

Building with cabal

Has anybody experience using this package with cabal?

My problem is that the FilePaths can only be resolved if I give the absolute Path, but I would like the package to be self-contained.
Specifying data-dir in the .cabal file and accessing the file via getDataDir does not work since the files are needed at compile-time, not at runtime.

Type-safe links?

Is there a recommended way of generating type-safe links for a directory who's API has been created by createApiAndServerDecs?

Tests not compiling

@nix { "action": "setPhase", "phase": "setupCompilerEnvironmentPhase" }
setupCompilerEnvironmentPhase
Build with /nix/store/qs0m6r89s0sm5i0bij8c4khy0sk656ml-ghc-9.8.1.
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/4kdq9ia4lcszb9afbl7gg58s29as04pf-servant-static-th-1.0.0.0.tar.gz
source root is servant-static-th-1.0.0.0
setting SOURCE_DATE_EPOCH to timestamp 1611152934 of file servant-static-th-1.0.0.0/test/Spec/ServerSpec.hs
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "compileBuildDriverPhase" }
compileBuildDriverPhase
setupCompileFlags: -package-db=/build/tmp.jPVZZzmdcS/setup-package.conf.d -j16 +RTS -A64M -RTS -threaded -rtsopts
[1 of 2] Compiling Main             ( Setup.hs, /build/tmp.jPVZZzmdcS/Main.o )
[2 of 2] Linking Setup
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
configureFlags: --verbose --prefix=/nix/store/xhh4a5nfj269k1kkx56aiadbkg39hrc3-servant-static-th-1.0.0.0 --libdir=$prefix/lib/$compiler/lib --libsubdir=$abi/$libname --docdir=/nix/store/myhdis6jc84d8b8zzy4scj1llcc3amfv-servant-static-th-1.0.0.0-doc/share/doc/servant-static-th-1.0.0.0 --with-gcc=gcc --package-db=/build/tmp.jPVZZzmdcS/package.conf.d --ghc-options=-j16 +RTS -A64M -RTS --disable-split-objs --enable-library-profiling --profiling-detail=exported-functions --disable-profiling --enable-shared --disable-coverage --enable-static --disable-executable-dynamic --enable-tests --disable-benchmarks --enable-library-vanilla --disable-library-for-ghci --ghc-option=-split-sections --ghc-options=-haddock --extra-lib-dirs=/nix/store/5i51nfixxx3p3gshkfsjj4bzp7wajwxz-ncurses-6.4/lib --extra-lib-dirs=/nix/store/9kd4bc8fpclpvf1vdwlbila71svyb6w1-libffi-3.4.4/lib --extra-lib-dirs=/nix/store/a7lb858d0gylghivrfgd8k0dpgi87xwp-elfutils-0.190/lib --extra-lib-dirs=/nix/store/s3s7gv33p88kzbgki2bprg2a1nc7jnf8-gmp-with-cxx-6.3.0/lib --extra-lib-dirs=/nix/store/qs0m6r89s0sm5i0bij8c4khy0sk656ml-ghc-9.8.1/lib
Using Parsec parser
Configuring servant-static-th-1.0.0.0...
Flags chosen: buildexample=False
Dependency base >=4.8 && <5: using base-4.19.0.0
Dependency blaze-html: using blaze-html-0.9.1.2
Dependency bytestring: using bytestring-0.12.0.2
Dependency containers: using containers-0.6.8
Dependency directory >=1.2.5.0: using directory-1.3.8.1
Dependency filepath: using filepath-1.4.100.4
Dependency http-media: using http-media-0.8.1.1
Dependency semigroups: using semigroups-0.20
Dependency servant >=0.8: using servant-0.20.1
Dependency servant-blaze >=0.7: using servant-blaze-0.9.1
Dependency servant-server >=0.8: using servant-server-0.20
Dependency template-haskell: using template-haskell-2.21.0.0
Dependency text: using text-2.1
Dependency Glob: using Glob-0.10.2
Dependency base: using base-4.19.0.0
Dependency doctest: using doctest-0.22.2
Dependency base: using base-4.19.0.0
Dependency blaze-html: using blaze-html-0.9.1.2
Dependency bytestring: using bytestring-0.12.0.2
Dependency directory: using directory-1.3.8.1
Dependency filepath: using filepath-1.4.100.4
Dependency hspec-wai: using hspec-wai-0.11.1
Dependency servant: using servant-0.20.1
Dependency servant-blaze: using servant-blaze-0.9.1
Dependency servant-server: using servant-server-0.20
Dependency servant-static-th: using servant-static-th-1.0.0.0
Dependency tasty: using tasty-1.5
Dependency tasty-hspec: using tasty-hspec-1.2.0.4
Dependency tasty-hunit: using tasty-hunit-0.10.1
Dependency wai: using wai-3.2.3
Source component graph:
    component test:servant-static-th-doctest
    component lib
    component test:servant-static-th-test dependency lib
Configured component graph:
    component servant-static-th-1.0.0.0-Gf0JRl0LOlJH7QqAq3egcu-servant-static-th-doctest
        include Glob-0.10.2-5wtbbWWlpvHDlEzR8rhOk5
        include base-4.19.0.0-inplace
        include doctest-0.22.2-GNADHsJpBOCGoZihEw8jdB
    component servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd
        include base-4.19.0.0-inplace
        include blaze-html-0.9.1.2-LU4PdqfluMFAXQJ7C5cUjo
        include bytestring-0.12.0.2-inplace
        include containers-0.6.8-inplace
        include directory-1.3.8.1-inplace
        include filepath-1.4.100.4-inplace
        include http-media-0.8.1.1-Hn47BiyXnjC2UfOtCR8Az8
        include semigroups-0.20-E5GWr2A9lEaLFFYy4Mn0aN
        include servant-0.20.1-7IwaPuLx14D8jflaJ2sbpm
        include servant-blaze-0.9.1-4rCnzax1hMd3RpnLTH5KQ
        include servant-server-0.20-6PU7r2EwFI9KKfieWZzWSD
        include template-haskell-2.21.0.0-inplace
        include text-2.1-inplace
    component servant-static-th-1.0.0.0-6clajfMJDw7BzItuZrU0jc-servant-static-th-test
        include base-4.19.0.0-inplace
        include blaze-html-0.9.1.2-LU4PdqfluMFAXQJ7C5cUjo
        include bytestring-0.12.0.2-inplace
        include directory-1.3.8.1-inplace
        include filepath-1.4.100.4-inplace
        include hspec-wai-0.11.1-7Zw367T24ty8GHLFD0n3Ec
        include servant-0.20.1-7IwaPuLx14D8jflaJ2sbpm
        include servant-blaze-0.9.1-4rCnzax1hMd3RpnLTH5KQ
        include servant-server-0.20-6PU7r2EwFI9KKfieWZzWSD
        include servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd
        include tasty-1.5-5P11eN7UrPQ7gjLMV13jao
        include tasty-hspec-1.2.0.4-5Cc8P1Pfq1BEu4izxYUEno
        include tasty-hunit-0.10.1-JSQDxk9lM8dCFxWFiE71D6
        include wai-3.2.3-1Efsg7fpcjiF2EGPl1cm3G
Linked component graph:
    unit servant-static-th-1.0.0.0-Gf0JRl0LOlJH7QqAq3egcu-servant-static-th-doctest
        include Glob-0.10.2-5wtbbWWlpvHDlEzR8rhOk5
        include base-4.19.0.0-inplace
        include doctest-0.22.2-GNADHsJpBOCGoZihEw8jdB
    unit servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd
        include base-4.19.0.0-inplace
        include blaze-html-0.9.1.2-LU4PdqfluMFAXQJ7C5cUjo
        include bytestring-0.12.0.2-inplace
        include containers-0.6.8-inplace
        include directory-1.3.8.1-inplace
        include filepath-1.4.100.4-inplace
        include http-media-0.8.1.1-Hn47BiyXnjC2UfOtCR8Az8
        include semigroups-0.20-E5GWr2A9lEaLFFYy4Mn0aN
        include servant-0.20.1-7IwaPuLx14D8jflaJ2sbpm
        include servant-blaze-0.9.1-4rCnzax1hMd3RpnLTH5KQ
        include servant-server-0.20-6PU7r2EwFI9KKfieWZzWSD
        include template-haskell-2.21.0.0-inplace
        include text-2.1-inplace
        Servant.Static.TH=servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd:Servant.Static.TH,Servant.Static.TH.Internal=servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd:Servant.Static.TH.Internal,Servant.Static.TH.Internal.Api=servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd:Servant.Static.TH.Internal.Api,Servant.Static.TH.Internal.FileTree=servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd:Servant.Static.TH.Internal.FileTree,Servant.Static.TH.Internal.Mime=servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd:Servant.Static.TH.Internal.Mime,Servant.Static.TH.Internal.Server=servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd:Servant.Static.TH.Internal.Server,Servant.Static.TH.Internal.Util=servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd:Servant.Static.TH.Internal.Util
    unit servant-static-th-1.0.0.0-6clajfMJDw7BzItuZrU0jc-servant-static-th-test
        include base-4.19.0.0-inplace
        include blaze-html-0.9.1.2-LU4PdqfluMFAXQJ7C5cUjo
        include bytestring-0.12.0.2-inplace
        include directory-1.3.8.1-inplace
        include filepath-1.4.100.4-inplace
        include hspec-wai-0.11.1-7Zw367T24ty8GHLFD0n3Ec
        include servant-0.20.1-7IwaPuLx14D8jflaJ2sbpm
        include servant-blaze-0.9.1-4rCnzax1hMd3RpnLTH5KQ
        include servant-server-0.20-6PU7r2EwFI9KKfieWZzWSD
        include servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd
        include tasty-1.5-5P11eN7UrPQ7gjLMV13jao
        include tasty-hspec-1.2.0.4-5Cc8P1Pfq1BEu4izxYUEno
        include tasty-hunit-0.10.1-JSQDxk9lM8dCFxWFiE71D6
        include wai-3.2.3-1Efsg7fpcjiF2EGPl1cm3G
Ready component graph:
    definite servant-static-th-1.0.0.0-Gf0JRl0LOlJH7QqAq3egcu-servant-static-th-doctest
        depends Glob-0.10.2-5wtbbWWlpvHDlEzR8rhOk5
        depends base-4.19.0.0-inplace
        depends doctest-0.22.2-GNADHsJpBOCGoZihEw8jdB
    definite servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd
        depends base-4.19.0.0-inplace
        depends blaze-html-0.9.1.2-LU4PdqfluMFAXQJ7C5cUjo
        depends bytestring-0.12.0.2-inplace
        depends containers-0.6.8-inplace
        depends directory-1.3.8.1-inplace
        depends filepath-1.4.100.4-inplace
        depends http-media-0.8.1.1-Hn47BiyXnjC2UfOtCR8Az8
        depends semigroups-0.20-E5GWr2A9lEaLFFYy4Mn0aN
        depends servant-0.20.1-7IwaPuLx14D8jflaJ2sbpm
        depends servant-blaze-0.9.1-4rCnzax1hMd3RpnLTH5KQ
        depends servant-server-0.20-6PU7r2EwFI9KKfieWZzWSD
        depends template-haskell-2.21.0.0-inplace
        depends text-2.1-inplace
    definite servant-static-th-1.0.0.0-6clajfMJDw7BzItuZrU0jc-servant-static-th-test
        depends base-4.19.0.0-inplace
        depends blaze-html-0.9.1.2-LU4PdqfluMFAXQJ7C5cUjo
        depends bytestring-0.12.0.2-inplace
        depends directory-1.3.8.1-inplace
        depends filepath-1.4.100.4-inplace
        depends hspec-wai-0.11.1-7Zw367T24ty8GHLFD0n3Ec
        depends servant-0.20.1-7IwaPuLx14D8jflaJ2sbpm
        depends servant-blaze-0.9.1-4rCnzax1hMd3RpnLTH5KQ
        depends servant-server-0.20-6PU7r2EwFI9KKfieWZzWSD
        depends servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd
        depends tasty-1.5-5P11eN7UrPQ7gjLMV13jao
        depends tasty-hspec-1.2.0.4-5Cc8P1Pfq1BEu4izxYUEno
        depends tasty-hunit-0.10.1-JSQDxk9lM8dCFxWFiE71D6
        depends wai-3.2.3-1Efsg7fpcjiF2EGPl1cm3G
Using Cabal-3.10.2.0 compiled by ghc-9.8
Using compiler: ghc-9.8.1
Using install prefix:
/nix/store/xhh4a5nfj269k1kkx56aiadbkg39hrc3-servant-static-th-1.0.0.0
Executables installed in:
/nix/store/xhh4a5nfj269k1kkx56aiadbkg39hrc3-servant-static-th-1.0.0.0/bin
Libraries installed in:
/nix/store/xhh4a5nfj269k1kkx56aiadbkg39hrc3-servant-static-th-1.0.0.0/lib/ghc-9.8.1/lib/x86_64-linux-ghc-9.8.1/servant-static-th-1.0.0.0-Eu8KZKOVrVf6OdBLsTDzsd
Dynamic Libraries installed in:
/nix/store/xhh4a5nfj269k1kkx56aiadbkg39hrc3-servant-static-th-1.0.0.0/lib/ghc-9.8.1/lib/x86_64-linux-ghc-9.8.1
Private executables installed in:
/nix/store/xhh4a5nfj269k1kkx56aiadbkg39hrc3-servant-static-th-1.0.0.0/libexec/x86_64-linux-ghc-9.8.1/servant-static-th-1.0.0.0
Data files installed in:
/nix/store/xhh4a5nfj269k1kkx56aiadbkg39hrc3-servant-static-th-1.0.0.0/share/x86_64-linux-ghc-9.8.1/servant-static-th-1.0.0.0
Documentation installed in:
/nix/store/myhdis6jc84d8b8zzy4scj1llcc3amfv-servant-static-th-1.0.0.0-doc/share/doc/servant-static-th-1.0.0.0
Configuration files installed in:
/nix/store/xhh4a5nfj269k1kkx56aiadbkg39hrc3-servant-static-th-1.0.0.0/etc
No alex found
Using ar found on system at:
/nix/store/1fn92b0783crypjcxvdv6ycmvi27by0j-binutils-2.40/bin/ar
No c2hs found
No cpphs found
Using doctest version 0.22.2 found on system at:
/nix/store/b1jvz9i6yl2gb87xwjrnlsr96j7nf2rj-doctest-0.22.2/bin/doctest
Using gcc version 12.3.0 given by user at:
/nix/store/90h6k8ylkgn81k10190v5c9ldyjpzgl9-gcc-wrapper-12.3.0/bin/gcc
Using ghc version 9.8.1 found on system at:
/nix/store/qs0m6r89s0sm5i0bij8c4khy0sk656ml-ghc-9.8.1/bin/ghc
Using ghc-pkg version 9.8.1 found on system at:
/nix/store/qs0m6r89s0sm5i0bij8c4khy0sk656ml-ghc-9.8.1/bin/ghc-pkg-9.8.1
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.30.0 found on system at:
/nix/store/qs0m6r89s0sm5i0bij8c4khy0sk656ml-ghc-9.8.1/bin/haddock-ghc-9.8.1
No happy found
Using haskell-suite found on system at: haskell-suite-dummy-location
Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location
No hmake found
Using hpc version 0.69 found on system at:
/nix/store/qs0m6r89s0sm5i0bij8c4khy0sk656ml-ghc-9.8.1/bin/hpc-ghc-9.8.1
Using hsc2hs version 0.68.10 found on system at:
/nix/store/qs0m6r89s0sm5i0bij8c4khy0sk656ml-ghc-9.8.1/bin/hsc2hs-ghc-9.8.1
Using hscolour version 1.24 found on system at:
/nix/store/icy67iqfm3k226224210fs901hq7m6v7-hscolour-1.24.4/bin/HsColour
No jhc found
Using ld found on system at:
/nix/store/1alqjnr40dsk7cl15l5sn5y2zdxidc1v-binutils-wrapper-2.40/bin/ld.gold
No pkg-config found
Using runghc version 9.8.1 found on system at:
/nix/store/qs0m6r89s0sm5i0bij8c4khy0sk656ml-ghc-9.8.1/bin/runghc-9.8.1
Using strip version 2.40 found on system at:
/nix/store/90h6k8ylkgn81k10190v5c9ldyjpzgl9-gcc-wrapper-12.3.0/bin/strip
Using tar found on system at:
/nix/store/xpidksbd07in3nd4sjx79ybwwy81b338-gnutar-1.35/bin/tar
No uhc found
@nix { "action": "setPhase", "phase": "buildPhase" }
building
Preprocessing test suite 'servant-static-th-doctest' for servant-static-th-1.0.0.0..
Building test suite 'servant-static-th-doctest' for servant-static-th-1.0.0.0..
[1 of 1] Compiling Main             ( test/DocTest.hs, dist/build/servant-static-th-doctest/servant-static-th-doctest-tmp/Main.o )

test/DocTest.hs:6:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
  |
6 | import Data.Monoid ((<>))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
[2 of 2] Linking dist/build/servant-static-th-doctest/servant-static-th-doctest
Preprocessing library for servant-static-th-1.0.0.0..
Building library for servant-static-th-1.0.0.0..
[1 of 7] Compiling Servant.Static.TH.Internal.FileTree ( src/Servant/Static/TH/Internal/FileTree.hs, dist/build/Servant/Static/TH/Internal/FileTree.o, dist/build/Servant/Static/TH/Internal/FileTree.dyn_o )

src/Servant/Static/TH/Internal/FileTree.hs:21:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
   |
21 | import Data.Monoid ((<>))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^
[2 of 7] Compiling Servant.Static.TH.Internal.Util ( src/Servant/Static/TH/Internal/Util.hs, dist/build/Servant/Static/TH/Internal/Util.o, dist/build/Servant/Static/TH/Internal/Util.dyn_o )
[3 of 7] Compiling Servant.Static.TH.Internal.Mime ( src/Servant/Static/TH/Internal/Mime.hs, dist/build/Servant/Static/TH/Internal/Mime.o, dist/build/Servant/Static/TH/Internal/Mime.dyn_o )

src/Servant/Static/TH/Internal/Mime.hs:30:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
   |
30 | import Data.Monoid ((<>))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Mime.hs:79:7: warning: [GHC-55524] [-Wmonomorphism-restriction]
    • The Monomorphism Restriction applies to the binding
      for ‘stringExp’
    • In the expression:
        let
          stringExp
            = stringE . unpack $ decodeUtf8With lenientDecode byteString
          packedExp = appE (varE 'pack) stringExp
          byteStringExp = appE (varE 'encodeUtf8) packedExp
        in appE (varE 'pure) byteStringExp
      In an equation for ‘utf8ByteStringToExp’:
          utf8ByteStringToExp byteString
            = let
                stringExp
                  = stringE . unpack $ decodeUtf8With lenientDecode byteString
                packedExp = appE (varE ...) stringExp
                ....
              in appE (varE 'pure) byteStringExp
    Suggested fix: Consider giving ‘stringExp’ a type signature
   |
79 |   let stringExp = stringE . unpack $ decodeUtf8With lenientDecode byteString
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[4 of 7] Compiling Servant.Static.TH.Internal.Server ( src/Servant/Static/TH/Internal/Server.hs, dist/build/Servant/Static/TH/Internal/Server.o, dist/build/Servant/Static/TH/Internal/Server.dyn_o )

src/Servant/Static/TH/Internal/Server.hs:7:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Foldable’ is redundant
      except perhaps to import instances from ‘Data.Foldable’
    To import instances alone, use: import Data.Foldable()
  |
7 | import Data.Foldable (foldl1)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Server.hs:8:1: warning: [GHC-38856] [-Wunused-imports]
    The import of ‘:|’ from module ‘Data.List.NonEmpty’ is redundant
  |
8 | import Data.List.NonEmpty (NonEmpty((:|)))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Server.hs:129:7: warning: [GHC-55524] [-Wmonomorphism-restriction]
    • The Monomorphism Restriction applies to the binding
      for ‘sigTypeQ’
    • In the expression:
        let
          funcName = mkName serverName
          sigTypeQ
            = [t| forall m.
                  Applicative m => ServerT $(conT (mkName apiName)) m |]
              pending(rn) [<spn, conT (mkName apiName)>]
          signatureQ = sigD funcName sigTypeQ
          ....
        in sequence [signatureQ, funcQ]
      In an equation for ‘createServerDec’:
          createServerDec apiName serverName templateDir
            = let
                funcName = mkName serverName
                sigTypeQ = ...
                ....
              in sequence [signatureQ, funcQ]
    Suggested fix: Consider giving ‘sigTypeQ’ a type signature
    |
129 |       sigTypeQ =
    |       ^^^^^^^^^^...
[5 of 7] Compiling Servant.Static.TH.Internal.Api ( src/Servant/Static/TH/Internal/Api.hs, dist/build/Servant/Static/TH/Internal/Api.o, dist/build/Servant/Static/TH/Internal/Api.dyn_o )

src/Servant/Static/TH/Internal/Api.hs:8:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Foldable’ is redundant
      except perhaps to import instances from ‘Data.Foldable’
    To import instances alone, use: import Data.Foldable()
  |
8 | import Data.Foldable (foldl1)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Api.hs:25:7: warning: [GHC-55524] [-Wmonomorphism-restriction]
    • The Monomorphism Restriction applies to the binding
      for ‘fileNameLitT’
    • In the expression:
        do addDependentFile filePath
           MimeTypeInfo mimeT respT _ <- extensionToMimeTypeInfoEx filePath
           let fileName = takeFileName filePath
           let fileNameLitT = litT $ strTyLit fileName
           ....
      In an equation for ‘fileTreeToApiType’:
          fileTreeToApiType (FileTreeFile filePath _)
            = do addDependentFile filePath
                 MimeTypeInfo mimeT respT _ <- extensionToMimeTypeInfoEx filePath
                 let fileName = ...
                 ....
    Suggested fix: Consider giving ‘fileNameLitT’ a type signature
   |
25 |   let fileNameLitT = litT $ strTyLit fileName
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Api.hs:32:7: warning: [GHC-55524] [-Wmonomorphism-restriction]
    • The Monomorphism Restriction applies to the binding
      for ‘fileNameLitT’
    • In the expression:
        let fileNameLitT = litT $ strTyLit $ takeFileName filePath
        in
          [t| $(fileNameLitT)
              :> $(combineWithServantOrT nonEmptyApiTypesQ) |]
          pending(rn) [<spn, combineWithServantOrT nonEmptyApiTypesQ>,
                       <spn, fileNameLitT>]
      In an equation for ‘fileTreeToApiType’:
          fileTreeToApiType (FileTreeDir filePath fileTrees)
            = let fileNameLitT = litT $ strTyLit $ takeFileName filePath
              in
                [t| $(fileNameLitT)
                    :> $(combineWithServantOrT nonEmptyApiTypesQ) |]
                pending(rn) [<spn, combineWithServantOrT nonEmptyApiTypesQ>,
                             <spn, fileNameLitT>]
            where
                nonEmptyApiTypesQ :: NonEmpty (Q Type)
                nonEmptyApiTypesQ = fmap fileTreeToApiType fileTrees
    Suggested fix: Consider giving ‘fileNameLitT’ a type signature
   |
32 |   let fileNameLitT = litT $ strTyLit $ takeFileName filePath
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[6 of 7] Compiling Servant.Static.TH.Internal ( src/Servant/Static/TH/Internal.hs, dist/build/Servant/Static/TH/Internal.o, dist/build/Servant/Static/TH/Internal.dyn_o )
[7 of 7] Compiling Servant.Static.TH ( src/Servant/Static/TH.hs, dist/build/Servant/Static/TH.o, dist/build/Servant/Static/TH.dyn_o )
[1 of 7] Compiling Servant.Static.TH.Internal.FileTree ( src/Servant/Static/TH/Internal/FileTree.hs, dist/build/Servant/Static/TH/Internal/FileTree.p_o )

src/Servant/Static/TH/Internal/FileTree.hs:21:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
   |
21 | import Data.Monoid ((<>))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^
[2 of 7] Compiling Servant.Static.TH.Internal.Util ( src/Servant/Static/TH/Internal/Util.hs, dist/build/Servant/Static/TH/Internal/Util.p_o )
[3 of 7] Compiling Servant.Static.TH.Internal.Mime ( src/Servant/Static/TH/Internal/Mime.hs, dist/build/Servant/Static/TH/Internal/Mime.p_o )

src/Servant/Static/TH/Internal/Mime.hs:30:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
   |
30 | import Data.Monoid ((<>))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Mime.hs:79:7: warning: [GHC-55524] [-Wmonomorphism-restriction]
    • The Monomorphism Restriction applies to the binding
      for ‘stringExp’
    • In the expression:
        let
          stringExp
            = stringE . unpack $ decodeUtf8With lenientDecode byteString
          packedExp = appE (varE 'pack) stringExp
          byteStringExp = appE (varE 'encodeUtf8) packedExp
        in appE (varE 'pure) byteStringExp
      In an equation for ‘utf8ByteStringToExp’:
          utf8ByteStringToExp byteString
            = let
                stringExp
                  = stringE . unpack $ decodeUtf8With lenientDecode byteString
                packedExp = appE (varE ...) stringExp
                ....
              in appE (varE 'pure) byteStringExp
    Suggested fix: Consider giving ‘stringExp’ a type signature
   |
79 |   let stringExp = stringE . unpack $ decodeUtf8With lenientDecode byteString
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[4 of 7] Compiling Servant.Static.TH.Internal.Server ( src/Servant/Static/TH/Internal/Server.hs, dist/build/Servant/Static/TH/Internal/Server.p_o )

src/Servant/Static/TH/Internal/Server.hs:7:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Foldable’ is redundant
      except perhaps to import instances from ‘Data.Foldable’
    To import instances alone, use: import Data.Foldable()
  |
7 | import Data.Foldable (foldl1)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Server.hs:8:1: warning: [GHC-38856] [-Wunused-imports]
    The import of ‘:|’ from module ‘Data.List.NonEmpty’ is redundant
  |
8 | import Data.List.NonEmpty (NonEmpty((:|)))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Server.hs:129:7: warning: [GHC-55524] [-Wmonomorphism-restriction]
    • The Monomorphism Restriction applies to the binding
      for ‘sigTypeQ’
    • In the expression:
        let
          funcName = mkName serverName
          sigTypeQ
            = [t| forall m.
                  Applicative m => ServerT $(conT (mkName apiName)) m |]
              pending(rn) [<spn, conT (mkName apiName)>]
          signatureQ = sigD funcName sigTypeQ
          ....
        in sequence [signatureQ, funcQ]
      In an equation for ‘createServerDec’:
          createServerDec apiName serverName templateDir
            = let
                funcName = mkName serverName
                sigTypeQ = ...
                ....
              in sequence [signatureQ, funcQ]
    Suggested fix: Consider giving ‘sigTypeQ’ a type signature
    |
129 |       sigTypeQ =
    |       ^^^^^^^^^^...
[5 of 7] Compiling Servant.Static.TH.Internal.Api ( src/Servant/Static/TH/Internal/Api.hs, dist/build/Servant/Static/TH/Internal/Api.p_o )

src/Servant/Static/TH/Internal/Api.hs:8:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.Foldable’ is redundant
      except perhaps to import instances from ‘Data.Foldable’
    To import instances alone, use: import Data.Foldable()
  |
8 | import Data.Foldable (foldl1)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Api.hs:25:7: warning: [GHC-55524] [-Wmonomorphism-restriction]
    • The Monomorphism Restriction applies to the binding
      for ‘fileNameLitT’
    • In the expression:
        do addDependentFile filePath
           MimeTypeInfo mimeT respT _ <- extensionToMimeTypeInfoEx filePath
           let fileName = takeFileName filePath
           let fileNameLitT = litT $ strTyLit fileName
           ....
      In an equation for ‘fileTreeToApiType’:
          fileTreeToApiType (FileTreeFile filePath _)
            = do addDependentFile filePath
                 MimeTypeInfo mimeT respT _ <- extensionToMimeTypeInfoEx filePath
                 let fileName = ...
                 ....
    Suggested fix: Consider giving ‘fileNameLitT’ a type signature
   |
25 |   let fileNameLitT = litT $ strTyLit fileName
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Servant/Static/TH/Internal/Api.hs:32:7: warning: [GHC-55524] [-Wmonomorphism-restriction]
    • The Monomorphism Restriction applies to the binding
      for ‘fileNameLitT’
    • In the expression:
        let fileNameLitT = litT $ strTyLit $ takeFileName filePath
        in
          [t| $(fileNameLitT)
              :> $(combineWithServantOrT nonEmptyApiTypesQ) |]
          pending(rn) [<spn, combineWithServantOrT nonEmptyApiTypesQ>,
                       <spn, fileNameLitT>]
      In an equation for ‘fileTreeToApiType’:
          fileTreeToApiType (FileTreeDir filePath fileTrees)
            = let fileNameLitT = litT $ strTyLit $ takeFileName filePath
              in
                [t| $(fileNameLitT)
                    :> $(combineWithServantOrT nonEmptyApiTypesQ) |]
                pending(rn) [<spn, combineWithServantOrT nonEmptyApiTypesQ>,
                             <spn, fileNameLitT>]
            where
                nonEmptyApiTypesQ :: NonEmpty (Q Type)
                nonEmptyApiTypesQ = fmap fileTreeToApiType fileTrees
    Suggested fix: Consider giving ‘fileNameLitT’ a type signature
   |
32 |   let fileNameLitT = litT $ strTyLit $ takeFileName filePath
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[6 of 7] Compiling Servant.Static.TH.Internal ( src/Servant/Static/TH/Internal.hs, dist/build/Servant/Static/TH/Internal.p_o )
[7 of 7] Compiling Servant.Static.TH ( src/Servant/Static/TH.hs, dist/build/Servant/Static/TH.p_o )
Preprocessing test suite 'servant-static-th-test' for servant-static-th-1.0.0.0..
Building test suite 'servant-static-th-test' for servant-static-th-1.0.0.0..
[1 of 6] Compiling Spec.TastyHelpers ( test/Spec/TastyHelpers.hs, dist/build/servant-static-th-test/servant-static-th-test-tmp/Spec/TastyHelpers.o )
[2 of 6] Compiling Spec.TestDirLocation ( test/Spec/TestDirLocation.hs, dist/build/servant-static-th-test/servant-static-th-test-tmp/Spec/TestDirLocation.o, dist/build/servant-static-th-test/servant-static-th-test-tmp/Spec/TestDirLocation.dyn_o )
[3 of 6] Compiling Spec.ServerSpec  ( test/Spec/ServerSpec.hs, dist/build/servant-static-th-test/servant-static-th-test-tmp/Spec/ServerSpec.o )

test/Spec/ServerSpec.hs:15:36: error: [GHC-61689]
    Module ‘Test.Tasty.Hspec’ does not export ‘it’.
   |
15 | import Test.Tasty.Hspec (testSpec, it)
   |                                    ^^
[4 of 6] Compiling Spec.HelperFuncSpec ( test/Spec/HelperFuncSpec.hs, dist/build/servant-static-th-test/servant-static-th-test-tmp/Spec/HelperFuncSpec.o )
[5 of 6] Compiling Spec.ApiSpec     ( test/Spec/ApiSpec.hs, dist/build/servant-static-th-test/servant-static-th-test-tmp/Spec/ApiSpec.o )

test/Spec/ApiSpec.hs:36:24: error: [GHC-83865]
    • Couldn't match type: ("dir"
                            :> (("inner-file.html" :> Get '[HTML] Html)
                                :<|> ("test.js" :> Get '[JS] ByteString)))
                           :<|> ("hello.html" :> Get '[HTML] Html)
                     with: "dir"
                           :> (("inner-file.html" :> Get '[HTML] Html)
                               :<|> ("test.js" :> Get '[JS] ByteString))
      Expected: ExpectedFrontEndApi :~: FrontEndApi
        Actual: ExpectedFrontEndApi :~: ExpectedFrontEndApi
    • In the expression: Refl
      In an equation for ‘checkFrontEndApiType’:
          checkFrontEndApiType = Refl
   |
36 | checkFrontEndApiType = Refl
   |                        ^^^^

test/Spec/ApiSpec.hs:40:59: error: [GHC-83865]
    • Couldn't match type: ("dir"
                            :> (("inner-file.html" :> Get '[HTML] Html)
                                :<|> ("test.js" :> Get '[JS] ByteString)))
                           :<|> ("hello.html" :> Get '[HTML] Html)
                     with: "dir"
                           :> (("inner-file.html" :> Get '[HTML] Html)
                               :<|> ("test.js" :> Get '[JS] ByteString))
      Expected: ExpectedFrontEndApi :~: FrontEndApi
        Actual: ExpectedFrontEndApi :~: ExpectedFrontEndApi
    • In the second argument of ‘(@?=)’, namely ‘Refl’
      In the second argument of ‘($)’, namely
        ‘checkFrontEndApiType @?= Refl’
      In the expression:
        testCase "created correctly" $ checkFrontEndApiType @?= Refl
   |
40 |   testCase "created correctly" $ checkFrontEndApiType @?= Refl
   |                                                           ^^^^

Long compile time on 100K~ bytes static files

It takes long compile time when one of the front-end files becomes to be around 100K bytes.
A 100K bytes js files are likely such as one it imports babel-polyfill.

After installing dependent libraries,
stack build --flag servant-static-th:buildexample takes

It must be a sort of bottleneck to let people to use this fantastic servant-static-th in real world applications.

Files that has to be ignored and not served

Hello,
I have static files (.sass) that do not need to be served but ignored by the extensionToMimeTypeInfoEx function
Right now, it fails with "unknown extension type"
Do you have a plan for such issue already ?
Thanks for your reply.
Alexandre

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.