trailsjs / trailpack-footprints

:package: Footprints Trailpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prefix ignored with waterline

jdell64 opened this issue · comments

I created a config\web.js file manually (this broke in beta-1 of trails) and added exports.web = require('./web') to config\index.js (again, bug in trails).

GET http://localhost:3000/api/v1/default/info works just fine (see below).
GET http://localhost:3000/api/v1/user gives this response:

# http response:
{
  "statusCode": 500,
  "error": "Internal Server Error",
  "message": "An internal server error occurred"
}

#console response:
debug: [FootprintController] (findAssociation) api v1 -> user undefined , criteria =
Debug: internal, implementation, error 
    TypeError: Uncaught error: Cannot read property 'attributes' of undefined
    at FootprintService.findAssociation (/home/jeff/dev/trails/sample_app/node_modules/trailpack-waterline/api/services/FootprintService.js:165:39)
    at FootprintController.findAssociation (/home/jeff/dev/trails/sample_app/node_modules/trailpack-hapi/api/controllers/FootprintController.js:139:30)
    at Object.exports.execute.internals.prerequisites.internals.handler.callback [as handler] (/home/jeff/dev/trails/sample_app/node_modules/hapi/lib/handler.js:96:36)
    at /home/jeff/dev/trails/sample_app/node_modules/hapi/lib/handler.js:63:26
    at done (/home/jeff/dev/trails/sample_app/node_modules/hapi/node_modules/items/lib/index.js:31:25)
    at done (/home/jeff/dev/trails/sample_app/node_modules/hapi/node_modules/items/lib/index.js:63:25)
    at /home/jeff/dev/trails/sample_app/node_modules/hapi/lib/handler.js:49:28
    at finalize (/home/jeff/dev/trails/sample_app/node_modules/hapi/lib/handler.js:281:20)
    at wrapped (/home/jeff/dev/trails/sample_app/node_modules/hapi/node_modules/hoek/lib/index.js:867:20)
    at internals.Response._prepare.internals.Response._processPrepare.next [as _processPrepare] (/home/jeff/dev/trails/sample_app/node_modules/hapi/lib/response.js:448:16)
    at internals.Response._prepare.next [as _prepare] (/home/jeff/dev/trails/sample_app/node_modules/hapi/lib/response.js:387:21)
    at /home/jeff/dev/trails/sample_app/node_modules/hapi/lib/reply.js:151:22
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

It seems to be trying to get an api v1 model. In the FootprintService.js

const parentModel = this.app.orm[parentModelName] || this.app.packs.waterline.orm.collections[parentModelName]

parentModelName has the value of 'api' not user

If I make a request to

GET http://localhost:3000/user
it seems to work.

I think the footprints prefix is being ignored here.

Here is my setup:


{
  "app": "0.0.0",
  "node": "v5.10.1",
  "libs": {
    "http_parser": "2.6.2",
    "node": "5.10.1",
    "v8": "4.6.85.31",
    "uv": "1.8.0",
    "zlib": "1.2.8",
    "ares": "1.10.1-DEV",
    "modules": "47",
    "openssl": "1.0.2g"
  },
  "trailpacks": [
    {
      "name": "core",
      "version": "1.0.0-beta-6"
    },
    {
      "name": "repl",
      "version": "1.0.0-beta-4"
    },
    {
      "name": "router",
      "version": "1.0.0-beta-4"
    },
    {
      "name": "hapi",
      "version": "1.0.0-beta-3"
    },
    {
      "name": "waterline",
      "version": "1.0.0-alpha-6"
    },
    {
      "name": "footprints",
      "version": "1.0.0-beta-6"
    }
  ]
}

@jdell64 does this work now ?

Closing this as it should work now :) let me know if you still have the problem