This repository was archived by the owner on Apr 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Rework models to use the new 2.0 layout, extract lbclient/
#28
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "Todo": { | ||
| "dataSource": "db" | ||
| }, | ||
| "user": { | ||
| "dataSource": "db" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| browser.bundle.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| var loopback = require('loopback'); | ||
| var boot = require('loopback-boot'); | ||
|
|
||
| // model definitions | ||
| require('../models'); | ||
| require('./models/index'); | ||
|
|
||
| var client = module.exports = loopback(); | ||
| boot(client); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| var path = require('path'); | ||
| var pkg = require('./package.json'); | ||
| var fs = require('fs'); | ||
| var browserify = require('browserify'); | ||
| var boot = require('loopback-boot'); | ||
|
|
||
| exports.global = function(env, global) { | ||
| }; | ||
|
|
||
| exports.local = function configure(env, global, local) { | ||
| // NOTE: this config will be available in the browser | ||
| local.serverInfo = { | ||
| api: global.api, | ||
| url: global.api.protocol | ||
| + '://' | ||
| + global.api.host | ||
| + ':' | ||
| + global.api.port | ||
| + global.api.root | ||
| }; | ||
| local.routes = global.routes; | ||
| }; | ||
|
|
||
| exports.build = function(env, global, local, cb) { | ||
| var b = browserify({ basedir: __dirname }); | ||
| b.require('./' + pkg.main, { expose: 'lbclient' }); | ||
|
|
||
| try { | ||
| boot.compileToBrowserify({ | ||
| appRootDir: __dirname, | ||
| env: env | ||
| }, b); | ||
| } catch(err) { | ||
| return cb(err); | ||
| } | ||
|
|
||
| var bundlePath = path.resolve(__dirname, 'browser.bundle.js'); | ||
| var out = fs.createWriteStream(path.resolve(__dirname, bundlePath)); | ||
|
|
||
| b.bundle({ | ||
| // TODO(bajtos) debug should be always true, the sourcemaps should be | ||
| // saved to a standalone file when !isDev(env) | ||
| debug: isDev(env) | ||
| }) | ||
| .on('error', cb) | ||
| .pipe(out); | ||
|
|
||
| out.on('error', cb); | ||
| out.on('close', cb); | ||
| }; | ||
|
|
||
| function isDev(env) { | ||
| return ~['debug', 'development', 'test'].indexOf(env); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "db": { | ||
| "remote": { | ||
| "connector": "remote" | ||
| }, | ||
| "local": { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| var LOCAL_CONFIG = require('local.config'); | ||
|
|
||
| module.exports = { | ||
| db: { | ||
| remote: { | ||
| url: LOCAL_CONFIG.serverInfo.url | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "Todo": { | ||
| "dataSource": "remote" | ||
| }, | ||
| "LocalTodo": { | ||
| "dataSource": "local" | ||
| }, | ||
| "user": { | ||
| "dataSource": "remote" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| exports.LocalTodo = require('./local-todo'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| var loopback = require('loopback'); | ||
|
|
||
| var LocalTodo = loopback.createModel(require('./local-todo.json')); | ||
| module.exports = LocalTodo; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "LocalTodo", | ||
| "base": "Todo" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "client", | ||
| "main": "app.client.js" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be confusing for new LB developers. The thing is,
require('./models')is resolved to./models.json.Here are some of the solutions:
models/tomodel/. Other folders use singular form too (lib,test).models.jsonto something else -app-models.json,models-config.json, etc. This is introducing inconsistency withapp.jsonanddatasources.json, perhaps they should be renamed too?I am inclining towards the first option - keep model definitions in
modelfolder.