diff --git a/.travis.yml b/.travis.yml index 9921cd9a93d7..728ed1955779 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,7 @@ jobs: # is not able to access type information for dependencies script: - lerna bootstrap + - npm run build - npm run lint - node_js: "12" diff --git a/acceptance/extension-logging-fluentd/index.d.ts b/acceptance/extension-logging-fluentd/index.d.ts deleted file mode 100644 index cd72d0ceb8c6..000000000000 --- a/acceptance/extension-logging-fluentd/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-extension-logging-fluentd -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/acceptance/extension-logging-fluentd/index.js b/acceptance/extension-logging-fluentd/index.js deleted file mode 100644 index 922391a5d639..000000000000 --- a/acceptance/extension-logging-fluentd/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-extension-logging-fluentd -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/acceptance/extension-logging-fluentd/package.json b/acceptance/extension-logging-fluentd/package.json index 5f6626933bd3..f124fd7edd92 100644 --- a/acceptance/extension-logging-fluentd/package.json +++ b/acceptance/extension-logging-fluentd/package.json @@ -3,6 +3,8 @@ "version": "0.3.3", "description": "Acceptance test for extension-logging with fluentd", "private": true, + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -29,8 +31,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/acceptance/repository-cloudant/index.d.ts b/acceptance/repository-cloudant/index.d.ts deleted file mode 100644 index 69dfc054f54c..000000000000 --- a/acceptance/repository-cloudant/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-cloudant -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/acceptance/repository-cloudant/index.js b/acceptance/repository-cloudant/index.js deleted file mode 100644 index 29867dec6e00..000000000000 --- a/acceptance/repository-cloudant/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-cloudant -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/acceptance/repository-cloudant/index.ts b/acceptance/repository-cloudant/index.ts deleted file mode 100644 index 22b0e7aac254..000000000000 --- a/acceptance/repository-cloudant/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-cloudant -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/acceptance/repository-cloudant/package.json b/acceptance/repository-cloudant/package.json index 79392998a094..4d9530bf95e3 100644 --- a/acceptance/repository-cloudant/package.json +++ b/acceptance/repository-cloudant/package.json @@ -3,6 +3,8 @@ "version": "2.1.3", "description": "", "private": true, + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -36,8 +38,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/acceptance/repository-mongodb/index.d.ts b/acceptance/repository-mongodb/index.d.ts deleted file mode 100644 index 1c6ea27f7625..000000000000 --- a/acceptance/repository-mongodb/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-mongodb -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/acceptance/repository-mongodb/index.js b/acceptance/repository-mongodb/index.js deleted file mode 100644 index 0e52f1f18501..000000000000 --- a/acceptance/repository-mongodb/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-mongodb -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/acceptance/repository-mongodb/index.ts b/acceptance/repository-mongodb/index.ts deleted file mode 100644 index dc8bef8423fd..000000000000 --- a/acceptance/repository-mongodb/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-mongodb -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/acceptance/repository-mongodb/package.json b/acceptance/repository-mongodb/package.json index eb226690da15..7be1883108da 100644 --- a/acceptance/repository-mongodb/package.json +++ b/acceptance/repository-mongodb/package.json @@ -3,6 +3,8 @@ "version": "0.7.3", "description": "", "private": true, + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -28,8 +30,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/acceptance/repository-mysql/index.d.ts b/acceptance/repository-mysql/index.d.ts deleted file mode 100644 index bb2a6970cc08..000000000000 --- a/acceptance/repository-mysql/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-mysql -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/acceptance/repository-mysql/index.js b/acceptance/repository-mysql/index.js deleted file mode 100644 index 6620c9bb0f1e..000000000000 --- a/acceptance/repository-mysql/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-mysql -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/acceptance/repository-mysql/index.ts b/acceptance/repository-mysql/index.ts deleted file mode 100644 index e210342ff487..000000000000 --- a/acceptance/repository-mysql/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-mysql -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/acceptance/repository-mysql/package.json b/acceptance/repository-mysql/package.json index e6ff62c06606..8ee1c8a77810 100644 --- a/acceptance/repository-mysql/package.json +++ b/acceptance/repository-mysql/package.json @@ -3,6 +3,8 @@ "version": "0.7.3", "description": "", "private": true, + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -28,8 +30,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/acceptance/repository-postgresql/index.d.ts b/acceptance/repository-postgresql/index.d.ts deleted file mode 100644 index 9c84f345e0eb..000000000000 --- a/acceptance/repository-postgresql/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-postgresql -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/acceptance/repository-postgresql/index.js b/acceptance/repository-postgresql/index.js deleted file mode 100644 index d0f5851b14a2..000000000000 --- a/acceptance/repository-postgresql/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-postgresql -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/acceptance/repository-postgresql/index.ts b/acceptance/repository-postgresql/index.ts deleted file mode 100644 index 6c0d2f7671f2..000000000000 --- a/acceptance/repository-postgresql/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/test-repository-postgresql -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/acceptance/repository-postgresql/package.json b/acceptance/repository-postgresql/package.json index 243051d4dd3c..4e5721339500 100644 --- a/acceptance/repository-postgresql/package.json +++ b/acceptance/repository-postgresql/package.json @@ -3,6 +3,8 @@ "version": "2.1.3", "description": "", "private": true, + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -28,8 +30,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/benchmark/index.js b/benchmark/index.js deleted file mode 100644 index 546939e018ec..000000000000 --- a/benchmark/index.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/benchmark -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const bench = require('./dist'); - -module.exports = bench; - -if (require.main === module) { - bench.main().then( - success => process.exit(0), - err => { - console.error('Cannot run the benchmark.', err); - process.exit(1); - }, - ); -} diff --git a/benchmark/index.ts b/benchmark/index.ts deleted file mode 100644 index 17219363c459..000000000000 --- a/benchmark/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/benchmark -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/benchmark/package.json b/benchmark/package.json index a9df16ec022b..921b5fed58d4 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -1,14 +1,15 @@ { "name": "@loopback/benchmark", "version": "2.0.8", - "private": true, "description": "Benchmarks measuring performance of our framework.", + "private": true, + "main": "dist/index.js", + "types": "dist/index.d.ts", "keywords": [ "loopback", "performance", "benchmark" ], - "main": "index.js", "engines": { "node": ">=10" }, @@ -26,8 +27,6 @@ "license": "MIT", "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/benchmark/src/index.ts b/benchmark/src/index.ts index 7bf757357fa6..d5d691a7163f 100644 --- a/benchmark/src/index.ts +++ b/benchmark/src/index.ts @@ -16,3 +16,13 @@ export async function main() { bench.logger = (title, stats) => console.log('%s:', title, stats); await bench.run(); } + +if (require.main === module) { + main().then( + success => process.exit(0), + err => { + console.error('Cannot run the benchmark.', err); + process.exit(1); + }, + ); +} diff --git a/docs/site/deployment/Deploying-with-pm2-and-nginx.md b/docs/site/deployment/Deploying-with-pm2-and-nginx.md index 2a3cbcd70eda..ac4d9535ba67 100644 --- a/docs/site/deployment/Deploying-with-pm2-and-nginx.md +++ b/docs/site/deployment/Deploying-with-pm2-and-nginx.md @@ -62,7 +62,7 @@ section of documentation for detailed instructions. apps: [ { name: 'MyAPI', - script: 'index.js', + script: 'dist/index.js', instances: 1, autorestart: true, watch: false, @@ -105,8 +105,8 @@ section of documentation for detailed instructions. $ npm start ``` - This creates a dist folder which contains the transpiled code. Use `index.js` - at your app's root level for starting the server using `pm2`. + This creates a dist folder which contains the transpiled code. Use + `dist/index.js` at your app's root level for starting the server using `pm2`. Now you can visit [http://127.0.0.1:3000/](http://127.0.0.1:3000/) to check your newly deployed API. diff --git a/docs/site/express-with-lb4-rest-tutorial.md b/docs/site/express-with-lb4-rest-tutorial.md index 3c94c6e3f7d0..c779e50a185d 100644 --- a/docs/site/express-with-lb4-rest-tutorial.md +++ b/docs/site/express-with-lb4-rest-tutorial.md @@ -151,9 +151,10 @@ Create two properties, the Express application instance and LoopBack application instance: ```ts -import {NoteApplication} from './application'; -import {ApplicationConfig} from '@loopback/core'; import express from 'express'; +import {ApplicationConfig, NoteApplication} from './application'; + +export {ApplicationConfig}; export class ExpressServer { public readonly app: express.Application; @@ -255,10 +256,9 @@ Now that our **src/server.ts** file is ready, then we can modify our {% include code-caption.html content="src/index.ts" %} ```ts -import {ExpressServer} from './server'; -import {ApplicationConfig} from '@loopback/core'; +import {ApplicationConfig, ExpressServer} from './server'; -export {ExpressServer, NoteApplication}; +export {ApplicationConfig, ExpressServer, NoteApplication}; export async function main(options: ApplicationConfig = {}) { const server = new ExpressServer(options); @@ -266,21 +266,13 @@ export async function main(options: ApplicationConfig = {}) { await server.start(); console.log('Server is running at http://127.0.0.1:3000'); } -``` - -{% include code-caption.html content="index.js" %} - -```js -const application = require('./dist'); - -module.exports = application; if (require.main === module) { // Run the application const config = { rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', openApiSpec: { // useful when used with OpenAPI-to-GraphQL to locate your application setServersFromRequest: true, @@ -289,7 +281,7 @@ if (require.main === module) { listenOnStart: false, }, }; - application.main(config).catch(err => { + main(config).catch(err => { console.error('Cannot start the application.', err); process.exit(1); }); diff --git a/docs/site/tutorials/todo/todo-tutorial-scaffolding.md b/docs/site/tutorials/todo/todo-tutorial-scaffolding.md index a5fd52d8fdba..387947b8161f 100644 --- a/docs/site/tutorials/todo/todo-tutorial-scaffolding.md +++ b/docs/site/tutorials/todo/todo-tutorial-scaffolding.md @@ -71,8 +71,6 @@ node_modules/ *** LICENSE README.md -index.js -index.ts package.json tsconfig.json .eslintrc.js @@ -84,8 +82,6 @@ Note that there might be extra files not listed here. | File | Purpose | | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `index.ts` | Allows importing contents of the `src` folder (for use elsewhere) | -| `index.js` | Top-level file connecting components of the application. | | `package.json` | Your application's package manifest. See [package.json](https://docs.npmjs.com/files/package.json) for details. | | `tsconfig.json` | The TypeScript project configuration. See [tsconfig.json](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) for details. | | `.eslintrc.js` | [ESLint configuration](https://eslint.org/docs/user-guide/configuring) | diff --git a/examples/access-control-migration/index.d.ts b/examples/access-control-migration/index.d.ts deleted file mode 100644 index 737cc5bf8047..000000000000 --- a/examples/access-control-migration/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-access-control-migration -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/access-control-migration/index.js b/examples/access-control-migration/index.js deleted file mode 100644 index fa2916f2d130..000000000000 --- a/examples/access-control-migration/index.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-access-control-migration -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/access-control-migration/index.ts b/examples/access-control-migration/index.ts deleted file mode 100644 index e8638d0c7c32..000000000000 --- a/examples/access-control-migration/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-access-control-migration -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/access-control-migration/package.json b/examples/access-control-migration/package.json index cc0c742eca4e..7febb2e2fa60 100644 --- a/examples/access-control-migration/package.json +++ b/examples/access-control-migration/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-access-control-migration", "version": "1.2.1", "description": "Tutorial example on how to migrate the access control example with LoopBack 4.", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/access-control-migration/src/application.ts b/examples/access-control-migration/src/application.ts index 72b3e51c4210..9cc4050b55ba 100644 --- a/examples/access-control-migration/src/application.ts +++ b/examples/access-control-migration/src/application.ts @@ -19,6 +19,8 @@ import { } from './components/jwt-authentication'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + /** * Information from package.json */ diff --git a/examples/access-control-migration/src/index.ts b/examples/access-control-migration/src/index.ts index b17bafb04d4d..97bda9678ebb 100644 --- a/examples/access-control-migration/src/index.ts +++ b/examples/access-control-migration/src/index.ts @@ -3,8 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {AccessControlApplication} from './application'; -import {ApplicationConfig} from '@loopback/core'; +import {AccessControlApplication, ApplicationConfig} from './application'; export async function main(options: ApplicationConfig = {}) { const app = new AccessControlApplication(options); @@ -17,8 +16,26 @@ export async function main(options: ApplicationConfig = {}) { } // re-exports for our benchmark, not needed for the tutorial itself -export {AccessControlApplication}; - +export * from '@loopback/rest'; +export * from './application'; export * from './models'; export * from './repositories'; -export * from '@loopback/rest'; + +// Start the server when loaded via `node .` +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/context/index.d.ts b/examples/context/index.d.ts deleted file mode 100644 index 842ba5c115dc..000000000000 --- a/examples/context/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/example-context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/context/index.js b/examples/context/index.js deleted file mode 100644 index 4a78fc9b01a3..000000000000 --- a/examples/context/index.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/example-context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const examples = require('./dist'); - -if (require.main === module) { - examples.main().catch(err => { - console.error('Fails to run examples.', err); - process.exit(1); - }); -} diff --git a/examples/context/index.ts b/examples/context/index.ts deleted file mode 100644 index f21395f745fc..000000000000 --- a/examples/context/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/example-context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/context/package.json b/examples/context/package.json index e7b6065f4be4..136e00e4ed77 100644 --- a/examples/context/package.json +++ b/examples/context/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-context", "version": "2.0.8", "description": "Standalone examples for @loopback/context", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/context/src/index.ts b/examples/context/src/index.ts index e1b18b655ec3..826d7aeeb797 100644 --- a/examples/context/src/index.ts +++ b/examples/context/src/index.ts @@ -32,3 +32,10 @@ if (require.main === module) { process.exit(1); }); } + +if (require.main === module) { + main().catch(err => { + console.error('Fails to run examples.', err); + process.exit(1); + }); +} diff --git a/examples/express-composition/index.d.ts b/examples/express-composition/index.d.ts deleted file mode 100644 index f26d3eeb54c9..000000000000 --- a/examples/express-composition/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-express-composition -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/express-composition/index.js b/examples/express-composition/index.js deleted file mode 100644 index 1e1637adb68c..000000000000 --- a/examples/express-composition/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-express-composition -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - // Use the LB4 application as a route. It should not be listening. - listenOnStart: false, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/express-composition/index.ts b/examples/express-composition/index.ts deleted file mode 100644 index a4973b834840..000000000000 --- a/examples/express-composition/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-express-composition -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/express-composition/package.json b/examples/express-composition/package.json index bc10c9f26de1..5a572894c2e7 100644 --- a/examples/express-composition/package.json +++ b/examples/express-composition/package.json @@ -2,6 +2,8 @@ "name": "@loopback/example-express-composition", "version": "2.1.1", "description": "LoopBack 4 REST API on Express", + "main": "dist/index.js", + "types": "dist/index.d.ts", "keywords": [ "loopback-application", "loopback", @@ -9,7 +11,6 @@ "tutorial", "express" ], - "main": "index.js", "engines": { "node": ">=10" }, diff --git a/examples/express-composition/src/application.ts b/examples/express-composition/src/application.ts index 1a14a1d874c7..10ede5d96482 100644 --- a/examples/express-composition/src/application.ts +++ b/examples/express-composition/src/application.ts @@ -12,6 +12,8 @@ import {ServiceMixin} from '@loopback/service-proxy'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class NoteApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { diff --git a/examples/express-composition/src/index.ts b/examples/express-composition/src/index.ts index c3992e7de994..d91c0af2161e 100644 --- a/examples/express-composition/src/index.ts +++ b/examples/express-composition/src/index.ts @@ -3,10 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ExpressServer} from './server'; -import {ApplicationConfig} from '@loopback/core'; +import {ApplicationConfig, ExpressServer} from './server'; -export {ExpressServer}; +export * from './server'; export async function main(options: ApplicationConfig = {}) { const server = new ExpressServer(options); @@ -14,3 +13,23 @@ export async function main(options: ApplicationConfig = {}) { await server.start(); console.log('Server is running at http://127.0.0.1:3000'); } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + // Use the LB4 application as a route. It should not be listening. + listenOnStart: false, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/express-composition/src/server.ts b/examples/express-composition/src/server.ts index 3407d999e2f4..01642a7c3455 100644 --- a/examples/express-composition/src/server.ts +++ b/examples/express-composition/src/server.ts @@ -3,12 +3,13 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ApplicationConfig} from '@loopback/core'; import {once} from 'events'; import express, {Request, Response} from 'express'; import http from 'http'; import path from 'path'; -import {NoteApplication} from './application'; +import {ApplicationConfig, NoteApplication} from './application'; + +export {ApplicationConfig}; export class ExpressServer { public readonly app: express.Application; diff --git a/examples/file-transfer/index.js b/examples/file-transfer/index.js deleted file mode 100644 index e355299b8ed3..000000000000 --- a/examples/file-transfer/index.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-file-transfer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +(process.env.PORT || 3000), - host: process.env.HOST, - // The `gracePeriodForClose` provides a graceful close for http/https - // servers with keep-alive clients. The default value is `Infinity` - // (don't force-close). If you want to immediately destroy all sockets - // upon stop, set its value to `0`. - // See https://www.npmjs.com/package/stoppable - gracePeriodForClose: 5000, // 5 seconds - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/file-transfer/index.ts b/examples/file-transfer/index.ts deleted file mode 100644 index 4c5b3c11fc00..000000000000 --- a/examples/file-transfer/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-file-transfer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/file-transfer/package.json b/examples/file-transfer/package.json index c22a5eb5e5a8..a9a0c2e59067 100644 --- a/examples/file-transfer/package.json +++ b/examples/file-transfer/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-file-transfer", "version": "1.2.5", "description": "Example application for file upload/download with LoopBack 4", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/file-transfer/src/application.ts b/examples/file-transfer/src/application.ts index e4c6d5208f90..1076024bd4d3 100644 --- a/examples/file-transfer/src/application.ts +++ b/examples/file-transfer/src/application.ts @@ -15,6 +15,8 @@ import path from 'path'; import {FILE_UPLOAD_SERVICE, STORAGE_DIRECTORY} from './keys'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class FileUploadApplication extends BootMixin(RestApplication) { constructor(options: ApplicationConfig = {}) { super(options); diff --git a/examples/file-transfer/src/index.ts b/examples/file-transfer/src/index.ts index 7e6a6f94647d..8db04d4ac68b 100644 --- a/examples/file-transfer/src/index.ts +++ b/examples/file-transfer/src/index.ts @@ -4,10 +4,9 @@ // License text available at https://opensource.org/licenses/MIT /* istanbul ignore file */ -import {ApplicationConfig} from '@loopback/core'; -import {FileUploadApplication} from './application'; +import {ApplicationConfig, FileUploadApplication} from './application'; -export {FileUploadApplication}; +export * from './application'; export async function main(options: ApplicationConfig = {}) { const app = new FileUploadApplication(options); @@ -19,3 +18,27 @@ export async function main(options: ApplicationConfig = {}) { return app; } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST, + // The `gracePeriodForClose` provides a graceful close for http/https + // servers with keep-alive clients. The default value is `Infinity` + // (don't force-close). If you want to immediately destroy all sockets + // upon stop, set its value to `0`. + // See https://www.npmjs.com/package/stoppable + gracePeriodForClose: 5000, // 5 seconds + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/greeter-extension/index.d.ts b/examples/greeter-extension/index.d.ts deleted file mode 100644 index 18078ab5428c..000000000000 --- a/examples/greeter-extension/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-greeter-extension -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/greeter-extension/index.js b/examples/greeter-extension/index.js deleted file mode 100644 index 69c1a955988c..000000000000 --- a/examples/greeter-extension/index.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-greeter-extension -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); - -if (require.main === module) { - const app = new module.exports.GreetingApplication(); - app.main().catch(err => { - console.error(err); - process.exit(1); - }); -} diff --git a/examples/greeter-extension/index.ts b/examples/greeter-extension/index.ts deleted file mode 100644 index d1bad0d47fbc..000000000000 --- a/examples/greeter-extension/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-greeter-extension -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/greeter-extension/package.json b/examples/greeter-extension/package.json index b4717292d540..36b39604deff 100644 --- a/examples/greeter-extension/package.json +++ b/examples/greeter-extension/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-greeter-extension", "version": "2.0.8", "description": "An example extension point/extensions for LoopBack 4", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/greeter-extension/src/index.ts b/examples/greeter-extension/src/index.ts index 7a0587fd9c05..ad35f5422575 100644 --- a/examples/greeter-extension/src/index.ts +++ b/examples/greeter-extension/src/index.ts @@ -8,3 +8,12 @@ export * from './component'; export * from './greeting-service'; export * from './keys'; export * from './types'; + +import {GreetingApplication} from './application'; +if (require.main === module) { + const app = new GreetingApplication(); + app.main().catch(err => { + console.error(err); + process.exit(1); + }); +} diff --git a/examples/greeting-app/index.d.ts b/examples/greeting-app/index.d.ts deleted file mode 100644 index 5e26d73d54a2..000000000000 --- a/examples/greeting-app/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-greeting-app -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/greeting-app/index.js b/examples/greeting-app/index.js deleted file mode 100644 index a95102fe86ed..000000000000 --- a/examples/greeting-app/index.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-greeting-app -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); - -async function main() { - const config = { - rest: { - port: +(process.env.PORT || 3000), - host: process.env.HOST || '127.0.0.1', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - const app = new module.exports.GreetingApplication(config); - await app.main(); - const url = app.restServer.url; - console.log(`The service is running at ${url}/greet/world.`); -} - -if (require.main === module) { - main().catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/greeting-app/index.ts b/examples/greeting-app/index.ts deleted file mode 100644 index 24944191bb99..000000000000 --- a/examples/greeting-app/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-greeting-app -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/greeting-app/package.json b/examples/greeting-app/package.json index 388afc884402..9b2f0e23c62d 100644 --- a/examples/greeting-app/package.json +++ b/examples/greeting-app/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-greeting-app", "version": "2.0.8", "description": "An example greeting application for LoopBack 4", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/greeting-app/src/index.ts b/examples/greeting-app/src/index.ts index 634358254d14..ab0d82564a5c 100644 --- a/examples/greeting-app/src/index.ts +++ b/examples/greeting-app/src/index.ts @@ -6,3 +6,28 @@ export * from './application'; export * from './keys'; export * from './types'; + +import {GreetingApplication} from './application'; +export async function main() { + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? '127.0.0.1', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + const app = new GreetingApplication(config); + await app.main(); + const url = app.restServer.url; + console.log(`The service is running at ${url}/greet/world.`); +} + +if (require.main === module) { + main().catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/hello-world/index.d.ts b/examples/hello-world/index.d.ts deleted file mode 100644 index 34d28a0aa1f6..000000000000 --- a/examples/hello-world/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-hello-world -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/hello-world/index.js b/examples/hello-world/index.js deleted file mode 100644 index 6743c7de9dd0..000000000000 --- a/examples/hello-world/index.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-hello-world -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/hello-world/index.ts b/examples/hello-world/index.ts deleted file mode 100644 index 740a960fb4ca..000000000000 --- a/examples/hello-world/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-hello-world -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/hello-world/package.json b/examples/hello-world/package.json index c4896cd36233..2c161a5a3902 100644 --- a/examples/hello-world/package.json +++ b/examples/hello-world/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-hello-world", "version": "2.0.8", "description": "A simple hello-world Application using LoopBack 4", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/hello-world/src/application.ts b/examples/hello-world/src/application.ts index 0a2507e12aa4..57a118268a55 100644 --- a/examples/hello-world/src/application.ts +++ b/examples/hello-world/src/application.ts @@ -5,6 +5,7 @@ import {ApplicationConfig} from '@loopback/core'; import {RestApplication, RestServer} from '@loopback/rest'; +export {ApplicationConfig}; export class HelloWorldApplication extends RestApplication { constructor(options: ApplicationConfig = {}) { diff --git a/examples/hello-world/src/index.ts b/examples/hello-world/src/index.ts index 5d46ddb70020..18a8030598de 100644 --- a/examples/hello-world/src/index.ts +++ b/examples/hello-world/src/index.ts @@ -3,10 +3,28 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {HelloWorldApplication} from './application'; +import {ApplicationConfig, HelloWorldApplication} from './application'; -export async function main() { +export async function main(config: ApplicationConfig) { const app = new HelloWorldApplication(); await app.start(); return app; } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/lb3-application/README.md b/examples/lb3-application/README.md index 5543e9a0b0ba..d57b4dd8ce7b 100644 --- a/examples/lb3-application/README.md +++ b/examples/lb3-application/README.md @@ -276,7 +276,7 @@ LoopBack 4 apps. import {ApplicationConfig} from '@loopback/core'; import {ExpressServer} from './server'; - export {ExpressServer}; + export {ApplicationConfig, ExpressServer}; export async function main(options: ApplicationConfig = {}) { const server = new ExpressServer(options); @@ -286,17 +286,15 @@ LoopBack 4 apps. } ``` -4. Update `index.js` +4. Next, modify the application config in `src/index.ts` file to prevent the LB4 + app from listening, by adding `listenOnStart: false` in `config.rest` object. + The `config` object should now look like this: - Next, modify the `index.js` file in the root of the project to prevent the - LB4 app from listening, by adding `listenOnStart: false` in `config.rest` - object. The `config` object should now look like this: - - ```js + ```ts const config = { rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', openApiSpec: { // useful when used with OpenAPI-to-GraphQL to locate your application setServersFromRequest: true, diff --git a/examples/lb3-application/index.d.ts b/examples/lb3-application/index.d.ts deleted file mode 100644 index 2cba9adbc8a8..000000000000 --- a/examples/lb3-application/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-lb3-application -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/lb3-application/index.js b/examples/lb3-application/index.js deleted file mode 100644 index fe29c918b88b..000000000000 --- a/examples/lb3-application/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-lb3-application -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - // Use the LB4 application as a route. It should not be listening. - listenOnStart: false, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/lb3-application/index.ts b/examples/lb3-application/index.ts deleted file mode 100644 index 73ad50398426..000000000000 --- a/examples/lb3-application/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/example-lb3-application -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/lb3-application/package.json b/examples/lb3-application/package.json index cbc0104c0197..312cebf58f0f 100644 --- a/examples/lb3-application/package.json +++ b/examples/lb3-application/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-lb3-application", "version": "2.0.8", "description": "Tutorial example on how to add existing an LB3 application to a LB4 project", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/lb3-application/src/index.ts b/examples/lb3-application/src/index.ts index 889632c7b6df..679cf1ee4db9 100644 --- a/examples/lb3-application/src/index.ts +++ b/examples/lb3-application/src/index.ts @@ -3,10 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ApplicationConfig} from '@loopback/core'; -import {ExpressServer} from './server'; +import {ApplicationConfig, ExpressServer} from './server'; -export {ExpressServer}; +export * from './server'; export async function main(options: ApplicationConfig = {}) { const server = new ExpressServer(options); @@ -14,3 +13,23 @@ export async function main(options: ApplicationConfig = {}) { await server.start(); console.log(`Server is running at ${server.url}`); } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + // Use the LB4 application as a route. It should not be listening. + listenOnStart: false, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/lb3-application/src/server.ts b/examples/lb3-application/src/server.ts index 7285ebd2c98c..a9eef0a44018 100644 --- a/examples/lb3-application/src/server.ts +++ b/examples/lb3-application/src/server.ts @@ -16,6 +16,8 @@ const compression = require('compression'); const cors = require('cors'); const helmet = require('helmet'); +export {ApplicationConfig}; + export class ExpressServer { private app: express.Application; public readonly lbApp: CoffeeShopApplication; diff --git a/examples/log-extension/index.d.ts b/examples/log-extension/index.d.ts deleted file mode 100644 index c138809354ce..000000000000 --- a/examples/log-extension/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-log-extension -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/log-extension/index.js b/examples/log-extension/index.js deleted file mode 100644 index 5d341d89b3d0..000000000000 --- a/examples/log-extension/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-log-extension -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/examples/log-extension/index.ts b/examples/log-extension/index.ts deleted file mode 100644 index 9330cce8901d..000000000000 --- a/examples/log-extension/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-log-extension -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/log-extension/package.json b/examples/log-extension/package.json index 245849eb1668..6a35920bb0ba 100644 --- a/examples/log-extension/package.json +++ b/examples/log-extension/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-log-extension", "version": "2.0.8", "description": "An example extension project for LoopBack 4", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/metrics-prometheus/index.d.ts b/examples/metrics-prometheus/index.d.ts deleted file mode 100644 index bb249228ff45..000000000000 --- a/examples/metrics-prometheus/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/example-metrics-prometheus -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/metrics-prometheus/index.js b/examples/metrics-prometheus/index.js deleted file mode 100644 index 7c75f56d8a44..000000000000 --- a/examples/metrics-prometheus/index.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/example-metrics-prometheus -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); - -async function main() { - const config = { - rest: { - port: +(process.env.PORT || 3000), - host: process.env.HOST || '127.0.0.1', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - const app = new module.exports.GreetingApplication(config); - await app.main(); - const url = app.restServer.url; - console.log(`Greeting service is running at ${url}/greet/world?count=5.`); - console.log(`Metrics is running at ${url}/metrics`); -} - -if (require.main === module) { - main().catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/metrics-prometheus/index.ts b/examples/metrics-prometheus/index.ts deleted file mode 100644 index 964a062c16a4..000000000000 --- a/examples/metrics-prometheus/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/example-metrics-prometheus -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/metrics-prometheus/package.json b/examples/metrics-prometheus/package.json index 5ac62490a5bd..b3c9597b2124 100644 --- a/examples/metrics-prometheus/package.json +++ b/examples/metrics-prometheus/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-metrics-prometheus", "version": "0.2.8", "description": "Standalone examples for @loopback/metrics", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/metrics-prometheus/src/index.ts b/examples/metrics-prometheus/src/index.ts index 5567c452c311..9690205b4e50 100644 --- a/examples/metrics-prometheus/src/index.ts +++ b/examples/metrics-prometheus/src/index.ts @@ -4,3 +4,29 @@ // License text available at https://opensource.org/licenses/MIT export * from './application'; + +import {GreetingApplication} from './application'; +export async function main() { + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? '127.0.0.1', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + const app = new GreetingApplication(config); + await app.main(); + const url = app.restServer.url; + console.log(`Greeting service is running at ${url}/greet/world?count=5.`); + console.log(`Metrics is running at ${url}/metrics`); +} + +if (require.main === module) { + main().catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/multi-tenancy/index.js b/examples/multi-tenancy/index.js deleted file mode 100644 index 2f0eca41c73a..000000000000 --- a/examples/multi-tenancy/index.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-multi-tenancy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +(process.env.PORT || 3000), - host: process.env.HOST, - // The `gracePeriodForClose` provides a graceful close for http/https - // servers with keep-alive clients. The default value is `Infinity` - // (don't force-close). If you want to immediately destroy all sockets - // upon stop, set its value to `0`. - // See https://www.npmjs.com/package/stoppable - gracePeriodForClose: 5000, // 5 seconds - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/multi-tenancy/index.ts b/examples/multi-tenancy/index.ts deleted file mode 100644 index 10cf08ee6726..000000000000 --- a/examples/multi-tenancy/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-multi-tenancy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/multi-tenancy/package.json b/examples/multi-tenancy/package.json index f1b6b8226748..a6c36543ecd6 100644 --- a/examples/multi-tenancy/package.json +++ b/examples/multi-tenancy/package.json @@ -2,12 +2,13 @@ "name": "@loopback/example-multi-tenancy", "version": "0.2.1", "description": "An example to demonstrate multi-tenancy with LoopBack 4", + "main": "dist/index.js", + "types": "dist/index.d.ts", "keywords": [ "loopback-application", "loopback", "multi-tenancy" ], - "main": "index.js", "engines": { "node": ">=10" }, @@ -43,8 +44,6 @@ "license": "MIT", "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/examples/multi-tenancy/src/application.ts b/examples/multi-tenancy/src/application.ts index 5cb8025211be..eb07ef816058 100644 --- a/examples/multi-tenancy/src/application.ts +++ b/examples/multi-tenancy/src/application.ts @@ -16,6 +16,8 @@ import path from 'path'; import {MultiTenancyComponent} from './multi-tenancy/component'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class ExampleMultiTenancyApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { diff --git a/examples/multi-tenancy/src/index.ts b/examples/multi-tenancy/src/index.ts index e2e0178c99cd..ac4e2894e528 100644 --- a/examples/multi-tenancy/src/index.ts +++ b/examples/multi-tenancy/src/index.ts @@ -3,10 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ExampleMultiTenancyApplication} from './application'; -import {ApplicationConfig} from '@loopback/core'; +import {ApplicationConfig, ExampleMultiTenancyApplication} from './application'; -export {ExampleMultiTenancyApplication}; +export * from './application'; export async function main(options: ApplicationConfig = {}) { const app = new ExampleMultiTenancyApplication(options); @@ -19,3 +18,27 @@ export async function main(options: ApplicationConfig = {}) { return app; } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST, + // The `gracePeriodForClose` provides a graceful close for http/https + // servers with keep-alive clients. The default value is `Infinity` + // (don't force-close). If you want to immediately destroy all sockets + // upon stop, set its value to `0`. + // See https://www.npmjs.com/package/stoppable + gracePeriodForClose: 5000, // 5 seconds + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/passport-login/index.js b/examples/passport-login/index.js deleted file mode 100644 index 2a5e6eb9b3ee..000000000000 --- a/examples/passport-login/index.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-passport-login -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - application.main().catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/passport-login/index.ts b/examples/passport-login/index.ts deleted file mode 100644 index 98dc8d71ea92..000000000000 --- a/examples/passport-login/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-passport-login -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/passport-login/package.json b/examples/passport-login/package.json index 2de2a5aa3883..39943fba5bf5 100644 --- a/examples/passport-login/package.json +++ b/examples/passport-login/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-passport-login", "version": "1.3.0", "description": "examples to demonstrate authentication with passport strategies", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/passport-login/src/index.ts b/examples/passport-login/src/index.ts index 89a39159516d..e7c48335dcf3 100644 --- a/examples/passport-login/src/index.ts +++ b/examples/passport-login/src/index.ts @@ -3,13 +3,12 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ApplicationConfig} from '@loopback/core'; -import {ExpressServer} from './server'; +import {RestApplication} from '@loopback/rest'; import * as path from 'path'; import {oauth2ProfileFunction} from './authentication-strategies'; -import {RestApplication} from '@loopback/rest'; +import {ApplicationConfig, ExpressServer} from './server'; -export {ExpressServer}; +export * from './server'; /** * Prepare server config @@ -91,3 +90,10 @@ export async function main() { ); console.log(`Server is running at ${server.url}`); } + +if (require.main === module) { + main().catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/passport-login/src/server.ts b/examples/passport-login/src/server.ts index d0b5abf2333a..da9f5848935e 100644 --- a/examples/passport-login/src/server.ts +++ b/examples/passport-login/src/server.ts @@ -11,6 +11,8 @@ import {AddressInfo} from 'net'; import * as path from 'path'; import {OAuth2LoginApplication} from './application'; +export {ApplicationConfig}; + /** * An express server with multiple apps * diff --git a/examples/rest-crud/index.d.ts b/examples/rest-crud/index.d.ts deleted file mode 100644 index 9f2714ef8b1c..000000000000 --- a/examples/rest-crud/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-rest-crud -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/rest-crud/index.js b/examples/rest-crud/index.js deleted file mode 100644 index 2dd369019df6..000000000000 --- a/examples/rest-crud/index.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-rest-crud -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/rest-crud/index.ts b/examples/rest-crud/index.ts deleted file mode 100644 index ba8179f6695d..000000000000 --- a/examples/rest-crud/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-rest-crud -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/rest-crud/package.json b/examples/rest-crud/package.json index 120fb8142006..c2c8c0b0f8cd 100644 --- a/examples/rest-crud/package.json +++ b/examples/rest-crud/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-rest-crud", "version": "1.2.1", "description": "", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/rest-crud/src/application.ts b/examples/rest-crud/src/application.ts index 2ed3271bbd3e..b4e47c71e070 100644 --- a/examples/rest-crud/src/application.ts +++ b/examples/rest-crud/src/application.ts @@ -12,6 +12,8 @@ import {RestExplorerComponent} from '@loopback/rest-explorer'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class TodoApplication extends BootMixin( RepositoryMixin(RestApplication), ) { diff --git a/examples/rest-crud/src/index.ts b/examples/rest-crud/src/index.ts index de34874ea0b8..17496136f32e 100644 --- a/examples/rest-crud/src/index.ts +++ b/examples/rest-crud/src/index.ts @@ -3,8 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ApplicationConfig} from '@loopback/core'; -import {TodoApplication} from './application'; +import {ApplicationConfig, TodoApplication} from './application'; + +export * from './application'; export async function main(options: ApplicationConfig = {}) { const app = new TodoApplication(options); @@ -15,3 +16,21 @@ export async function main(options: ApplicationConfig = {}) { console.log(`Server is running at ${url}`); return app; } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/rpc-server/index.d.ts b/examples/rpc-server/index.d.ts deleted file mode 100644 index ad7a5124311e..000000000000 --- a/examples/rpc-server/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-rpc-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/rpc-server/index.js b/examples/rpc-server/index.js deleted file mode 100644 index fb50d6c99528..000000000000 --- a/examples/rpc-server/index.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-rpc-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - application.main().catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/rpc-server/index.ts b/examples/rpc-server/index.ts deleted file mode 100644 index 515e32f6f36c..000000000000 --- a/examples/rpc-server/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-rpc-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// NOTE(bajtos) This file is used by TypeScript compiler to resolve imports -// from "test" files against original TypeScript sources in "src" directory. -// As a side effect, `tsc` also produces "dist/index.{js,d.ts,map} files -// that allow test files to import paths pointing to {src,test} root directory, -// which is project root for TS sources but "dist" for transpiled sources. -export * from './src'; diff --git a/examples/rpc-server/package.json b/examples/rpc-server/package.json index 5a5d8850209d..2e0a8cde0921 100644 --- a/examples/rpc-server/package.json +++ b/examples/rpc-server/package.json @@ -2,6 +2,8 @@ "name": "@loopback/example-rpc-server", "version": "2.0.8", "description": "A basic RPC server using a made-up protocol.", + "main": "dist/index.js", + "types": "dist/index.d.ts", "keywords": [ "loopback-application", "loopback" diff --git a/examples/rpc-server/src/application.ts b/examples/rpc-server/src/application.ts index 9489ea7e223a..5f3f1c2b390b 100644 --- a/examples/rpc-server/src/application.ts +++ b/examples/rpc-server/src/application.ts @@ -4,8 +4,10 @@ // License text available at https://opensource.org/licenses/MIT import {Application, ApplicationConfig} from '@loopback/core'; -import {RPCServer} from './rpc.server'; import {GreetController} from './controllers'; +import {RPCServer} from './rpc.server'; + +export {ApplicationConfig}; export class MyApplication extends Application { options: ApplicationConfig; diff --git a/examples/rpc-server/src/index.ts b/examples/rpc-server/src/index.ts index 10f4e1be02db..d2ab69c94b6f 100644 --- a/examples/rpc-server/src/index.ts +++ b/examples/rpc-server/src/index.ts @@ -3,8 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {MyApplication} from './application'; -import {ApplicationConfig} from '@loopback/core'; +import {ApplicationConfig, MyApplication} from './application'; + +export * from './application'; export async function main(options: ApplicationConfig = {}) { const app = new MyApplication(options); @@ -13,3 +14,11 @@ export async function main(options: ApplicationConfig = {}) { console.log(`Server is running on port ${app.options.port}`); return app; } + +if (require.main === module) { + // Run the application + main().catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/soap-calculator/index.d.ts b/examples/soap-calculator/index.d.ts deleted file mode 100644 index 8c05a3838ec0..000000000000 --- a/examples/soap-calculator/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-soap-calculator -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/soap-calculator/index.js b/examples/soap-calculator/index.js deleted file mode 100644 index 09a182abbefb..000000000000 --- a/examples/soap-calculator/index.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-soap-calculator -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/soap-calculator/index.ts b/examples/soap-calculator/index.ts deleted file mode 100644 index a98dbd84e821..000000000000 --- a/examples/soap-calculator/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-soap-calculator -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/soap-calculator/package.json b/examples/soap-calculator/package.json index 473b5786c522..e79c27afbbbb 100644 --- a/examples/soap-calculator/package.json +++ b/examples/soap-calculator/package.json @@ -2,6 +2,8 @@ "name": "@loopback/example-soap-calculator", "version": "2.1.1", "description": "Integrate a SOAP webservice with LoopBack 4", + "main": "dist/index.js", + "types": "dist/index.d.ts", "keywords": [ "loopback", "LoopBack", @@ -9,7 +11,6 @@ "tutorial", "soap" ], - "main": "index.js", "engines": { "node": ">=8" }, diff --git a/examples/soap-calculator/src/application.ts b/examples/soap-calculator/src/application.ts index ed4dd2791f03..77648f1cf7e9 100644 --- a/examples/soap-calculator/src/application.ts +++ b/examples/soap-calculator/src/application.ts @@ -12,6 +12,8 @@ import {ServiceMixin} from '@loopback/service-proxy'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class SoapCalculatorApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { diff --git a/examples/soap-calculator/src/index.ts b/examples/soap-calculator/src/index.ts index f9f75b8abb9c..bfa5280d0f64 100644 --- a/examples/soap-calculator/src/index.ts +++ b/examples/soap-calculator/src/index.ts @@ -3,10 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {SoapCalculatorApplication} from './application'; -import {ApplicationConfig} from '@loopback/core'; +import {ApplicationConfig, SoapCalculatorApplication} from './application'; -export {SoapCalculatorApplication}; +export * from './application'; export async function main(options: ApplicationConfig = {}) { const app = new SoapCalculatorApplication(options); @@ -17,3 +16,21 @@ export async function main(options: ApplicationConfig = {}) { console.log(`Server is running at ${url}`); return app; } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/todo-list/index.d.ts b/examples/todo-list/index.d.ts deleted file mode 100644 index bdecdb7933a9..000000000000 --- a/examples/todo-list/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-todo-list -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/todo-list/index.js b/examples/todo-list/index.js deleted file mode 100644 index 13891c3f99d4..000000000000 --- a/examples/todo-list/index.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-todo-list -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/todo-list/index.ts b/examples/todo-list/index.ts deleted file mode 100644 index b2f746975202..000000000000 --- a/examples/todo-list/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-todo-list -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/todo-list/package.json b/examples/todo-list/package.json index d911fa5162ec..4cc3beb42507 100644 --- a/examples/todo-list/package.json +++ b/examples/todo-list/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-todo-list", "version": "3.1.1", "description": "Continuation of the todo example using relations in LoopBack 4.", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/todo-list/src/application.ts b/examples/todo-list/src/application.ts index bc082e7301cc..ee288ea90792 100644 --- a/examples/todo-list/src/application.ts +++ b/examples/todo-list/src/application.ts @@ -11,6 +11,8 @@ import {RestExplorerComponent} from '@loopback/rest-explorer'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class TodoListApplication extends BootMixin( RepositoryMixin(RestApplication), ) { diff --git a/examples/todo-list/src/index.ts b/examples/todo-list/src/index.ts index 6683b3f4c20e..20bfd5c4ca00 100644 --- a/examples/todo-list/src/index.ts +++ b/examples/todo-list/src/index.ts @@ -3,10 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {TodoListApplication} from './application'; -import {ApplicationConfig} from '@loopback/core'; +import {ApplicationConfig, TodoListApplication} from './application'; -export {TodoListApplication}; +export * from './application'; export async function main(options: ApplicationConfig = {}) { const app = new TodoListApplication(options); @@ -17,3 +16,21 @@ export async function main(options: ApplicationConfig = {}) { console.log(`Server is running at ${url}`); return app; } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/examples/todo/index.d.ts b/examples/todo/index.d.ts deleted file mode 100644 index eaf95721e5bc..000000000000 --- a/examples/todo/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-todo -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/examples/todo/index.js b/examples/todo/index.js deleted file mode 100644 index ff708c20e944..000000000000 --- a/examples/todo/index.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-todo -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +process.env.PORT || 3000, - host: process.env.HOST || 'localhost', - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/todo/index.ts b/examples/todo/index.ts deleted file mode 100644 index 43fc28739bf4..000000000000 --- a/examples/todo/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/example-todo -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/examples/todo/package.json b/examples/todo/package.json index 818313983177..de781e166eb0 100644 --- a/examples/todo/package.json +++ b/examples/todo/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-todo", "version": "3.3.0", "description": "Tutorial example on how to build an application with LoopBack 4.", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/todo/src/application.ts b/examples/todo/src/application.ts index eb883fc2246e..5d76d43c8e2f 100644 --- a/examples/todo/src/application.ts +++ b/examples/todo/src/application.ts @@ -13,6 +13,8 @@ import morgan from 'morgan'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class TodoListApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { diff --git a/examples/todo/src/index.ts b/examples/todo/src/index.ts index 55ab9c61c738..9df408130d72 100644 --- a/examples/todo/src/index.ts +++ b/examples/todo/src/index.ts @@ -3,8 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {TodoListApplication} from './application'; -import {ApplicationConfig} from '@loopback/core'; +import {ApplicationConfig, TodoListApplication} from './application'; export async function main(options: ApplicationConfig = {}) { const app = new TodoListApplication(options); @@ -16,9 +15,26 @@ export async function main(options: ApplicationConfig = {}) { return app; } -// re-exports for our benchmark, not needed for the tutorial itself -export {TodoListApplication}; +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST ?? 'localhost', + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} +// re-exports for our benchmark, not needed for the tutorial itself +export * from '@loopback/rest'; +export * from './application'; export * from './models'; export * from './repositories'; -export * from '@loopback/rest'; diff --git a/examples/validation-app/index.js b/examples/validation-app/index.js deleted file mode 100644 index 772ff978a36a..000000000000 --- a/examples/validation-app/index.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-validation-app -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +(process.env.PORT || 3000), - host: process.env.HOST, - // The `gracePeriodForClose` provides a graceful close for http/https - // servers with keep-alive clients. The default value is `Infinity` - // (don't force-close). If you want to immediately destroy all sockets - // upon stop, set its value to `0`. - // See https://www.npmjs.com/package/stoppable - gracePeriodForClose: 5000, // 5 seconds - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/examples/validation-app/index.ts b/examples/validation-app/index.ts deleted file mode 100644 index d2a2d613fcbd..000000000000 --- a/examples/validation-app/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/example-validation-app -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/examples/validation-app/package.json b/examples/validation-app/package.json index 9870ce194d1d..d18e91678b5f 100644 --- a/examples/validation-app/package.json +++ b/examples/validation-app/package.json @@ -2,7 +2,8 @@ "name": "@loopback/example-validation-app", "version": "1.3.1", "description": "LoopBack 4 application with validation examples", - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, diff --git a/examples/validation-app/src/application.ts b/examples/validation-app/src/application.ts index aa171e48921b..bcf0ead152a6 100644 --- a/examples/validation-app/src/application.ts +++ b/examples/validation-app/src/application.ts @@ -15,6 +15,8 @@ import {ServiceMixin} from '@loopback/service-proxy'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class ValidationApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { diff --git a/examples/validation-app/src/index.ts b/examples/validation-app/src/index.ts index 731343dbe884..4f4d8c229b84 100644 --- a/examples/validation-app/src/index.ts +++ b/examples/validation-app/src/index.ts @@ -3,10 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ApplicationConfig} from '@loopback/core'; -import {ValidationApplication} from './application'; +import {ApplicationConfig, ValidationApplication} from './application'; -export {ValidationApplication}; +export * from './application'; export async function main(options: ApplicationConfig = {}) { const app = new ValidationApplication(options); @@ -18,3 +17,27 @@ export async function main(options: ApplicationConfig = {}) { return app; } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST, + // The `gracePeriodForClose` provides a graceful close for http/https + // servers with keep-alive clients. The default value is `Infinity` + // (don't force-close). If you want to immediately destroy all sockets + // upon stop, set its value to `0`. + // See https://www.npmjs.com/package/stoppable + gracePeriodForClose: 5000, // 5 seconds + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/extensions/apiconnect/index.d.ts b/extensions/apiconnect/index.d.ts deleted file mode 100644 index 6d1e5f25950f..000000000000 --- a/extensions/apiconnect/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/apiconnect -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/extensions/apiconnect/index.js b/extensions/apiconnect/index.js deleted file mode 100644 index 7a68a0b4da28..000000000000 --- a/extensions/apiconnect/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/apiconnect -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/extensions/apiconnect/index.ts b/extensions/apiconnect/index.ts deleted file mode 100644 index 7b10624b4b5b..000000000000 --- a/extensions/apiconnect/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/apiconnect -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/extensions/apiconnect/package.json b/extensions/apiconnect/package.json index 2fa10e06fbbc..95e100b37679 100644 --- a/extensions/apiconnect/package.json +++ b/extensions/apiconnect/package.json @@ -2,6 +2,8 @@ "name": "@loopback/apiconnect", "version": "0.3.1", "description": "An extension for IBM API Connect", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -24,8 +26,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/extensions/authentication-jwt/index.d.ts b/extensions/authentication-jwt/index.d.ts deleted file mode 100644 index be9c118cb369..000000000000 --- a/extensions/authentication-jwt/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/authentication-jwt -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/extensions/authentication-jwt/index.js b/extensions/authentication-jwt/index.js deleted file mode 100644 index 337c50f903f1..000000000000 --- a/extensions/authentication-jwt/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/authentication-jwt -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/extensions/authentication-jwt/index.ts b/extensions/authentication-jwt/index.ts deleted file mode 100644 index 7a6eb2261184..000000000000 --- a/extensions/authentication-jwt/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/authentication-jwt -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/extensions/authentication-jwt/package.json b/extensions/authentication-jwt/package.json index f931673b39af..6d2c8a941658 100644 --- a/extensions/authentication-jwt/package.json +++ b/extensions/authentication-jwt/package.json @@ -2,6 +2,8 @@ "name": "@loopback/authentication-jwt", "version": "0.2.1", "description": "Extension for the prototype of JWT authentication", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -45,8 +47,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/extensions/authentication-passport/index.d.ts b/extensions/authentication-passport/index.d.ts deleted file mode 100644 index 0c015b0b0de4..000000000000 --- a/extensions/authentication-passport/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/authentication-passport -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/extensions/authentication-passport/index.js b/extensions/authentication-passport/index.js deleted file mode 100644 index 33273f1eee86..000000000000 --- a/extensions/authentication-passport/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/authentication-passport -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/extensions/authentication-passport/index.ts b/extensions/authentication-passport/index.ts deleted file mode 100644 index 18189454f60c..000000000000 --- a/extensions/authentication-passport/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/authentication-passport -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/extensions/authentication-passport/package.json b/extensions/authentication-passport/package.json index dbad16aca80b..2d7779c76d73 100644 --- a/extensions/authentication-passport/package.json +++ b/extensions/authentication-passport/package.json @@ -2,6 +2,8 @@ "name": "@loopback/authentication-passport", "version": "2.1.3", "description": "A package creating adapters between the passport module and @loopback/authentication", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -25,8 +27,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/extensions/context-explorer/index.d.ts b/extensions/context-explorer/index.d.ts deleted file mode 100644 index 4534aeb95a0d..000000000000 --- a/extensions/context-explorer/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/context-explorer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/extensions/context-explorer/index.js b/extensions/context-explorer/index.js deleted file mode 100644 index 535f888d1f24..000000000000 --- a/extensions/context-explorer/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/context-explorer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/extensions/context-explorer/index.ts b/extensions/context-explorer/index.ts deleted file mode 100644 index d5150c2f76be..000000000000 --- a/extensions/context-explorer/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/context-explorer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/extensions/context-explorer/package.json b/extensions/context-explorer/package.json index 35ef6d65db05..0e8010c495cf 100644 --- a/extensions/context-explorer/package.json +++ b/extensions/context-explorer/package.json @@ -2,6 +2,8 @@ "name": "@loopback/context-explorer", "version": "0.1.3", "description": "LoopBack's Context/Binding Explorer", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -36,8 +38,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__", diff --git a/extensions/cron/index.d.ts b/extensions/cron/index.d.ts deleted file mode 100644 index fd847054e25b..000000000000 --- a/extensions/cron/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/cron -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/extensions/cron/index.js b/extensions/cron/index.js deleted file mode 100644 index 495a41995207..000000000000 --- a/extensions/cron/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/cron -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/extensions/cron/index.ts b/extensions/cron/index.ts deleted file mode 100644 index 602a833a092f..000000000000 --- a/extensions/cron/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/cron -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/extensions/cron/package.json b/extensions/cron/package.json index 2456206a0d51..a1a090418bf7 100644 --- a/extensions/cron/package.json +++ b/extensions/cron/package.json @@ -2,6 +2,8 @@ "name": "@loopback/cron", "version": "0.2.3", "description": "LoopBack Cron Integration", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -36,8 +38,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/extensions/health/index.d.ts b/extensions/health/index.d.ts deleted file mode 100644 index 32733e892d9b..000000000000 --- a/extensions/health/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/extension-health -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/extensions/health/index.js b/extensions/health/index.js deleted file mode 100644 index edfea480527e..000000000000 --- a/extensions/health/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/extension-health -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/extensions/health/index.ts b/extensions/health/index.ts deleted file mode 100644 index 217ffb985feb..000000000000 --- a/extensions/health/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/extension-health -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/extensions/health/package.json b/extensions/health/package.json index 89d21bf101c0..50cf7b791667 100644 --- a/extensions/health/package.json +++ b/extensions/health/package.json @@ -2,6 +2,8 @@ "name": "@loopback/extension-health", "version": "0.4.3", "description": "LoopBack Health", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -35,8 +37,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/extensions/logging/index.d.ts b/extensions/logging/index.d.ts deleted file mode 100644 index d399a659f439..000000000000 --- a/extensions/logging/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/extension-logging -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/extensions/logging/index.js b/extensions/logging/index.js deleted file mode 100644 index 5b57f4878e57..000000000000 --- a/extensions/logging/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/extension-logging -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/extensions/logging/index.ts b/extensions/logging/index.ts deleted file mode 100644 index cf8ec779d223..000000000000 --- a/extensions/logging/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/extension-logging -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/extensions/logging/package.json b/extensions/logging/package.json index d44d48ec4b07..e2ab4d40cc8d 100644 --- a/extensions/logging/package.json +++ b/extensions/logging/package.json @@ -2,6 +2,8 @@ "name": "@loopback/extension-logging", "version": "0.3.3", "description": "LoopBack Logging for Winston and Fluentd", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -41,8 +43,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__", diff --git a/extensions/metrics/index.d.ts b/extensions/metrics/index.d.ts deleted file mode 100644 index c44da3cb1d77..000000000000 --- a/extensions/metrics/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/extension-metrics -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/extensions/metrics/index.js b/extensions/metrics/index.js deleted file mode 100644 index 368652de64a5..000000000000 --- a/extensions/metrics/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/extension-metrics -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/extensions/metrics/index.ts b/extensions/metrics/index.ts deleted file mode 100644 index c2d70ccb419b..000000000000 --- a/extensions/metrics/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/extension-metrics -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/extensions/metrics/package.json b/extensions/metrics/package.json index 38ae300e7567..f8b3f3164a57 100644 --- a/extensions/metrics/package.json +++ b/extensions/metrics/package.json @@ -2,6 +2,8 @@ "name": "@loopback/extension-metrics", "version": "0.3.3", "description": "LoopBack Metrics for Prometheus", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -38,8 +40,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__", diff --git a/packages/authentication/index.d.ts b/packages/authentication/index.d.ts deleted file mode 100644 index e8ea7860db05..000000000000 --- a/packages/authentication/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/authentication -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/authentication/index.js b/packages/authentication/index.js deleted file mode 100644 index cd14afa5645f..000000000000 --- a/packages/authentication/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/authentication -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/authentication/index.ts b/packages/authentication/index.ts deleted file mode 100644 index 2b90fa9c0160..000000000000 --- a/packages/authentication/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/authentication -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/authentication/package.json b/packages/authentication/package.json index 39aa591a38f0..178853752633 100644 --- a/packages/authentication/package.json +++ b/packages/authentication/package.json @@ -2,6 +2,8 @@ "name": "@loopback/authentication", "version": "4.2.3", "description": "A LoopBack component for authentication support.", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -44,8 +46,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/authorization/index.d.ts b/packages/authorization/index.d.ts deleted file mode 100644 index 3b335d0c917d..000000000000 --- a/packages/authorization/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/authorization -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/authorization/index.js b/packages/authorization/index.js deleted file mode 100644 index dd51df8ff984..000000000000 --- a/packages/authorization/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/authorization -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/authorization/index.ts b/packages/authorization/index.ts deleted file mode 100644 index 2982c147f1a4..000000000000 --- a/packages/authorization/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/authorization -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/authorization/package.json b/packages/authorization/package.json index ee66dd24458e..2bdad7556711 100644 --- a/packages/authorization/package.json +++ b/packages/authorization/package.json @@ -2,6 +2,8 @@ "name": "@loopback/authorization", "version": "0.5.8", "description": "A LoopBack component for authorization support.", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -41,8 +43,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__", diff --git a/packages/boot/index.d.ts b/packages/boot/index.d.ts deleted file mode 100644 index 26ebc618a084..000000000000 --- a/packages/boot/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/boot -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/boot/index.js b/packages/boot/index.js deleted file mode 100644 index 5f5eb0a767ce..000000000000 --- a/packages/boot/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/boot -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/boot/index.ts b/packages/boot/index.ts deleted file mode 100644 index 997ff4822ae8..000000000000 --- a/packages/boot/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/boot -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/packages/boot/package.json b/packages/boot/package.json index 691a48806fb8..8f2bd2caa3cc 100644 --- a/packages/boot/package.json +++ b/packages/boot/package.json @@ -2,6 +2,8 @@ "name": "@loopback/boot", "version": "2.2.0", "description": "A collection of Booters for LoopBack 4 Applications", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -44,8 +46,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/booter-lb3app/index.d.ts b/packages/booter-lb3app/index.d.ts deleted file mode 100644 index fd7dff3fd1cd..000000000000 --- a/packages/booter-lb3app/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/booter-lb3app -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/booter-lb3app/index.js b/packages/booter-lb3app/index.js deleted file mode 100644 index d90c10edc91b..000000000000 --- a/packages/booter-lb3app/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/booter-lb3app -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/booter-lb3app/index.ts b/packages/booter-lb3app/index.ts deleted file mode 100644 index 654d70723fd3..000000000000 --- a/packages/booter-lb3app/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/booter-lb3app -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/booter-lb3app/package.json b/packages/booter-lb3app/package.json index f8e5fd1fd21f..b6088eb2cf82 100644 --- a/packages/booter-lb3app/package.json +++ b/packages/booter-lb3app/package.json @@ -2,6 +2,8 @@ "name": "@loopback/booter-lb3app", "version": "2.1.3", "description": "Boot a LoopBack 3 application in a LoopBack 4 project", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -52,8 +54,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/cli/generators/app/templates/index.js.ejs b/packages/cli/generators/app/templates/index.js.ejs deleted file mode 100644 index eb51d1a90689..000000000000 --- a/packages/cli/generators/app/templates/index.js.ejs +++ /dev/null @@ -1,27 +0,0 @@ -const application = require('./dist'); - -module.exports = application; - -if (require.main === module) { - // Run the application - const config = { - rest: { - port: +(process.env.PORT || 3000), - host: process.env.HOST, - // The `gracePeriodForClose` provides a graceful close for http/https - // servers with keep-alive clients. The default value is `Infinity` - // (don't force-close). If you want to immediately destroy all sockets - // upon stop, set its value to `0`. - // See https://www.npmjs.com/package/stoppable - gracePeriodForClose: 5000, // 5 seconds - openApiSpec: { - // useful when used with OpenAPI-to-GraphQL to locate your application - setServersFromRequest: true, - }, - }, - }; - application.main(config).catch(err => { - console.error('Cannot start the application.', err); - process.exit(1); - }); -} diff --git a/packages/cli/generators/app/templates/src/application.ts.ejs b/packages/cli/generators/app/templates/src/application.ts.ejs index 75a3aa7dc639..7626e62b493b 100644 --- a/packages/cli/generators/app/templates/src/application.ts.ejs +++ b/packages/cli/generators/app/templates/src/application.ts.ejs @@ -21,6 +21,8 @@ import { import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + <% if (project.appClassWithMixins) { -%> export class <%= project.applicationName %> extends BootMixin( <%= project.appClassWithMixins %>, diff --git a/packages/cli/generators/app/templates/src/index.ts.ejs b/packages/cli/generators/app/templates/src/index.ts.ejs index 2716e90f5450..a94a69cbcfa3 100644 --- a/packages/cli/generators/app/templates/src/index.ts.ejs +++ b/packages/cli/generators/app/templates/src/index.ts.ejs @@ -1,7 +1,6 @@ -import {<%= project.applicationName %>} from './application'; -import {ApplicationConfig} from '@loopback/core'; +import {ApplicationConfig, <%= project.applicationName %>} from './application'; -export {<%= project.applicationName %>}; +export * from './application'; export async function main(options: ApplicationConfig = {}) { const app = new <%= project.applicationName %>(options); @@ -14,3 +13,27 @@ export async function main(options: ApplicationConfig = {}) { return app; } + +if (require.main === module) { + // Run the application + const config = { + rest: { + port: +(process.env.PORT ?? 3000), + host: process.env.HOST, + // The `gracePeriodForClose` provides a graceful close for http/https + // servers with keep-alive clients. The default value is `Infinity` + // (don't force-close). If you want to immediately destroy all sockets + // upon stop, set its value to `0`. + // See https://www.npmjs.com/package/stoppable + gracePeriodForClose: 5000, // 5 seconds + openApiSpec: { + // useful when used with OpenAPI-to-GraphQL to locate your application + setServersFromRequest: true, + }, + }, + }; + main(config).catch(err => { + console.error('Cannot start the application.', err); + process.exit(1); + }); +} diff --git a/packages/cli/generators/extension/templates/index.d.ts.ejs b/packages/cli/generators/extension/templates/index.d.ts.ejs deleted file mode 100644 index 5703fb5fd91d..000000000000 --- a/packages/cli/generators/extension/templates/index.d.ts.ejs +++ /dev/null @@ -1 +0,0 @@ -export * from './dist'; diff --git a/packages/cli/generators/extension/templates/index.js.ejs b/packages/cli/generators/extension/templates/index.js.ejs deleted file mode 100644 index cce6933584cd..000000000000 --- a/packages/cli/generators/extension/templates/index.js.ejs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist'); diff --git a/packages/cli/generators/project/templates/index.ts.ejs b/packages/cli/generators/project/templates/index.ts.ejs deleted file mode 100644 index 8420b1093fdb..000000000000 --- a/packages/cli/generators/project/templates/index.ts.ejs +++ /dev/null @@ -1 +0,0 @@ -export * from './src'; diff --git a/packages/cli/generators/project/templates/package.json.ejs b/packages/cli/generators/project/templates/package.json.ejs index 5dab3ea8c7cb..5ec1431ac4bb 100644 --- a/packages/cli/generators/project/templates/package.json.ejs +++ b/packages/cli/generators/project/templates/package.json.ejs @@ -6,7 +6,8 @@ "loopback-<%= project.projectType -%>", "loopback" ], - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -65,8 +66,6 @@ "license": "", "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/cli/generators/project/templates/package.plain.json.ejs b/packages/cli/generators/project/templates/package.plain.json.ejs index e95f77179b4a..16bc893846da 100644 --- a/packages/cli/generators/project/templates/package.plain.json.ejs +++ b/packages/cli/generators/project/templates/package.plain.json.ejs @@ -6,7 +6,8 @@ "loopback-<%= project.projectType -%>", "loopback" ], - "main": "index.js", + "main": "dist/index.js", + "main": "types/index.d.ts", "engines": { "node": ">=10" }, @@ -65,8 +66,6 @@ "license": "", "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/cli/snapshots/integration/generators/app.integration.snapshots.js b/packages/cli/snapshots/integration/generators/app.integration.snapshots.js index f5d7d8084f9c..52eaaa17544f 100644 --- a/packages/cli/snapshots/integration/generators/app.integration.snapshots.js +++ b/packages/cli/snapshots/integration/generators/app.integration.snapshots.js @@ -20,6 +20,8 @@ import {ServiceMixin} from '@loopback/service-proxy'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class MyAppApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { @@ -55,15 +57,27 @@ export class MyAppApplication extends BootMixin( exports[`app-generator specific files generates all the proper files 2`] = ` -const application = require('./dist'); +import {ApplicationConfig, MyAppApplication} from './application'; + +export * from './application'; -module.exports = application; +export async function main(options: ApplicationConfig = {}) { + const app = new MyAppApplication(options); + await app.boot(); + await app.start(); + + const url = app.restServer.url; + console.log(\`Server is running at \${url}\`); + console.log(\`Try \${url}/ping\`); + + return app; +} if (require.main === module) { // Run the application const config = { rest: { - port: +(process.env.PORT || 3000), + port: +(process.env.PORT ?? 3000), host: process.env.HOST, // The \`gracePeriodForClose\` provides a graceful close for http/https // servers with keep-alive clients. The default value is \`Infinity\` @@ -77,7 +91,7 @@ if (require.main === module) { }, }, }; - application.main(config).catch(err => { + main(config).catch(err => { console.error('Cannot start the application.', err); process.exit(1); }); @@ -87,27 +101,6 @@ if (require.main === module) { exports[`app-generator specific files generates all the proper files 3`] = ` -import {MyAppApplication} from './application'; -import {ApplicationConfig} from '@loopback/core'; - -export {MyAppApplication}; - -export async function main(options: ApplicationConfig = {}) { - const app = new MyAppApplication(options); - await app.boot(); - await app.start(); - - const url = app.restServer.url; - console.log(\`Server is running at \${url}\`); - console.log(\`Try \${url}/ping\`); - - return app; -} - -`; - - -exports[`app-generator specific files generates all the proper files 4`] = ` import {Request, RestBindings, get, ResponseObject} from '@loopback/rest'; import {inject} from '@loopback/context'; @@ -164,7 +157,7 @@ export class PingController { `; -exports[`app-generator specific files generates all the proper files 5`] = ` +exports[`app-generator specific files generates all the proper files 4`] = ` import {Client, expect} from '@loopback/testlab'; import {MyAppApplication} from '../..'; import {setupApplication} from './test-helper'; @@ -190,7 +183,7 @@ describe('PingController', () => { `; -exports[`app-generator specific files generates all the proper files 6`] = ` +exports[`app-generator specific files generates all the proper files 5`] = ` import {Client} from '@loopback/testlab'; import {MyAppApplication} from '../..'; import {setupApplication} from './test-helper'; @@ -226,7 +219,7 @@ describe('HomePage', () => { `; -exports[`app-generator specific files generates all the proper files 7`] = ` +exports[`app-generator specific files generates all the proper files 6`] = ` import {MyAppApplication} from '../..'; import { createRestAppClient, @@ -349,6 +342,8 @@ import { import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class MyAppApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { @@ -403,6 +398,8 @@ import {ServiceMixin} from '@loopback/service-proxy'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class MyApp extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { @@ -450,6 +447,8 @@ import {ServiceMixin} from '@loopback/service-proxy'; import path from 'path'; import {MySequence} from './sequence'; +export {ApplicationConfig}; + export class MyApp extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { diff --git a/packages/cli/test/acceptance/app-run.acceptance.js b/packages/cli/test/acceptance/app-run.acceptance.js index 07587f48fe55..d5667948fb9f 100644 --- a/packages/cli/test/acceptance/app-run.acceptance.js +++ b/packages/cli/test/acceptance/app-run.acceptance.js @@ -92,7 +92,11 @@ yarnTest('app-generator with Yarn (SLOW)', () => { .run(appGenerator) .inDir(appProps.outdir) // Mark it private to prevent accidental npm publication - .withOptions({packageManager: 'yarn', private: true}) + .withOptions({ + applicationName: 'YarnApp', + packageManager: 'yarn', + private: true, + }) .withPrompts(appProps); }); diff --git a/packages/cli/test/integration/generators/app.integration.js b/packages/cli/test/integration/generators/app.integration.js index b39d95b5c4b2..619b09c886bf 100644 --- a/packages/cli/test/integration/generators/app.integration.js +++ b/packages/cli/test/integration/generators/app.integration.js @@ -42,7 +42,6 @@ describe('app-generator specific files', () => { assertFilesToMatchSnapshot( {}, 'src/application.ts', - 'index.js', 'src/index.ts', 'src/controllers/ping.controller.ts', 'src/__tests__/acceptance/ping.controller.acceptance.ts', diff --git a/packages/cli/test/integration/lib/project-generator.js b/packages/cli/test/integration/lib/project-generator.js index 2d5be3522030..79dfba1159dd 100644 --- a/packages/cli/test/integration/lib/project-generator.js +++ b/packages/cli/test/integration/lib/project-generator.js @@ -365,7 +365,6 @@ module.exports = function (projGenerator, props, projectType) { ['.eslintrc.js', "extends: '@loopback/eslint-config'"], ['tsconfig.json', '"compilerOptions"'], ['tsconfig.json', '"resolveJsonModule": true'], - ['index.js', "require('./dist')"], ]); }); }); diff --git a/packages/context/index.d.ts b/packages/context/index.d.ts deleted file mode 100644 index 199e6e97960e..000000000000 --- a/packages/context/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/context/index.js b/packages/context/index.js deleted file mode 100644 index c961311bb641..000000000000 --- a/packages/context/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/context/index.ts b/packages/context/index.ts deleted file mode 100644 index c14c7dd90d20..000000000000 --- a/packages/context/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/context/package.json b/packages/context/package.json index b46620b2a246..0e5210316428 100644 --- a/packages/context/package.json +++ b/packages/context/package.json @@ -2,6 +2,8 @@ "name": "@loopback/context", "version": "3.7.0", "description": "LoopBack's container for Inversion of Control", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -45,8 +47,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts deleted file mode 100644 index c0dead640f94..000000000000 --- a/packages/core/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/core -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/core/index.js b/packages/core/index.js deleted file mode 100644 index f549e03b7f55..000000000000 --- a/packages/core/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/core -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/core/index.ts b/packages/core/index.ts deleted file mode 100644 index 24e6a76c496f..000000000000 --- a/packages/core/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/core -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/core/package.json b/packages/core/package.json index 0bf55d4d3bd9..6cb67adc22b3 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -2,6 +2,8 @@ "name": "@loopback/core", "version": "2.5.0", "description": "LoopBack 4 core", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -32,8 +34,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/express/index.d.ts b/packages/express/index.d.ts deleted file mode 100644 index c1fc0bb183b0..000000000000 --- a/packages/express/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/express -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/express/index.js b/packages/express/index.js deleted file mode 100644 index a5d74e30fe29..000000000000 --- a/packages/express/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/express -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/express/index.ts b/packages/express/index.ts deleted file mode 100644 index 362689217c3d..000000000000 --- a/packages/express/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2020. All Rights Reserved. -// Node module: @loopback/express -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/packages/express/package.json b/packages/express/package.json index af7662b41f44..a11db66384a1 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -2,11 +2,12 @@ "name": "@loopback/express", "version": "1.1.0", "description": "@loopback/express", + "main": "dist/index.js", + "types": "dist/index.d.ts", "keywords": [ "loopback-extension", "loopback" ], - "main": "index.js", "engines": { "node": ">=10" }, @@ -27,8 +28,6 @@ "license": "MIT", "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/http-caching-proxy/index.d.ts b/packages/http-caching-proxy/index.d.ts deleted file mode 100644 index 1a11468db6cd..000000000000 --- a/packages/http-caching-proxy/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/http-caching-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/http-caching-proxy/index.js b/packages/http-caching-proxy/index.js deleted file mode 100644 index 36847683f2c0..000000000000 --- a/packages/http-caching-proxy/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/http-caching-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/http-caching-proxy/index.ts b/packages/http-caching-proxy/index.ts deleted file mode 100644 index 3f44b66f0658..000000000000 --- a/packages/http-caching-proxy/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/http-caching-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/http-caching-proxy/package.json b/packages/http-caching-proxy/package.json index 90127aa80be2..d216224909fd 100644 --- a/packages/http-caching-proxy/package.json +++ b/packages/http-caching-proxy/package.json @@ -2,6 +2,8 @@ "name": "@loopback/http-caching-proxy", "version": "2.1.3", "description": "A caching HTTP proxy for integration tests. NOT SUITABLE FOR PRODUCTION USE!", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -42,8 +44,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/http-server/index.d.ts b/packages/http-server/index.d.ts deleted file mode 100644 index 933a085a57e6..000000000000 --- a/packages/http-server/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/http-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/http-server/index.js b/packages/http-server/index.js deleted file mode 100644 index 79a1789eed39..000000000000 --- a/packages/http-server/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/http-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/http-server/index.ts b/packages/http-server/index.ts deleted file mode 100644 index 556ec180413e..000000000000 --- a/packages/http-server/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/http-server -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './src'; diff --git a/packages/http-server/package.json b/packages/http-server/package.json index 0d388885c0bf..693d6d6b9816 100644 --- a/packages/http-server/package.json +++ b/packages/http-server/package.json @@ -2,6 +2,8 @@ "name": "@loopback/http-server", "version": "2.1.3", "description": "A wrapper for creating HTTP/HTTPS servers", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -29,8 +31,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/metadata/index.d.ts b/packages/metadata/index.d.ts deleted file mode 100644 index b3a664ee2082..000000000000 --- a/packages/metadata/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/metadata -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/metadata/index.js b/packages/metadata/index.js deleted file mode 100644 index 714d214bf56c..000000000000 --- a/packages/metadata/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/metadata -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/metadata/index.ts b/packages/metadata/index.ts deleted file mode 100644 index 8a9e766d7a97..000000000000 --- a/packages/metadata/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/metadata -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/metadata/package.json b/packages/metadata/package.json index e6d24d155491..76085d11a7c0 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -2,6 +2,8 @@ "name": "@loopback/metadata", "version": "2.1.3", "description": "LoopBack's metadata utilities for reflection and decoration", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -38,8 +40,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/model-api-builder/index.d.ts b/packages/model-api-builder/index.d.ts deleted file mode 100644 index 507063fc97b9..000000000000 --- a/packages/model-api-builder/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019,2020. All Rights Reserved. -// Node module: @loopback/model-api-builder -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/model-api-builder/index.js b/packages/model-api-builder/index.js deleted file mode 100644 index 714c64ef02d8..000000000000 --- a/packages/model-api-builder/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/model-api-builder -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/model-api-builder/index.ts b/packages/model-api-builder/index.ts deleted file mode 100644 index 087505382f3b..000000000000 --- a/packages/model-api-builder/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/model-api-builder -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/model-api-builder/package.json b/packages/model-api-builder/package.json index 97f6adf74664..e0e2e5b27346 100644 --- a/packages/model-api-builder/package.json +++ b/packages/model-api-builder/package.json @@ -2,10 +2,11 @@ "name": "@loopback/model-api-builder", "version": "2.1.3", "description": "Types and helpers for packages contributing Model API builders.", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, - "main": "index", "publishConfig": { "access": "public" }, @@ -31,8 +32,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/openapi-spec-builder/index.d.ts b/packages/openapi-spec-builder/index.d.ts deleted file mode 100644 index 819de13175f6..000000000000 --- a/packages/openapi-spec-builder/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/openapi-spec-builder -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/openapi-spec-builder/index.js b/packages/openapi-spec-builder/index.js deleted file mode 100644 index 5ac294aed123..000000000000 --- a/packages/openapi-spec-builder/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/openapi-spec-builder -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/openapi-spec-builder/index.ts b/packages/openapi-spec-builder/index.ts deleted file mode 100644 index 96d056d52290..000000000000 --- a/packages/openapi-spec-builder/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/openapi-spec-builder -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/openapi-spec-builder/package.json b/packages/openapi-spec-builder/package.json index 56a6d3b6f103..dd1691743f75 100644 --- a/packages/openapi-spec-builder/package.json +++ b/packages/openapi-spec-builder/package.json @@ -2,6 +2,8 @@ "name": "@loopback/openapi-spec-builder", "version": "2.1.3", "description": "Make it easy to create OpenAPI (Swagger) specification documents in your tests using the builder pattern.", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -34,8 +36,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/openapi-v3/index.d.ts b/packages/openapi-v3/index.d.ts deleted file mode 100644 index 9456fe569b2c..000000000000 --- a/packages/openapi-v3/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/openapi-v3 -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/openapi-v3/index.js b/packages/openapi-v3/index.js deleted file mode 100644 index 8ac77c086879..000000000000 --- a/packages/openapi-v3/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/openapi-v3 -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/openapi-v3/index.ts b/packages/openapi-v3/index.ts deleted file mode 100644 index c36f502c4040..000000000000 --- a/packages/openapi-v3/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/openapi-v3 -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/openapi-v3/package.json b/packages/openapi-v3/package.json index c388145ddfb8..42249af210b5 100644 --- a/packages/openapi-v3/package.json +++ b/packages/openapi-v3/package.json @@ -2,6 +2,8 @@ "name": "@loopback/openapi-v3", "version": "3.3.1", "description": "Processes openapi v3 related metadata", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -46,8 +48,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/repository-json-schema/index.d.ts b/packages/repository-json-schema/index.d.ts deleted file mode 100644 index 7d9ed70b4fca..000000000000 --- a/packages/repository-json-schema/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/repository-json-schema -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/repository-json-schema/index.js b/packages/repository-json-schema/index.js deleted file mode 100644 index a4d50290a5bf..000000000000 --- a/packages/repository-json-schema/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/repository-json-schema -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/repository-json-schema/index.ts b/packages/repository-json-schema/index.ts deleted file mode 100644 index 9d9305092f6f..000000000000 --- a/packages/repository-json-schema/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/repository-json-schema -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/repository-json-schema/package.json b/packages/repository-json-schema/package.json index 092f23f8dd57..1de6746320f8 100644 --- a/packages/repository-json-schema/package.json +++ b/packages/repository-json-schema/package.json @@ -2,6 +2,8 @@ "name": "@loopback/repository-json-schema", "version": "2.4.0", "description": "Converts TS classes into JSON Schemas using TypeScript's reflection API", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -40,8 +42,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/repository-tests/index.d.ts b/packages/repository-tests/index.d.ts deleted file mode 100644 index 1d827438989f..000000000000 --- a/packages/repository-tests/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/repository-tests -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/repository-tests/index.js b/packages/repository-tests/index.js deleted file mode 100644 index c1c89a9847d5..000000000000 --- a/packages/repository-tests/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/repository-tests -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/repository-tests/index.ts b/packages/repository-tests/index.ts deleted file mode 100644 index 26f5a91e410f..000000000000 --- a/packages/repository-tests/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/repository-tests -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/repository-tests/package.json b/packages/repository-tests/package.json index c676f98545bb..54e5596a98ad 100644 --- a/packages/repository-tests/package.json +++ b/packages/repository-tests/package.json @@ -2,10 +2,11 @@ "name": "@loopback/repository-tests", "version": "0.12.3", "description": "Shared test-suite for repository based persistence", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, - "main": "index", "publishConfig": { "access": "public" }, @@ -39,8 +40,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/repository/index.d.ts b/packages/repository/index.d.ts deleted file mode 100644 index 6963b5847439..000000000000 --- a/packages/repository/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/repository -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/repository/index.js b/packages/repository/index.js deleted file mode 100644 index f439827354c7..000000000000 --- a/packages/repository/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/repository -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/repository/index.ts b/packages/repository/index.ts deleted file mode 100644 index 2fe2270b8087..000000000000 --- a/packages/repository/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/repository -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/repository/package.json b/packages/repository/package.json index 04fa57cb49c7..f88274aded9b 100644 --- a/packages/repository/package.json +++ b/packages/repository/package.json @@ -2,10 +2,11 @@ "name": "@loopback/repository", "version": "2.4.0", "description": "Repository based persistence for LoopBack 4", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, - "main": "index", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build": "lb-tsc", @@ -38,8 +39,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/rest-crud/index.d.ts b/packages/rest-crud/index.d.ts deleted file mode 100644 index 16a78c799d05..000000000000 --- a/packages/rest-crud/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/rest-crud -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/rest-crud/index.js b/packages/rest-crud/index.js deleted file mode 100644 index 34522ca3d822..000000000000 --- a/packages/rest-crud/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/rest-crud -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/rest-crud/index.ts b/packages/rest-crud/index.ts deleted file mode 100644 index 79a2f7730544..000000000000 --- a/packages/rest-crud/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/rest-crud -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/rest-crud/package.json b/packages/rest-crud/package.json index c5e04ea5da97..c7c2fee559de 100644 --- a/packages/rest-crud/package.json +++ b/packages/rest-crud/package.json @@ -2,10 +2,11 @@ "name": "@loopback/rest-crud", "version": "0.8.3", "description": "REST API controller implementing default CRUD semantics", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, - "main": "index", "publishConfig": { "access": "public" }, @@ -40,8 +41,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/rest-explorer/index.d.ts b/packages/rest-explorer/index.d.ts deleted file mode 100644 index c8f42fd5a99f..000000000000 --- a/packages/rest-explorer/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/rest-explorer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/rest-explorer/index.js b/packages/rest-explorer/index.js deleted file mode 100644 index 91ba1ee68499..000000000000 --- a/packages/rest-explorer/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/rest-explorer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/rest-explorer/index.ts b/packages/rest-explorer/index.ts deleted file mode 100644 index 01f8393cb1be..000000000000 --- a/packages/rest-explorer/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/rest-explorer -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/rest-explorer/package.json b/packages/rest-explorer/package.json index e238d1f44e14..bad2785b7da4 100644 --- a/packages/rest-explorer/package.json +++ b/packages/rest-explorer/package.json @@ -2,6 +2,8 @@ "name": "@loopback/rest-explorer", "version": "2.2.0", "description": "LoopBack's API Explorer", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -39,8 +41,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__", diff --git a/packages/rest/index.d.ts b/packages/rest/index.d.ts deleted file mode 100644 index 447a0428faee..000000000000 --- a/packages/rest/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/rest -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/rest/index.js b/packages/rest/index.js deleted file mode 100644 index 8f9e5d00f091..000000000000 --- a/packages/rest/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/rest -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/rest/index.ts b/packages/rest/index.ts deleted file mode 100644 index 64219494453f..000000000000 --- a/packages/rest/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/rest -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/rest/package.json b/packages/rest/package.json index 1a4cf6bd7814..539de88a359b 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -2,6 +2,8 @@ "name": "@loopback/rest", "version": "4.0.0", "description": "", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -70,8 +72,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/security/index.d.ts b/packages/security/index.d.ts deleted file mode 100644 index c8a3fb25a18d..000000000000 --- a/packages/security/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/security -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/security/index.js b/packages/security/index.js deleted file mode 100644 index 4039d85f3486..000000000000 --- a/packages/security/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/security -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/security/index.ts b/packages/security/index.ts deleted file mode 100644 index 3c987a89de2c..000000000000 --- a/packages/security/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2019. All Rights Reserved. -// Node module: @loopback/security -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/security/package.json b/packages/security/package.json index bfb4606e5908..1ee7f5442dd4 100644 --- a/packages/security/package.json +++ b/packages/security/package.json @@ -2,6 +2,8 @@ "name": "@loopback/security", "version": "0.2.8", "description": "A LoopBack component for security support.", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -39,8 +41,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/service-proxy/index.d.ts b/packages/service-proxy/index.d.ts deleted file mode 100644 index 4bb0eff1114a..000000000000 --- a/packages/service-proxy/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/service-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/service-proxy/index.js b/packages/service-proxy/index.js deleted file mode 100644 index ac118f181366..000000000000 --- a/packages/service-proxy/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/service-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/service-proxy/index.ts b/packages/service-proxy/index.ts deleted file mode 100644 index 9c18c7396df1..000000000000 --- a/packages/service-proxy/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/service-proxy -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/service-proxy/package.json b/packages/service-proxy/package.json index d5c1ab864798..e1d4a77265db 100644 --- a/packages/service-proxy/package.json +++ b/packages/service-proxy/package.json @@ -2,10 +2,11 @@ "name": "@loopback/service-proxy", "version": "2.2.0", "description": "Service integration for LoopBack 4", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, - "main": "index", "scripts": { "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build": "lb-tsc", @@ -36,8 +37,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__" diff --git a/packages/testlab/index.d.ts b/packages/testlab/index.d.ts deleted file mode 100644 index 7835ed02de5d..000000000000 --- a/packages/testlab/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/testlab -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/testlab/index.js b/packages/testlab/index.js deleted file mode 100644 index 9806970717e2..000000000000 --- a/packages/testlab/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/testlab -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/testlab/index.ts b/packages/testlab/index.ts deleted file mode 100644 index e48c6c34f443..000000000000 --- a/packages/testlab/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2017,2020. All Rights Reserved. -// Node module: @loopback/testlab -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/testlab/package.json b/packages/testlab/package.json index 9def10972a9a..852fc2049030 100644 --- a/packages/testlab/package.json +++ b/packages/testlab/package.json @@ -2,6 +2,8 @@ "name": "@loopback/testlab", "version": "3.1.3", "description": "A collection of test utilities we use to write LoopBack tests.", + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, @@ -37,8 +39,6 @@ }, "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "fixtures", "should-as-function.d.ts", diff --git a/packages/tsdocs/index.d.ts b/packages/tsdocs/index.d.ts deleted file mode 100644 index 9d19e83fe880..000000000000 --- a/packages/tsdocs/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/tsdocs -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -export * from './dist'; diff --git a/packages/tsdocs/index.js b/packages/tsdocs/index.js deleted file mode 100644 index 106fede7c531..000000000000 --- a/packages/tsdocs/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/tsdocs -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -module.exports = require('./dist'); diff --git a/packages/tsdocs/index.ts b/packages/tsdocs/index.ts deleted file mode 100644 index b7412ddd9d25..000000000000 --- a/packages/tsdocs/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright IBM Corp. 2018,2020. All Rights Reserved. -// Node module: @loopback/tsdocs -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -// DO NOT EDIT THIS FILE -// Add any additional (re)exports to src/index.ts instead. -export * from './src'; diff --git a/packages/tsdocs/package.json b/packages/tsdocs/package.json index 7e4004a809a2..b41a3132f8b1 100644 --- a/packages/tsdocs/package.json +++ b/packages/tsdocs/package.json @@ -2,10 +2,12 @@ "name": "@loopback/tsdocs", "version": "2.1.3", "description": "LoopBack's TypeScript docs based on Microsoft api-extractor and api-documenter", + "private": true, + "main": "dist/index.js", + "types": "dist/index.d.ts", "engines": { "node": ">=10" }, - "private": true, "scripts": { "build:tsdocs": "npm run build && npm run -s extract-apidocs && npm run -s document-apidocs && npm run -s update-apidocs", "extract-apidocs": "node bin/extract-apis", @@ -42,8 +44,6 @@ ], "files": [ "README.md", - "index.js", - "index.d.ts", "dist", "src", "!*/__tests__",