diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..e69de29 diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..4ed9690 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,10 @@ +{ + "extends": "loopback", + "rules": { + "max-len": ["error", 80, 4, { + "ignoreComments": true, + "ignoreUrls": true, + "ignorePattern": "^\\s*var\\s.+=\\s*(require\\s*\\()|(/)" + }] + } +} \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..795176c --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,37 @@ + + +# Description/Steps to reproduce + + + +# Link to reproduction sandbox + + + +# Expected result + + + +# Additional information + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..368cb4c --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,25 @@ +### Description + + +#### Related issues + + + +- connect to + +### Checklist + + + +- [ ] New tests added or existing tests modified to cover all changes +- [ ] Code conforms with the [style + guide](http://loopback.io/doc/en/contrib/style-guide.html) diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..bebe60a --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,23 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 14 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security + - critical + - p1 + - major +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: > + This issue has been closed due to continued inactivity. Thank you for your understanding. + If you believe this to be in error, please contact one of the code owners, + listed in the `CODEOWNERS` file at the top-level of this repository. diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index ee8c771..0000000 --- a/.jshintignore +++ /dev/null @@ -1,2 +0,0 @@ -/client/ -/node_modules/ diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index feb0928..0000000 --- a/.jshintrc +++ /dev/null @@ -1,21 +0,0 @@ -{ - "node": true, - "esnext": true, - "bitwise": true, - "camelcase": true, - "eqeqeq": true, - "eqnull": true, - "immed": true, - "indent": 2, - "latedef": "nofunc", - "newcap": true, - "nonew": true, - "noarg": true, - "quotmark": "single", - "regexp": true, - "undef": true, - "unused": false, - "trailing": true, - "sub": true, - "maxlen": 80 -} diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..24c2021 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,9 @@ +# Lines starting with '#' are comments. +# Each line is a file pattern followed by one or more owners, +# the last matching pattern has the most precedence. + +# Alumni maintainers +# @kjdelisle @loay @ssh24 @virkt25 + +# Core team members from IBM +* @jannyHou @b-admike @dhmlau diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6b2e78..0591409 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -147,5 +147,5 @@ Contributing to `loopback-example-database` is easy. In a few simple steps: inaccurate in any respect. Email us at callback@strongloop.com. ``` -[Google C++ Style Guide]: https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml -[Google Javascript Style Guide]: https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml +[Google C++ Style Guide]: https://google.github.io/styleguide/cppguide.html +[Google Javascript Style Guide]: https://google.github.io/styleguide/javascriptguide.xml diff --git a/LICENSE.md b/LICENSE similarity index 85% rename from LICENSE.md rename to LICENSE index 12c1973..e25b440 100644 --- a/LICENSE.md +++ b/LICENSE @@ -1,4 +1,8 @@ -Copyright (c) 2013-2015 StrongLoop, Inc. +Copyright (c) IBM Corp. 2013,2017. All Rights Reserved. +Node module: loopback-example-database +This project is licensed under the MIT License, full text below. + +-------- MIT license diff --git a/README.md b/README.md index ef56bd2..54367a6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # loopback-example-database +**⚠️ This LoopBack 3 example project is no longer maintained. Please refer to [LoopBack 4 Examples](https://loopback.io/doc/en/lb4/Examples.html) instead. ⚠️** + A tutorial for basic database related features. - [Overview](#overview) @@ -67,8 +69,26 @@ npm start - Dir to contain the project: `loopback-example-database` ``` -slc loopback loopback-example-database -... # follow the prompts +lb app loopback-example-database + + _-----_ + | | ╭──────────────────────────╮ + |--(o)--| │ Let's create a LoopBack │ + `---------´ │ application! │ + ( _´U`_ ) ╰──────────────────────────╯ + /___A___\ / + | ~ | + __'.___.'__ + ´ ` |° ´ Y ` + +? What's the name of your application? loopback-example-database +? Enter name of the directory to contain the project: loopback-example-database + info change the working directory to loopback-example-database + +? Which version of LoopBack would you like to use? 3.x (current) +? What kind of application do you have in mind? empty-server (An empty LoopBack API, without any c +onfigured models or datasources) + ``` ### 2. Install the LoopBack MongoDB connector @@ -86,7 +106,7 @@ npm install --save loopback-connector-mongodb - Select the connector for `accountDS`: `MongoDB` ``` -slc loopback:datasource accountDS +lb datasource accountDS ... # follow the prompts ``` @@ -118,6 +138,11 @@ server. Edit `server/datasources.json` to set the MongoDB configs: ### 5. Create a new model +``` +lb model +... # follow the prompts +``` + #### Model Info - Model name: `Account` @@ -145,7 +170,7 @@ slc loopback:model Account With the `account` model configured, we can generate the corresponding MongoDB collection using the info from the `Account` metadata in [`common/models/account.json`](common/models/account.json) -via [*auto-migration*](https://docs.strongloop.com/display/public/LB/Implementing+auto-migration). +via [*auto-migration*](http://loopback.io/doc/en/lb2/Implementing-auto-migration.html). Start by creating a dir to store general-purpose scripts: @@ -220,7 +245,7 @@ You should see: ### 8. Add a script to perform instance instrospection (Discovery) -> [*Discovery*](https://docs.strongloop.com/display/public/LB/Discovering+models+from+relational+databases) +> [*Discovery*](http://loopback.io/doc/en/lb2/Discovering-models-from-relational-databases.html) > is the process of reverse engineering a LoopBack model from an existing database schema. The LoopBack MongoDB connector does not support discovery. However, you can use @@ -243,9 +268,9 @@ Created: { email: 'bob.doe@ibm.com', id: 56299d9d71c7f600719ca39f } ``` -> See the [official docs](http://docs.strongloop.com/display/LB/Creating+models+from+unstructured+data) +> See the [official docs](http://loopback.io/doc/en/lb2/Creating-models-from-unstructured-data.html) > for more info. --- -[More LoopBack examples](https://github.com/strongloop/loopback-example) +[More LoopBack examples](https://loopback.io/doc/en/lb3/Tutorials-and-examples.html) diff --git a/bin/automigrate.js b/bin/automigrate.js index ec95d81..e2f79fc 100644 --- a/bin/automigrate.js +++ b/bin/automigrate.js @@ -1,3 +1,8 @@ +// Copyright IBM Corp. 2015,2016. All Rights Reserved. +// Node module: loopback-example-database +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + var path = require('path'); var app = require(path.resolve(__dirname, '../server/server')); @@ -9,13 +14,13 @@ ds.automigrate('Account', function(err) { { email: 'john.doe@ibm.com', createdAt: new Date(), - lastModifiedAt: new Date() + lastModifiedAt: new Date(), }, { email: 'jane.doe@ibm.com', createdAt: new Date(), - lastModifiedAt: new Date() - } + lastModifiedAt: new Date(), + }, ]; var count = accounts.length; accounts.forEach(function(account) { diff --git a/bin/instance-introspection.js b/bin/instance-introspection.js index 7cbc8d8..be8eabf 100644 --- a/bin/instance-introspection.js +++ b/bin/instance-introspection.js @@ -1,3 +1,8 @@ +// Copyright IBM Corp. 2015,2016. All Rights Reserved. +// Node module: loopback-example-database +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + var path = require('path'); var app = require(path.resolve(__dirname, '../server/server')); @@ -6,10 +11,10 @@ var ds = app.datasources.accountDS; var account = { email: 'bob.doe@ibm.com', createdAt: new Date(), - lastModifiedAt: new Date() + lastModifiedAt: new Date(), }; var opts = { - idInjection: true + idInjection: true, }; var Account = ds.buildModelFromInstance('Account', account, opts); diff --git a/common/models/account.js b/common/models/account.js index f1c967e..bc8e1cd 100644 --- a/common/models/account.js +++ b/common/models/account.js @@ -1,3 +1,8 @@ +// Copyright IBM Corp. 2015,2016. All Rights Reserved. +// Node module: loopback-example-database +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + module.exports = function(Account) { }; diff --git a/package.json b/package.json index 378b63d..2ba6c08 100644 --- a/package.json +++ b/package.json @@ -3,22 +3,24 @@ "version": "2.0.0", "main": "server/server.js", "scripts": { - "pretest": "jshint .", "start": "node .", - "test": "tape test/*.js" + "lint": "eslint .", + "test": "tape test/*.js", + "posttest": "npm run lint" }, "dependencies": { "compression": "^1.0.3", - "cors": "^2.5.2", - "loopback": "^2.22.0", + "cors": "^2.8.1", + "loopback": "^3.0.0", "loopback-boot": "^2.6.5", - "loopback-component-explorer": "^2.1.0", - "loopback-connector-mongodb": "^1.13.0", - "loopback-datasource-juggler": "^2.39.0", - "serve-favicon": "^2.0.1" + "loopback-component-explorer": "^6.3.1", + "loopback-connector-mongodb": "^3.9.2", + "serve-favicon": "^2.0.1", + "strong-error-handler": "^1.1.0" }, "devDependencies": { - "jshint": "^2.5.6", + "eslint": "^2.7.0", + "eslint-config-loopback": "^1.0.0", "tape": "^4.2.2" }, "repository": { @@ -26,5 +28,6 @@ "url": "https://github.com/strongloop/loopback-example-database" }, "description": "loopback-example-database", - "license": "MIT" + "license": "MIT", + "author": "IBM Corp." } diff --git a/server/boot/authentication.js b/server/boot/authentication.js index a87cd08..2e3c97f 100644 --- a/server/boot/authentication.js +++ b/server/boot/authentication.js @@ -1,3 +1,8 @@ +// Copyright IBM Corp. 2014,2016. All Rights Reserved. +// Node module: loopback-example-database +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + module.exports = function enableAuthentication(server) { // enable authentication server.enableAuth(); diff --git a/server/boot/root.js b/server/boot/root.js index e106142..63bb5fa 100644 --- a/server/boot/root.js +++ b/server/boot/root.js @@ -1,3 +1,8 @@ +// Copyright IBM Corp. 2014,2016. All Rights Reserved. +// Node module: loopback-example-database +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + module.exports = function(server) { // Install a `/` route that returns server status var router = server.loopback.Router(); diff --git a/server/config.json b/server/config.json index ac5e58c..bf46eb4 100644 --- a/server/config.json +++ b/server/config.json @@ -3,9 +3,7 @@ "host": "0.0.0.0", "port": 3000, "remoting": { - "context": { - "enableHttpContext": false - }, + "context": false, "rest": { "normalizeHttpPath": false, "xml": false @@ -19,9 +17,7 @@ "limit": "100kb" }, "cors": false, - "errorHandler": { - "disableStackTrace": false - } + "errorHandler": false }, "legacyExplorer": false } diff --git a/server/middleware.json b/server/middleware.json index 1f334b2..9fbfdec 100644 --- a/server/middleware.json +++ b/server/middleware.json @@ -27,6 +27,6 @@ "loopback#urlNotFound": {} }, "final:after": { - "loopback#errorHandler": {} + "strong-error-handler": {} } } diff --git a/server/server.js b/server/server.js index 3be7b08..fa68d81 100644 --- a/server/server.js +++ b/server/server.js @@ -1,3 +1,8 @@ +// Copyright IBM Corp. 2014,2016. All Rights Reserved. +// Node module: loopback-example-database +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + var loopback = require('loopback'); var boot = require('loopback-boot'); diff --git a/test/smoke.js b/test/smoke.js index e01c3f4..f0c9a82 100644 --- a/test/smoke.js +++ b/test/smoke.js @@ -1,3 +1,8 @@ +// Copyright IBM Corp. 2015,2016. All Rights Reserved. +// Node module: loopback-example-database +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + var test = require('tape'); test('smoke test', function(t) {