Skip to content

Commit 0675afa

Browse files
committed
fix(docs): updates to docs sidebar
Signed-off-by: dhmlau <dhmlau@ca.ibm.com>
1 parent f06ab75 commit 0675afa

5 files changed

Lines changed: 159 additions & 122 deletions

File tree

docs/bin/build-preview-site.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ mkdir $JEKYLL_DIR/pages
6363
(TARGET="$PWD/$JEKYLL_DIR/pages" && cd "$PWD/site" && pax -rwlpe . $TARGET)
6464

6565
echo "Copying external README pages"
66+
mkdir -p $JEKYLL_DIR/_includes/readmes
6667
cp $SOURCE_DIR/pages/en/lb4/readmes/*.md $JEKYLL_DIR/pages/readmes/
68+
cp $SOURCE_DIR/pages/en/lb4/readmes/*.md $JEKYLL_DIR/_includes/readmes/
6769

6870
echo "Setting up sidebar(s)"
6971
rm -rf $JEKYLL_DIR/_data/sidebars
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
lang: en
3+
title: 'Create your first app'
4+
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
5+
sidebar: lb4_sidebar
6+
permalink: /doc/en/lb4/Create-your-first-app.html
7+
summary: Write and run a LoopBack 4 "Hello World" project in TypeScript.
8+
---
9+
10+
## Create Your First App
11+
12+
### Create a new project
13+
14+
The LoopBack 4 CLI scaffolds a new project by setting up the project structure,
15+
configuring the TypeScript, and installing required dependencies.
16+
17+
To create a new project, run the following command and follow the prompts:
18+
19+
```sh
20+
lb4 app
21+
```
22+
23+
Provide the following inputs when prompted:
24+
25+
```sh
26+
? Project name: getting-started
27+
? Project description: Getting started tutorial
28+
? Project root directory: getting-started
29+
? Application class name: StarterApplication
30+
? Select features to enable in the project:
31+
❯◉ Enable eslint: add a linter with pre-configured lint rules
32+
◉ Enable prettier: install prettier to format code conforming to rules
33+
◉ Enable mocha: install mocha to run tests
34+
◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint)
35+
◉ Enable editorconfig: add EditorConfig files
36+
◉ Enable vscode: add VSCode config files
37+
◉ Enable docker: include Dockerfile and .dockerignore
38+
◉ Enable repositories: include repository imports and RepositoryMixin
39+
◉ Enable services: include service-proxy imports and ServiceMixin
40+
```
41+
42+
### Starting the project
43+
44+
The generated project includes a built-in `/ping` endpoint for testing.
45+
46+
Start the application:
47+
48+
```sh
49+
cd getting-started
50+
npm install
51+
npm start
52+
```
53+
54+
Open your brower and navigate to:
55+
[http://127.0.0.1:3000/ping](http://127.0.0.1:3000/ping).
56+
57+
### Add a Controller
58+
59+
Next, add a custom [controller](Controller.md). In this example, you’ll create a
60+
simple “Hello World” endpoint.
61+
62+
Run:
63+
64+
```sh
65+
lb4 controller
66+
```
67+
68+
- _Note: If your application is running, press **CTRL+C** to stop it before
69+
running the command._
70+
71+
Respond to the prompts:
72+
73+
```sh
74+
? Controller class name: hello
75+
? What kind of controller would you like to generate? Empty Controller
76+
create src/controllers/hello.controller.ts
77+
update src/controllers/index.ts
78+
79+
Controller hello was now created in src/controllers/
80+
```
81+
82+
### Implement the Controller
83+
84+
Replace the contents of `src/controllers/hello.controller.ts` with the
85+
following:
86+
87+
```ts
88+
import {get} from '@loopback/rest';
89+
90+
export class HelloController {
91+
@get('/hello')
92+
hello(): string {
93+
return 'Hello world!';
94+
}
95+
}
96+
```
97+
98+
### Test the Endpoint
99+
100+
Restart the application:
101+
102+
```sh
103+
npm start
104+
```
105+
106+
Open your browser and navigate to:
107+
[http://127.0.0.1:3000/hello](http://127.0.0.1:3000/hello)
108+
109+
You should see:
110+
111+
```
112+
Hello world!
113+
```
114+
115+
### Code sample
116+
117+
View the complete example project here:
118+
[https://github.com/loopbackio/loopback-next/tree/master/examples/hello-world](https://github.com/loopbackio/loopback-next/tree/master/examples/hello-world)

docs/site/Getting-started.md

Lines changed: 0 additions & 117 deletions
This file was deleted.

docs/site/Installation.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
lang: en
3+
title: 'Installation'
4+
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
5+
sidebar: lb4_sidebar
6+
permalink: /doc/en/lb4/Installation.html
7+
summary: Write and run a LoopBack 4 "Hello World" project in TypeScript.
8+
---
9+
10+
## Prerequisites
11+
12+
Ensure that [Node.js](https://nodejs.org/en/download/) (version 22 or later) is
13+
installed on your machine.
14+
15+
## Install LoopBack 4 CLI
16+
17+
The LoopBack 4 CLI is a command-line tool that scaffolds projects and extensions
18+
by generating the required code. It provides the fastest way to get started with
19+
a LoopBack 4 project while following best practices.
20+
21+
To install the CLI globally, run:
22+
23+
```sh
24+
npm i -g @loopback/cli
25+
```

docs/site/sidebars/lb4_sidebar.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,21 @@ children:
1616
output: 'web, pdf'
1717

1818
- title: 'Getting started'
19-
url: Getting-started.html
2019
output: 'web, pdf'
20+
expand: 'true'
21+
22+
children:
23+
- title: 'Installation'
24+
url: Installation.html
25+
output: 'web, pdf'
26+
27+
- title: 'Create your first app'
28+
url: Create-your-first-app.html
29+
output: 'web, pdf'
30+
31+
- title: 'Project structure'
32+
url: Loopback-application-layout.html
33+
output: 'web, pdf'
2134

2235
- title: 'Inside a LoopBack Application'
2336
url: Inside-LoopBack-Application.html
@@ -801,10 +814,6 @@ children:
801814
output: 'web, pdf'
802815
children:
803816

804-
- title: 'LoopBack 4 Application Layout'
805-
url: Loopback-application-layout.html
806-
output: 'web, pdf'
807-
808817
- title: 'API docs'
809818
url: apidocs.index.html
810819
output: 'web, pdf'

0 commit comments

Comments
 (0)