hapipal / schwifty

A model layer for hapi integrating Objection ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Drop support for static models configuration

orditeck opened this issue · comments

When importing schwifty in webpack, I get the following warning:

WARNING in ./node_modules/Schwifty/lib/index.js 94:28-50
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/Schwifty/lib/index.js 98:28-76
Critical dependency: the request of a dependency is an expression

See webpack/webpack#196. There are some ways to get rid of these warnings in webpack, but it would be even better to avoid them in the first place.

I plan to drop support for static models config, as seen here:

schwifty/test/index.js

Lines 239 to 273 in de2f5ad

it('takes `models` option as a relative path.', async () => {
const options = getOptions({ models: Path.normalize('./test/' + modelsFile) });
const server = await getServer(options);
const models = server.models();
expect(models.Dog).to.exist();
expect(models.Person).to.exist();
});
it('takes `models` option as an absolute path.', async () => {
const options = getOptions({ models: Path.normalize(__dirname + '/' + modelsFile) });
const server = await getServer(options);
const models = server.models();
expect(models.Dog).to.exist();
expect(models.Person).to.exist();
});
it('takes `models` option respecting server.path().', async () => {
const server = Hapi.server();
server.path(__dirname);
await server.register({
plugin: Schwifty,
options: getOptions({ models: modelsFile })
});
const models = server.models();
expect(models.Dog).to.exist();
expect(models.Person).to.exist();
});

For me the reason is less due to webpack warnings, although I'm glad it will help clear that up too. The feature is very old, going back to usage with dogwater and pre-haute-couture. I don't think it's very useful nowadays, but if anyone objects I would be happy to chat more about it here.