If I have all code in a single file:
    
    
    import jester, json
    
    routes:
      get "/":
        var jsonResp = $(%*{"id": 2})
        resp Http200, jsonResp
    
    
    Run

This works well without any problem.

Now if I split this into two files:

main.nim
    
    
    import jester
    import api
    
    routes:
      extend apiv1, "/api/v1"
    
    
    Run

api.nim (in the same folder)
    
    
    import jester, json
    
    router apiv1:
      get "/":
        var jsonResp = %*{"id": 2}
        echo jsonResp
        resp Http200, "hello"
    
    
    Run

Then I get these errors:
    
    
    jester.nim(1277, 9) Hint: Asynchronous route: apiv1. [User]
    jester.nim(797, 9) Hint: 'settings' is declared but not used 
[XDeclaredButNotUsed]
    jester.nim(1307, 26) Hint: 'apiv1ErrorHandler' is declared but not used 
[XDeclaredButNotUsed]
    jester.nim(1280, 7) Hint: 'apiv1' is declared but not used 
[XDeclaredButNotUsed]
    jester.nim(1277, 9) Hint: Asynchronous route: match. [User]
    jester.nim(1283, 35) template/generic instantiation of `async` from here
    /server/src/api.nim(5, 20) Error: undeclared identifier: '%*'
    
    
    Run

I think it is a problem with creating json nodes. Can't understand how to 
resolve this.

Thanks for your help.

Reply via email to