Skip to content

Commit

Permalink
fixup! update docs
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <[email protected]>
  • Loading branch information
bajtos committed May 18, 2020
1 parent a83e776 commit 834d6cd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 34 deletions.
6 changes: 3 additions & 3 deletions docs/site/deployment/Deploying-with-pm2-and-nginx.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
24 changes: 8 additions & 16 deletions docs/site/express-with-lb4-rest-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -255,32 +256,23 @@ 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);
await server.boot();
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,
Expand All @@ -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);
});
Expand Down
4 changes: 0 additions & 4 deletions docs/site/tutorials/todo/todo-tutorial-scaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ node_modules/
***
LICENSE
README.md
index.js
index.ts
package.json
tsconfig.json
.eslintrc.js
Expand All @@ -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) |
Expand Down
2 changes: 2 additions & 0 deletions examples/express-composition/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
) {
Expand Down
3 changes: 1 addition & 2 deletions examples/express-composition/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
// 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};

Expand Down
16 changes: 7 additions & 9 deletions examples/lb3-application/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down

0 comments on commit 834d6cd

Please sign in to comment.