Skip to content

Commit 459abf6

Browse files
committed
update to v0.3.0
1 parent 6247ec7 commit 459abf6

File tree

2 files changed

+87
-80
lines changed

2 files changed

+87
-80
lines changed

CODEROAD.md

+42-39
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ config:
1212
- .env
1313
- .gitignore
1414
repo:
15-
uri: https://github.com/shmck/coderoad-fcc-basic-node-and-express
16-
branch: v0.2.0
15+
uri: https://github.com/coderoad/fcc-basic-node-and-express
16+
branch: v0.3.0
17+
dependencies:
18+
- name: node
19+
version: >0.10
1720
```
1821

1922
## Meet the Node Console
@@ -48,8 +51,8 @@ setup:
4851
files:
4952
- package.json
5053
commits:
51-
- 'c722f9e'
52-
- '9e28073'
54+
- 'a974aea'
55+
- 'bee383e'
5356
watchers:
5457
- package.json
5558
- node_modules/express
@@ -59,7 +62,7 @@ solution:
5962
files:
6063
- package.json
6164
commits:
62-
- 'ddd0820'
65+
- '63e304f'
6366
commands:
6467
- npm install
6568
```
@@ -73,14 +76,14 @@ setup:
7376
files:
7477
- src/server.js
7578
commits:
76-
- 'cc58e3b'
79+
- 'd9bf5f3'
7780
commands:
7881
- npm install
7982
solution:
8083
files:
8184
- src/server.js
8285
commits:
83-
- '3bfc55c'
86+
- 'ad7af42'
8487
```
8588

8689
Modify the `server.js` file to log "Hello World" to the console.
@@ -110,14 +113,14 @@ setup:
110113
files:
111114
- src/server.js
112115
commits:
113-
- 'a0e3b03'
116+
- '7462d28'
114117
commands:
115118
- npm install
116119
solution:
117120
files:
118121
- src/server.js
119122
commits:
120-
- 'e28b824'
123+
- '331bdfc'
121124
```
122125

123126
Use the `app.get()` method to serve the string "Hello Express" to GET requests matching the `/` (root) path.
@@ -141,12 +144,12 @@ setup:
141144
files:
142145
- src/views/index.html
143146
commits:
144-
- 'fdd75dc20aa74f37e9f2ece83dce578c48a430bc'
147+
- 'd806cc5'
145148
solution:
146149
files:
147150
- src/server.js
148151
commits:
149-
- 'ec492d67803067158e810e00e817b20d14cc39b6'
152+
- '1b04cf8'
150153
```
151154

152155
Send the `/views/index.html` file as a response to GET requests to the `/` path. If you view your live app, you should see a big HTML heading (and a form that we will use later…), with no style applied.
@@ -166,12 +169,12 @@ setup:
166169
files:
167170
- src/public/style.css
168171
commits:
169-
- '6bfd618b3a7163a34dc7e9547791a36a57d39aa7'
172+
- 'c2c1b90'
170173
solution:
171174
files:
172175
- src/server.js
173176
commits:
174-
- 'fb0fe43203089709173372fa39eeb473eae09e80'
177+
- 'bf27ac1'
175178
```
176179

177180
Mount the `express.static()` middleware for all requests with `app.use()`. The absolute path to the assets folder is `\_\_dirname + /public`.
@@ -192,12 +195,12 @@ setup:
192195
files:
193196
- src/server.js
194197
commits:
195-
- '78962a4195d663a06946ea0b1ec62c10fb8ea71b'
198+
- 'ead9fcb'
196199
solution:
197200
files:
198201
- src/server.js
199202
commits:
200-
- 'b16b05d1c408798fb094d40ad196973f436e983f'
203+
- '31fd254'
201204
```
202205

203206
Serve the object `{"message": "Hello json"}` as a response, in JSON format, to GET requests to the `/json` route. Then point your browser to `your-app-url/json`, you should see the message on the screen.
@@ -215,14 +218,14 @@ The environment variables are accessible from the app as `process.env.VAR_NAME`.
215218
```config
216219
setup:
217220
commits:
218-
- '8f4234fce7c540b052ea210191a2a2c6a49b1cca'
221+
- 'da2dfbc'
219222
watchers:
220223
- .env
221224
solution:
222225
files:
223226
- .env
224227
commits:
225-
- 'f06ecb4f0ad67bdd6be5a09a36dc7a3b921de182'
228+
- '3037600'
226229
```
227230

228231
Create a .env file in the root of your project.
@@ -234,12 +237,12 @@ setup:
234237
files:
235238
- .gitignore
236239
commits:
237-
- 'a3577e7b25f8a2d72a271092362f1b7a0582f243'
240+
- '66a5a9e'
238241
solution:
239242
files:
240243
- .gitignore
241244
commits:
242-
- '323233af8c62f5233d8ccdd6b2e760e211957c6f'
245+
- 'b21bbf7'
243246
```
244247

245248
Add the .env file to your .gitignore file. It should be kept a secret.
@@ -251,12 +254,12 @@ setup:
251254
files:
252255
- .env
253256
commits:
254-
- 'fabd307b8a77bf3a965dba8f96e7c91112627257'
257+
- 'b5a291a'
255258
solution:
256259
files:
257260
- .env
258261
commits:
259-
- 'aa0fe163477d8459c187e69f4444a3aa75ea6723'
262+
- '508520c'
260263
```
261264

262265
Let's add an environment variable as a configuration option.
@@ -269,15 +272,15 @@ setup:
269272
files:
270273
- package.json
271274
commits:
272-
- '906a86d8af50b2d4d2e73442e5aeb2f3b9761532'
275+
- '45eafdc'
273276
watchers:
274277
- package.json
275278
- node_modules/dotenv
276279
solution:
277280
files:
278281
- package.json
279282
commits:
280-
- 'fe9f2d0fd6d3e58a7652b599d0cf477894998481'
283+
- 'd400723'
281284
commands:
282285
- npm install
283286
```
@@ -291,12 +294,12 @@ setup:
291294
files:
292295
- src/server.js
293296
commits:
294-
- 'd5440e5cf711625e859d14ebe851e7bbceff8c0d'
297+
- 'a1f1713'
295298
solution:
296299
files:
297300
- src/server.js
298301
commits:
299-
- '75d6643eb1f20049f77077ea96806c99989e2d72'
302+
- '44e6c3a'
300303
```
301304

302305
Load dependencies into your server.js by adding the following line to the top of your file:
@@ -314,12 +317,12 @@ setup:
314317
files:
315318
- src/server.js
316319
commits:
317-
- '7cee81b2c2c847718d2b2a123efbe106c84a3ad9'
320+
- '40fd774'
318321
solution:
319322
files:
320323
- src/server.js
321324
commits:
322-
- 'ebfd74be1a47a4348d9acfdcc6d345ab257d572e'
325+
- 'f5340dc'
323326
```
324327

325328
Tell the GET `/json` route handler that you created in the last challenge to transform the response object’s message to uppercase if `process.env.MESSAGE_STYLE` equals `uppercase`. The response object should become `{"message": "HELLO JSON"}`.
@@ -350,12 +353,12 @@ setup:
350353
files:
351354
- src/server.js
352355
commits:
353-
- 'e400e1df828926321eb375686e6b5c388342119b'
356+
- 'b18fa07'
354357
solution:
355358
files:
356359
- src/server.js
357360
commits:
358-
- '458f2d51fd7b77be921a197ef2ec5589bbf4e282'
361+
- '9ba7d21'
359362
```
360363

361364
Build a simple logger. For every request, it should log to the console a string taking the following format: `method path - ip`. An example would look like this: `GET /json - ::ffff:127.0.0.1`. Note that there is a space between `method` and `path` and that the dash separating `path` and `ip` is surrounded by a space on both sides. You can get the request method (http verb), the relative route path, and the caller’s ip from the request object using `req.method`, `req.path` and `req.ip`. Remember to call `next()` when you are done, or your server will be stuck forever. Be sure to have the ‘Logs’ opened, and see what happens when some request arrives.
@@ -391,12 +394,12 @@ setup:
391394
files:
392395
- src/server.js
393396
commits:
394-
- '6adeb38dc7c4349ee3138be6bef78f7a7b562874'
397+
- 'b3c244e'
395398
solution:
396399
files:
397400
- src/server.js
398401
commits:
399-
- 'ee9205ea772e60bbce0671a9bd6855e7b2d3357f'
402+
- '5b12fa5'
400403
```
401404

402405
In the route `app.get('/now', ...)` chain a middleware function and the final handler. In the middleware function you should add the current time to the request object in the `req.time` key. You can use `new Date().toString()`. In the handler, respond with a JSON object, taking the structure `{time: req.time}`.
@@ -417,12 +420,12 @@ setup:
417420
files:
418421
- src/server.js
419422
commits:
420-
- 'ab47c91e36779a9132e0cddc88166aa58b44062b'
423+
- 'fd4a291'
421424
solution:
422425
files:
423426
- src/server.js
424427
commits:
425-
- 'c53edaa512157c7791b01f8e9aca9de719545451'
428+
- '6d1db55'
426429
```
427430

428431
Build an echo server, mounted at the route `GET /echo/:word`. Respond with a JSON object, taking the structure `{echo: word}`. You can find the word to be repeated at `req.params.word`.
@@ -442,12 +445,12 @@ setup:
442445
files:
443446
- src/server.js
444447
commits:
445-
- '2111dd1cd4111f113ba3b8071ab80de42ade8844'
448+
- '1881c49'
446449
solution:
447450
files:
448451
- src/server.js
449452
commits:
450-
- '0ed8dd9050558854a90ae10ccd0096a7f1741b76'
453+
- 'd12bd73'
451454
```
452455

453456
Build an API endpoint, mounted at `GET /name`. Respond with a JSON document, taking the structure `{ name: 'firstname lastname'}`. The first and last name parameters should be encoded in a query string e.g. `?first=firstname&last=lastname`.
@@ -480,15 +483,15 @@ setup:
480483
files:
481484
- package.json
482485
commits:
483-
- '343c6b6d0cea18b5439fee7ca3babebe91d74ccb'
486+
- 'e510f57'
484487
watchers:
485488
- package.json
486489
- node_modules/body-parser
487490
solution:
488491
files:
489492
- package.json
490493
commits:
491-
- '0835a39f5f5fd38b690ad9c8d1ae6243b3b4dd7c'
494+
- 'a38dc38'
492495
commands:
493496
- npm install
494497
```
@@ -502,12 +505,12 @@ setup:
502505
files:
503506
- src/server.js
504507
commits:
505-
- 'b5d65b56bf232ec09c6101b9e868213fb157a32a'
508+
- '4249499'
506509
solution:
507510
files:
508511
- src/server.js
509512
commits:
510-
- '2c3c3815e5352f3a94716d5023af93f1b49fa5cd'
513+
- '2a74c71'
511514
```
512515

513516
Require "body-parser" at the top of the server.js file. Store it in a variable named `bodyParser`. The middleware to handle urlencoded data is returned by `bodyParser.urlencoded({extended: false})`. Pass to `app.use()` the function returned by the previous method call. As usual, the middleware must be mounted before all the routes which need it.

0 commit comments

Comments
 (0)