Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/psi-4ward/loopback-packageloader
Load loopback models and configs from different directories
https://github.com/psi-4ward/loopback-packageloader
Last synced: 22 days ago
JSON representation
Load loopback models and configs from different directories
- Host: GitHub
- URL: https://github.com/psi-4ward/loopback-packageloader
- Owner: psi-4ward
- Created: 2015-01-27T15:54:27.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-30T10:09:28.000Z (almost 10 years ago)
- Last Synced: 2024-12-09T08:46:53.747Z (25 days ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# loopback-packageloader
Load loopback models and configs from different directories.
* `packages/*/loopback`
* `node_modules/*` if the package.json contains `loopback4angularModule:true`## Install
```
npm install psi-4ward/loopback-packageloader
```## Usage
Edit your server.js like this```javascript
var loopback = require('loopback');
var boot = require('loopback-boot');
var packageloader = require('loopback-packageloader');var app = module.exports = loopback();
// generate a boot config that supports packages
var bootCfg = packageloader();// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, bootCfg);// start the web server
app.listen(function() {
app.emit('started');
console.log('Web server listening at: %s', app.get('url'));
});
```## Configuration
You can pass a config object as first param to `packageloader(objConfig)`
```javascript
var objConfig = {
localPackages: [
'packages/*/loopback',
'server' // also support the "old" server directory
],
foreignPackages: [
// must include loopback4angularModule:true key in package.json
'node_modules/*'
],
loadCommonModels: true, // load User, ACL, Roles etc models
appRootDir: __dirname,
appConfigRootDir: '.', // heres config.json
env: 'development' // is overwritten with process.env.NODE_ENV
};
```