-
Notifications
You must be signed in to change notification settings - Fork 387
/
getting-started.html
257 lines (240 loc) · 10.3 KB
/
getting-started.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="">
<!-- not working -->
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<title>LoopBack 4</title>
<!-- Bootstrap core CSS -->
<link href="dist/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Sans" rel="stylesheet">
<link href="css/loopback.css" rel="stylesheet">
<link href="css/getting-started.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-150726441-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-150726441-2');
</script>
</head>
<body>
<!-- Navbar -->
<div id="navbar-template"></div>
<!-- Header -->
<div class="gs-masthead">
<div class="container-fluid"></div>
<div class="header-space"></div>
<h2>Ready to build with LoopBack?</h2>
<br>
<h5 style="font-weight: normal">Let's get you equipped.</h5>
<div class="header-space"></div>
</div>
<!-- Getting Started Steps section -->
<section class="odd-section">
<!-- Install Node subsection -->
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 1</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Have you installed Node.js?</h3>
<p class="p large step">Before you install LoopBack, make sure to download and install Node.js (version 8.9.x or higher), a JavaScript
runtime. </p>
</div>
<div class="col-md-6">
<a class="btn btn-secondary" style="padding-left:60px; padding-right:60px; top: 20%" role="button" href="https://nodejs.org/en/download/" target="_blank" rel="noopener noreferrer">Install Node.js</a>
</div>
</div>
</div>
</section>
<hr class="hairline">
<section id="step2" class="even-section">
<!-- Install LB4 CLI subsection -->
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 2</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Install LoopBack 4 CLI</h3>
<p class="p large step">The LoopBack 4 CLI is a command-line interface that can scaffold a project or extension. The CLI provides
the fastest way to get started with a LoopBack 4 project that adheres to best practices.
</p>
</div>
<div class="col-md-6">
<pre class="code-snippet">
<code-blue>$</code-blue> npm install -g @loopback/cli
</pre>
</div>
</div>
</div>
</section>
<hr class="hairline">
<section id="step3" class="odd-section">
<!-- create new project subsection -->
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 3</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Create a new project</h3>
<p class="p large step">To create a new project, run the CLI as follows.
</p>
</div>
<div class="col-md-6">
<pre class="code-snippet">
<code-blue>$</code-blue> lb4 app
</pre>
</div>
</div>
</div>
<!-- answer the prompt subsection -->
<div class="container">
<hr class="hairline">
<div class="row text-center">
<div class="col-md-6">
<p class="p large" style="position:relative; top:60%">Answer the prompts as follows.
</p>
</div>
<div class="col-md-6">
<pre class="code-snippet">
<code-blue>[?]</code-blue> Project name: getting-started
<code-blue>[?]</code-blue> Project description: Getting started tutorial
<code-blue>[?]</code-blue> Project root directory: (getting-started)
<code-blue>[?]</code-blue> Application class name: StarterApplication
<code-blue>[?]</code-blue> Select features to enable in the project: Enable eslint, Enable prettier, Enable mocha, Enable loopbackBuild, Enable vscode, Enable docker, Enable repositories, Enable services
</pre>
</div>
</div>
</div>
</section>
<hr class="hairline">
<section id="step4" class="even-section">
<!-- Starting the project-->
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 4</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Starting the project</h3>
<p class="p large step">The project comes with a "ping" route to test the project. Let's try it out by running the projects.
</p>
<p class="p large">In a browser, visit
<a class="link" href="http://127.0.0.1:3000/ping">http://127.0.0.1:3000/ping</a>
</p>
</div>
<div class="col-md-6">
<pre class="code-snippet">
<code-blue>$</code-blue> cd getting-started
<code-blue>$</code-blue> npm start
</pre>
</div>
</div>
</div>
</section>
<hr class="hairline">
<section id="step5" class="odd-section">
<!-- add controller subsection -->
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 5</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Add your own controller</h3>
<p class="p large step">Now that we have a basic project created, it’s time to add our own controller. Let’s add a simple “Hello
World” controller as follows.
</p>
</div>
<div class="col-md-6">
<pre class="code-snippet" style="top:10%">
<code-blue> $</code-blue> lb4 controller
<code-blue>[?]</code-blue> Controller class name: hello
<code-blue>[?]</code-blue> What kind of controller would you like to generate? Empty Controller
create src/controllers/hello.controller.ts
update src/controllers/index.ts
Controller Hello was now created in src/controllers/
</pre>
</div>
</div>
</div>
<!-- Edit controller subsection -->
<div class="container">
<hr class="hairline">
<div class="row text-center">
<div class="col-md-6">
<p class="p large" style="position:relative;top:55%">Paste the following contents into the file <code>/src/controllers/hello.controller.ts</code>.
</p>
</div>
<div class="col-md-6">
<pre class="code-snippet">
<code-blue>import</code-blue> {<code-blue>get</code-blue>} <code-blue>from</code-blue> '@loopback/rest';
<code-blue>export class </code-blue>HelloController {
@get('/hello')
hello(): string {
<code-blue>return</code-blue> 'Hello world!';
}
}
</pre>
</div>
</div>
</div>
</section>
<hr class="hairline">
<section id="step6" class="even-section">
<!-- Test your application -->
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<button class="steptag text-uppercase">Step 6</button>
</div>
<div class="col-md-6">
<h3 class="feature-heading">Test your application</h3>
<p class="p large step">Start the application using <code>npm start</code>.
</p>
</div>
<div class="col-md-6">
Visit <a class="link" href="http://127.0.0.1:3000/hello" target="_blank" rel="noopener noreferrer">http://127.0.0.1:3000/hello</a> to see <code>Hello world!</code>
</div>
</div>
</div>
</section>
<div class="action">
<div class="container">
<div class="row">
<div class="col-md-8">
<h3 style="color:white">Ready to continue your journey?
<p class="p large">Follow the tutorial to create a real-world application with LoopBack 4.</h3>
</div>
<div class="col-md-4">
<a class="btn btn-primary" role="button" style="padding-left:60px; padding-right:60px" href="/doc/en/lb4/todo-tutorial.html">View Tutorial</a>
</div>
</div>
</div>
</div>
<!-- footer -->
<footer>
<div id="footer-template"></div>
</footer>
<script src="/dist/jquery/jquery-3.4.1.min.js" crossorigin="anonymous"></script>
<script src="dist/popper/1.14.0/umd/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script src="dist/bootstrap/js/bootstrap.min.js"></script>
<!-- GitHub button -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
<!-- Load the NavBar template -->
<script>
$(function(){
$("#navbar-template").load("navbar-template.html");
$("#footer-template").load("footer-template.html");
});
</script>
</body>