Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running bookshelf - Not a aclass #10

Open
artmunro opened this issue Feb 2, 2017 · 3 comments
Open

Error running bookshelf - Not a aclass #10

artmunro opened this issue Feb 2, 2017 · 3 comments

Comments

@artmunro
Copy link

artmunro commented Feb 2, 2017

Trying to get baseline working with Bookshelf after install got error...

trail pack Bookshelf validationError: migrate is not allowed. defaultStore is not allowed

Then added the user, and profile from example .. After npm start get ...

throw new Error(${resourceName} should be a class. It is a regular object)
^

Error: User should be a class. It is a regular object
at _.mapValues (...S\trails_ems2\node_modules\trails\lib\core.js:60:15)

Package versions ..
"dependencies": {
"express": "^5.0.0-alpha.2",
"trailpack-bookshelf": "^1.0.0-alpha-1",
"trailpack-express": "^2.0.0-rc3",
"trailpack-repl": "v2-latest",
"trailpack-router": "v2-latest",
"trails": "v2-latest",
"winston": "^2.3"
},

XXXXXX node version ...

{
"app": "0.0.0",
"node": "v6.2.1",
"libs": {
"http_parser": "2.7.0",
"node": "6.2.1",
"v8": "5.0.71.52",
"uv": "1.9.1",
"zlib": "1.2.8",
"ares": "1.10.1-DEV",
"icu": "57.1",
"modules": "48",
"openssl": "1.0.2h"
},
"trailpacks": [
{
"name": "repl",
"version": "2.1.0"
},
{
"name": "router",
"version": "2.1.0"
},
{
"name": "express",
"version": "2.0.0-rc3"
}
]
}

@tjwebb
Copy link
Member

tjwebb commented Feb 16, 2017

@zuker any thoughts?

@zuker
Copy link
Contributor

zuker commented Mar 1, 2017

@artmunro the source of an error is here: https://github.com/trailsjs/trails/blob/f54ec3933663b72e32cab26bbe13b1a4e5e97e3a/index.js#L146
This lines try to bind resource methods from app's api and check if all of them are exported as classes. I think problem is in the trailpack-bookshelf readme example service, it is outdated, service there is declared as object, but should be exported as class, like this:

'use strict'

const Service = require('trails/service')

/**
 * @module UserService
 * @description TODO document Service
 */
module.exports = class UserService extends Service {
 /**
   * Fetches user with profile by id.
   * @return Promise
   * @example {
   *    name: 'jdoe',
   *    proflie: {
   *      first_name: 'John',
   *      last_name: 'Doe'
   *    }
   * }
   */
  fetchUserWithProfile(id) {
    return this.orm.User.forge({ id: id }).fetch({ withRelated: 'profile' });
  }
}

so if you copypasted service from the example - app will not start. Also please check all of your app models, services, controllers and policies - all of them should export classes.
Sorry for outdated example, i should update it.

@analogrithems
Copy link

I'm getting a similar error and all of my models, services, controllers and policies are exporting classes

wage-slave:radio analog$ npm start

> [email protected] start /Users/analog/Dropbox/Projects/analogradio
> node server.js

(node:82438) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
error: 
 ValidationError: "migrate" is not allowed. "defaultStore" is not allowed
    at Object.exports.process (/Users/analog/Dropbox/Projects/analogradio/node_modules/trailpack-bookshelf/node_modules/joi/lib/errors.js:152:19)
    at internals.Object.internals.Any._validateWithOptions (/Users/analog/Dropbox/Projects/analogradio/node_modules/trailpack-bookshelf/node_modules/joi/lib/any.js:633:27)
    at root.validate (/Users/analog/Dropbox/Projects/analogradio/node_modules/trailpack-bookshelf/node_modules/joi/lib/index.js:104:23)
    at cb (/Users/analog/Dropbox/Projects/analogradio/node_modules/trailpack-bookshelf/dist/index.js:86:68)
    at tryCatcher (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/util.js:16:23)
    at Promise.fromNode.Promise.fromCallback (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/promise.js:180:30)
    at resolve.then (/Users/analog/Dropbox/Projects/analogradio/node_modules/trailpack-bookshelf/dist/index.js:86:49)
    at tryCatcher (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromiseCtx (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/Users/analog/Dropbox/Projects/analogradio/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)
error: The application did not boot successfully.
error: Try increasing the loglevel to "debug" to learn more
info: Shutting down...
(node:82438) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'removeAllListeners' of undefined
(node:82438) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants