-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(lb4): reorganize current tutorial materials #601
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,19 @@ children: | |
url: Installation.html | ||
output: 'web, pdf' | ||
|
||
- title: 'Getting started' | ||
url: Getting-started.html | ||
- title: 'Examples and tutorials' | ||
url: Examples-and-tutorials.html | ||
output: 'web, pdf' | ||
children: | ||
|
||
- title: 'Examples and tutorials' | ||
url: Examples-and-tutorials.html | ||
- title: 'Hello World!' | ||
url: Hello-World.html | ||
output: 'web, pdf' | ||
|
||
- title: 'Getting Started' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd actually prefer Getting Started being at the top level. That's usually the first place to look when people are starting out. |
||
url: Getting-started.html | ||
output: 'web, pdf' | ||
|
||
- title: 'Key concepts' | ||
url: Concepts.html | ||
output: 'web, pdf' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,12 @@ | ||
--- | ||
title: "Getting Started" | ||
lang: en | ||
title: 'Getting started' | ||
keywords: LoopBack 4.0, LoopBack 4 | ||
tags: | ||
layout: readme | ||
source: loopback-next | ||
file: packages/example-getting-started/README.md | ||
keywords: LoopBack, LoopBack 4 | ||
tags: [tutorial, getting-started] | ||
sidebar: lb4_sidebar | ||
permalink: /doc/en/lb4/Getting-started.html | ||
summary: Write and run a LoopBack 4 "Hello World" project in JavaScript and TypeScript. | ||
summary: The introductory tutorial for learning LoopBack 4. | ||
--- | ||
## Prerequisites | ||
|
||
Install [Node.js](https://nodejs.org/en/download/) (version 8.x.x or higher) if | ||
not already installed on your machine. | ||
|
||
## Install LoopBack 4 CLI | ||
|
||
The LoopBack 4 CLI is a command-line interface that can scaffold a project or | ||
extension with more features under development. CLI provides the fastest way to | ||
get started with a LoopBack 4 project that adheres to best practices. | ||
|
||
Install the CLI globally by running | ||
```sh | ||
npm i -g @loopback/cli | ||
``` | ||
|
||
## Create a new project | ||
|
||
The CLI tool will scaffold the project, configure TypeScript compiler and | ||
install all the required dependencies. To create a new project, run the CLI as | ||
follows and answer the prompts. | ||
```sh | ||
lb4 app | ||
``` | ||
|
||
Answer the prompts as follows: | ||
```sh | ||
? Project name: getting-started | ||
? Project description: Getting started tutorial | ||
? Project root directory: (getting-started) | ||
? Application class name: StarterApplication | ||
? Select project build settings: Enable tslint, Enable prettier, Enable mocha, Enable loopbackBuild | ||
``` | ||
|
||
### Starting the project | ||
|
||
The project comes with a "ping" route to test the project. Let's try it out by running the project. | ||
```sh | ||
cd getting-started | ||
npm start | ||
``` | ||
|
||
In a browser, visit [http://127.0.0.1:3000/ping](http://127.0.0.1:3000/ping). | ||
|
||
## Adding your own controller | ||
|
||
Now that we have a basic project created, it's time to add our own [controller](Controllers.html). | ||
Let's add a simple "Hello World" controller as follows: | ||
|
||
* Create a new file in `/src/controllers/` called `hello.controller.ts`. | ||
|
||
* Paste the following contents into the file: | ||
```ts | ||
import {get} from '@loopback/rest'; | ||
|
||
export class HelloController { | ||
@get('/hello') | ||
hello(): string { | ||
return 'Hello world!'; | ||
} | ||
} | ||
``` | ||
|
||
* Update `/src/application.ts` to load the controller: | ||
* Import `HelloController` at the top of the file | ||
```ts | ||
import {HelloController} from './controllers/hello.controller'; | ||
``` | ||
|
||
* Add controller in `setupControllers()` | ||
```ts | ||
setupControllers() { | ||
this.controller(PingController); | ||
this.controller(HelloController); | ||
} | ||
``` | ||
|
||
* Start the application using `npm start`. | ||
* *Note: If your application is still running, press **CTRL+C** to stop it before restarting it* | ||
|
||
* Visit [http://127.0.0.1:3000/hello](http://127.0.0.1:3000/hello) to see `Hello world!` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
lang: en | ||
title: 'Hello World!' | ||
keywords: LoopBack 4.0, LoopBack 4 | ||
tags: | ||
sidebar: lb4_sidebar | ||
permalink: /doc/en/lb4/Hello-World.html | ||
summary: Write and run a LoopBack 4 "Hello World" project in JavaScript and TypeScript. | ||
--- | ||
|
||
## Prerequisites | ||
|
||
Install [Node.js](https://nodejs.org/en/download/) (version 8.x.x or higher) if | ||
not already installed on your machine. | ||
|
||
## Install LoopBack 4 CLI | ||
|
||
The LoopBack 4 CLI is a command-line interface that can scaffold a project or | ||
extension with more features under development. CLI provides the fastest way to | ||
get started with a LoopBack 4 project that adheres to best practices. | ||
|
||
Install the CLI globally by running | ||
|
||
```sh | ||
npm i -g @loopback/cli | ||
``` | ||
|
||
## Create a new project | ||
|
||
The CLI tool will scaffold the project, configure TypeScript compiler and | ||
install all the required dependencies. To create a new project, run the CLI as | ||
follows and answer the prompts. | ||
|
||
```sh | ||
lb4 app | ||
``` | ||
|
||
Answer the prompts as follows: | ||
|
||
```sh | ||
? Project name: hello-world | ||
? Project description: A Hello World app! | ||
? Project root directory: (hello-world) | ||
? Application class name: StarterApplication | ||
? Select project build settings: Enable tslint, Enable prettier, Enable mocha, Enable loopbackBuild | ||
``` | ||
|
||
### Starting the project | ||
|
||
The project comes with a "ping" route to test the project. Let's try it out by running the project. | ||
|
||
```sh | ||
cd hello-world | ||
npm start | ||
``` | ||
|
||
In a browser, visit [http://127.0.0.1:3000/ping](http://127.0.0.1:3000/ping). | ||
|
||
## Adding your own controller | ||
|
||
Now that we have a basic project created, it's time to add our own [controller](Controllers.html). | ||
Let's add a simple "Hello World" controller as follows: | ||
|
||
* Create a new file in `/src/controllers/` called `hello.controller.ts`. | ||
|
||
* Paste the following contents into the file: | ||
|
||
```ts | ||
import { get } from '@loopback/rest'; | ||
|
||
export class HelloController { | ||
@get('/hello') | ||
hello(): string { | ||
return 'Hello world!'; | ||
} | ||
} | ||
``` | ||
|
||
* Update `/src/application.ts` to load the controller: | ||
|
||
* Import `HelloController` at the top of the file | ||
|
||
```ts | ||
import { HelloController } from './controllers/hello.controller'; | ||
``` | ||
|
||
* Add controller in `setupControllers()` | ||
```ts | ||
setupControllers() { | ||
this.controller(PingController); | ||
this.controller(HelloController); | ||
} | ||
``` | ||
|
||
* Start the application using `npm start`. | ||
|
||
* _Note: If your application is still running, press **CTRL+C** to stop it before restarting it_ | ||
|
||
* Visit [http://127.0.0.1:3000/hello](http://127.0.0.1:3000/hello) to see `Hello world!` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we removing the Getting Started? I kind of like it though.
The garden path tutorial might be able to guide people through. But the Getting Started can at least quickly show what LB can do?
Not sure what you're planning for the tutorial. If it's simple enough for people to "Get started", i'm good with removing the getting started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to keeping Getting started as the page describing the process of ensure Node 8 + TypeScript is installed (does this need to be installed?), installing the CLI, and creating an app (Just show the built-in
ping controller
). A bare bones, I made a thing with LB4.Tutorial imo then should go into a more complex app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the Getting Started page can / should fold in the installation page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah. just realize @virkt25 has the same comment! :)
see loopbackio/loopback-next#1004