diff --git a/examples/express-composition/index.d.ts b/examples/express-composition/index.d.ts new file mode 100644 index 000000000000..f26d3eeb54c9 --- /dev/null +++ b/examples/express-composition/index.d.ts @@ -0,0 +1,6 @@ +// 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/package.json b/examples/express-composition/package.json index fa6fc3f023bd..e5b3e9e76b54 100644 --- a/examples/express-composition/package.json +++ b/examples/express-composition/package.json @@ -26,9 +26,9 @@ "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", "pretest": "npm run clean && npm run build", - "test": "lb-mocha --allow-console-logs \"dist/src/__tests__\"", + "test": "lb-mocha \"dist/__tests__/**/*.js\"", "posttest": "npm run lint", - "test:dev": "lb-mocha --allow-console-logs dist/src/__tests__/**/*.js && npm run posttest", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest", "migrate": "node ./dist/src/migrate", "prestart": "npm run build", "start": "node ." @@ -42,14 +42,6 @@ }, "author": "IBM Corp.", "license": "MIT", - "files": [ - "README.md", - "index.js", - "index.d.ts", - "dist/src", - "dist/index*", - "src" - ], "dependencies": { "@loopback/boot": "^1.0.14", "@loopback/context": "^1.6.0", diff --git a/examples/express-composition/src/__tests__/acceptance/note.acceptance.ts b/examples/express-composition/src/__tests__/acceptance/note.acceptance.ts index b3951276048a..94a04e5374ad 100644 --- a/examples/express-composition/src/__tests__/acceptance/note.acceptance.ts +++ b/examples/express-composition/src/__tests__/acceptance/note.acceptance.ts @@ -12,6 +12,7 @@ describe('NoteApplication', () => { before('setupApplication', async () => { ({server, client, lbApp} = await setupExpressApplication()); + await changeDataSourceConfig(); await givenNoteRepository(); }); @@ -57,4 +58,15 @@ describe('NoteApplication', () => { async function givenNoteRepository() { noteRepo = await lbApp.getRepository(NoteRepository); } + + async function changeDataSourceConfig() { + /** + * Override default config for DataSource for testing so we don't write + * test data to file when using the memory connector. + */ + lbApp.bind('datasources.config.ds').to({ + name: 'ds', + connector: 'memory', + }); + } }); diff --git a/examples/express-composition/src/application.ts b/examples/express-composition/src/application.ts index 0db164357c86..6ea6856082c4 100644 --- a/examples/express-composition/src/application.ts +++ b/examples/express-composition/src/application.ts @@ -25,7 +25,7 @@ export class NoteApplication extends BootMixin( this.sequence(MySequence); // Set up default home page - this.static('/', path.join(__dirname, '../../public')); + this.static('/', path.join(__dirname, '../public')); // Customize @loopback/rest-explorer configuration here this.bind(RestExplorerBindings.CONFIG).to({ diff --git a/examples/express-composition/src/server.ts b/examples/express-composition/src/server.ts index 5a7191ae0042..b407f49136e1 100644 --- a/examples/express-composition/src/server.ts +++ b/examples/express-composition/src/server.ts @@ -20,14 +20,14 @@ export class ExpressServer { // Custom Express routes this.app.get('/', function(_req: Request, res: Response) { - res.sendFile(path.resolve('public/express.html')); + res.sendFile(path.join(__dirname, '../public/express.html')); }); this.app.get('/hello', function(_req: Request, res: Response) { res.send('Hello world!'); }); // Serve static files in the public folder - this.app.use(express.static('public')); + this.app.use(express.static(path.join(__dirname, '../public'))); } public async boot() { diff --git a/examples/express-composition/tsconfig.build.json b/examples/express-composition/tsconfig.build.json index fbce60b221ef..6e15e4be4f6f 100644 --- a/examples/express-composition/tsconfig.build.json +++ b/examples/express-composition/tsconfig.build.json @@ -1,18 +1,8 @@ { "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", - "include": [ - "src", - "test", - "index.ts" - ], - "exclude": [ - "node_modules/**", - "packages/*/node_modules/**", - "**/*.d.ts" - ], "compilerOptions": { - "experimentalDecorators": true - } - + "rootDir": "src" + }, + "include": ["src"] }