Skip to content

Commit

Permalink
build: include express-composition example in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nabdelgadir committed Mar 8, 2019
1 parent d0fb755 commit ed6f32c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions examples/express-composition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('NoteApplication', () => {

before('setupApplication', async () => {
({server, client, lbApp} = await setupExpressApplication());
await changeDataSourceConfig();
await givenNoteRepository();
});

Expand Down Expand Up @@ -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',
});
}
});
2 changes: 1 addition & 1 deletion examples/express-composition/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions examples/express-composition/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
16 changes: 3 additions & 13 deletions examples/express-composition/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -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"]
}

0 comments on commit ed6f32c

Please sign in to comment.