The following is an extract from my server.js script:
constHapi=require('hapi');constserver=newHapi.Server();constSequelize=require('sequelize');/* Register all required plugins */server.register([{{...allotherpluginsinhere...},{register:require('hapi-sequelize'),options:[{name:'agrade',models:['./api/models/seq/*.js'],sequelize:newSequelize('a-grade','root','',{host:'localhost',port:3306,dialect:'mysql'})}]}],(err)=>{if(err){console.log('ERROR:',err);};letdb=server.plugins['hapi-sequelize'].agrade;letmodels=db.sequelize.models;//associations(models);
server.register({register:require('hapi-sequelize-crud'),options:{prefix:'/api/seq'}});varroutes=require(appDir+process.env.PATH_API+process.env.PATH_ROUTES);server.route(routes);server.start(()=>{logger.log('info',`SERVER - server STARTED`);});});
I'm not sure where to register the hapi-sequelize-crud plugin.
When it is as the code above, the server starts up without errors, but none of my routes work (not routes generated by hapi-sequelize-crud, or manually created routes).
When I add it immediately after the hapi-sequelize registration, I get the following error: "Cannot read property 'sequelize' of undefined" or server startup.
The following is an extract from my `server.js` script:
``` javascript
const Hapi = require('hapi');
const server = new Hapi.Server();
const Sequelize = require('sequelize');
/* Register all required plugins */
server.register([{
{ ... all other plugins in here ... },
{
register: require('hapi-sequelize'),
options: [
{
name: 'agrade',
models: ['./api/models/seq/*.js'],
sequelize: new Sequelize('a-grade', 'root', '', {
host: 'localhost',
port: 3306,
dialect: 'mysql'
})
}
]
}], (err) => {
if (err) {
console.log('ERROR:', err);
};
let db = server.plugins['hapi-sequelize'].agrade;
let models = db.sequelize.models;
//associations(models);
server.register({
register: require('hapi-sequelize-crud'),
options: {
prefix: '/api/seq'
}
});
var routes = require(appDir + process.env.PATH_API + process.env.PATH_ROUTES);
server.route(routes);
server.start(() => {
logger.log('info',`SERVER - server STARTED`);
});
});
```
I'm not sure _where_ to register the `hapi-sequelize-crud` plugin.
When it is as the code above, the server starts up without errors, but none of my routes work (not routes generated by `hapi-sequelize-crud`, or manually created routes).
When I add it immediately after the `hapi-sequelize` registration, I get the following error: "**Cannot read property 'sequelize' of undefined**" or server startup.
@casalot: Hey, you're right about db name being hardcoded, I wasn't aware of such feature.
We're most probably going to switch to Babel 6 here.
@casalot: Hey, you're right about db name being hardcoded, I wasn't aware of such feature.
We're most probably going to switch to Babel 6 [here](https://github.com/mdibaiee/hapi-sequelize-crud/pull/5).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The following is an extract from my
server.jsscript:I'm not sure where to register the
hapi-sequelize-crudplugin.When it is as the code above, the server starts up without errors, but none of my routes work (not routes generated by
hapi-sequelize-crud, or manually created routes).When I add it immediately after the
hapi-sequelizeregistration, I get the following error: "Cannot read property 'sequelize' of undefined" or server startup.Okay, I have figured this out. Two issues:
babel-polyfillmissinghapi-sequelizedb name is hardcoded as 'db'@casalot: Hey, you're right about db name being hardcoded, I wasn't aware of such feature.
We're most probably going to switch to Babel 6 here.