sealcode / sealious

An extensible, declarative node framework
25 stars 2 forks source link

Strange errors when running a regular app #302

Closed adwydman closed 6 years ago

adwydman commented 7 years ago

I try to run FKA bookshop app, here are REST routes:

new Sealious.Collection({
    name: "books",
    fields: [
        {name: "author", type: "text", required: true},
        {name: "title", type: "text", required: true},
        {name: "year", type: "int", required: true},
        {name: "book", type: "file", required: false}
    ]
});

//Codes generation
www_server.route({
    method: "POST",
    path: "/api/v1/codes",
    handler: codePost
});

//Get particular code -- it returns
www_server.route({
    method: "GET",
    path: "/api/v1/codes/{code}",
    handler: codeGet
});

//Get all codes
www_server.route({
    method: "GET",
    path: "/api/v1/codes",
    handler: codesGet
});

www_server.route({
    method: "DELETE",
    path: "/api/v1/codes/{code}",
    handler: codeDelete
});

When I try to GET api/v1/books:

{
  "message": "No child subject with key 'books' in RootSubject",
  "type": "bad_subject",
  "data": {}
}

When I try to GET api/v1/codes I get status code 500 and error:

23:22:26.206 - error:  TypeError: Cannot read property 'SealiousSession' of undefined
    at Chip.www_server.get_context (/home/adrian/Documents/fka-bookshop/node_modules/sealious-channel-rest/node_modules/sealious-www-server/define/channel.www_server.js:111:32)
    at /home/adrian/Documents/fka-bookshop/app/codesGet.js:3:36
    at /home/adrian/Documents/fka-bookshop/node_modules/sealious-channel-rest/node_modules/sealious-www-server/define/channel.www_server.js:126:10
    at bound (domain.js:280:14)
    at runBound (domain.js:293:12)
    at tryCatcher (/home/adrian/Documents/fka-bookshop/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/adrian/Documents/fka-bookshop/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/home/adrian/Documents/fka-bookshop/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/home/adrian/Documents/fka-bookshop/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/home/adrian/Documents/fka-bookshop/node_modules/bluebird/js/release/promise.js:691:18)
    at Async._drainQueue (/home/adrian/Documents/fka-bookshop/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/home/adrian/Documents/fka-bookshop/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues (/home/adrian/Documents/fka-bookshop/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:637:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5)
arkadiusz-wieczorek commented 7 years ago

Which version of sealious are you using?

If you are using alpha - you should GET /api/v1/collections/books, GET /api/v1/collections/codes, etc. :)

adwydman commented 7 years ago

FML... ok, thanks...

adwydman commented 7 years ago

Okay, the problem is solved for books, but it persists for codes, even when I changed the route. The error is still the same.

arkadiusz-wieczorek commented 7 years ago

Yes, because codes isn't a collection. I think that you have to check declaration www_server.route in currently version of sealious-www-server. Unfortunately sealious-www-server requires rewrite. Probably path: "/api/v1/codes" is overlooked in declaration process.

arkadiusz-wieczorek commented 7 years ago

Why you didn't use collection structure for codes?

adwydman commented 7 years ago

Because their behaviour is not typical and it required a custom handler.

arkadiusz-wieczorek commented 7 years ago

Do you have this declaration in main.js: www_server = Sealious.ChipManager.get_chip("channel", "www_server");?

The problem is connected with this line from sealious-www-server: www_server.kill_session(request.state.SealiousSession);, I bet that the problem lies in your handler.

kuba-orlik commented 7 years ago

As we talked afk today, please use Collections for codes. Disable the default create route with an access strategy (create: "noone") and create a custom route only for creating the codes. Cheers!

kuba-orlik commented 6 years ago

Issues moved do Sealcode's phabricator: https://hub.sealcode.org/project/view/11/