typicode / json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)
Other
72.87k stars 7.02k forks source link

500 internal server error #667

Open bdbais opened 7 years ago

bdbais commented 7 years ago

I'm trying to create a rest api fake server of an online service and I have some difficult to create routes / entries:

I'm trying to POST http://localhost:3000/meta this payload:

{  "data": {
    "transforms": {
      "workers": {
        "person": {
          "communication": {
            "readonly": false,
            "optional": true,
            "email": {
              "readonly": false,
              "optional": true,
              "emailUri": {
                "readonly": false,
                "optional": true,
                "hidden": false,
                "shortLabelName": "Personal Email",
                "minLenght": 0,
                "maxLenght": 256
       }}}}}}}}

On console I can see:

::1 - - [19/Oct/2017:12:42:30 +0000] "POST /meta HTTP/1.1" 500 4423 "-" "-" TypeError: this.database[collection].push is not a function at Somewhere.save (/usr/local/lib/node_modules/jsonserver/node_modules/somewhere/lib/somewhere.coffee:25:27) at /usr/local/lib/node_modules/jsonserver/lib/jsonserver.coffee:43:18 at Layer.handle [as handle_request] (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/layer.js:95:5) at next (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/layer.js:95:5) at /usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:281:22 at param (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:354:14) at param (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:365:14) at Function.process_params (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:410:3) at next (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:275:10) at /usr/local/lib/node_modules/jsonserver/lib/jsonserver.coffee:29:8 at Layer.handle [as handle_request] (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:317:13) at /usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:335:12) at next (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:275:10) at logger (/usr/local/lib/node_modules/jsonserver/node_modules/morgan/index.js:144:5) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:317:13) at /usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:335:12) at next (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:275:10) at multipart (/usr/local/lib/node_modules/jsonserver/node_modules/connect-multiparty/index.js:42:27) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:317:13) at /usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:335:12) at next (/usr/local/lib/node_modules/jsonserver/node_modules/express/lib/router/index.js:275:10) at /usr/local/lib/node_modules/jsonserver/node_modules/body-parser/lib/read.js:130:5 at invokeCallback (/usr/local/lib/node_modules/jsonserver/node_modules/raw-body/index.js:224:16) at done (/usr/local/lib/node_modules/jsonserver/node_modules/raw-body/index.js:213:7) at IncomingMessage.onEnd (/usr/local/lib/node_modules/jsonserver/node_modules/raw-body/index.js:273:7) at emitNone (events.js:105:13) at IncomingMessage.emit (events.js:207:7) at endReadableNT (_stream_readable.js:1059:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)

naveennvrgup commented 6 years ago

dang it