Skip to content

Commit 5d7c01b

Browse files
author
Luca Sartori
committed
Week 1 exercises
1 parent 234b470 commit 5d7c01b

File tree

5 files changed

+77
-1
lines changed

5 files changed

+77
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/node_modules

README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ exercises as wanted.
7878

7979
### Materials
8080

81-
1. You will need to install [Node.JS](https://nodejs.org/en/) (NVM is strongly recommended - [Unix](https://github.com/creationix/nvm#installation)/[Windows](https://github.com/coreybutler/nvm-windows))
81+
1. You will need to install [Node.JS](https://nodejs.org/en/) (Version 8) (NVM is strongly recommended - [Unix](https://github.com/creationix/nvm#installation)/[Windows](https://github.com/coreybutler/nvm-windows))
8282

8383
2. The recommended IDE is [Visual Studio Code](https://code.visualstudio.com/). However, you can use any IDE of your preference.
8484

@@ -280,9 +280,38 @@ Then you can go on with this
280280
- [How npm works?](https://docs.npmjs.com/how-npm-works/npm3)
281281

282282
### Exercise:
283+
Look into [`src/week1/day4-5`](src/week1/day4-5) in there there're some `js` files. Those 2 are Node.js apps, they don't work as you would expect from any other `.js` file.
284+
You will need to use the command line:
285+
```
286+
luca.sartori@AR-IT12688:~/bootcamps/ui$
287+
```
288+
That's your Command Line Interface, know your CLI, love your CLI, **BE** your CLI. A developer is defined by it's tools, and you will want this one on your side.
289+
290+
You'll need to navigate to `src/week1/day4-5`
291+
```
292+
luca.sartori@AR-IT12688:~/bootcamps/ui$ cd src/week1/day4-5/
293+
```
294+
If you excecute a `ls` command you'll se the contents on the CLI
295+
```
296+
luca.sartori@AR-IT12688:~/bootcamps/ui/src/week1/day4-5/$ ls
297+
298+
expressDemo.js fsDemo.js node_modules package.json
299+
300+
```
301+
Then, you have to run one of the files
302+
```
303+
luca.sartori@AR-IT12688:~/bootcamps/ui/src/week1/day4-5/$ node fsDemo.js
304+
```
305+
[**Remember, you'll need Node.js installed**](#materials)
306+
307+
That will run the code, just remember two things
308+
1. Server code, like the one from [expressDemo](/src/week1/day4-5/expressDemo.js) keeps running, you have to exit it
309+
2. To exit a running process on the CLI, you need to press `CTRL+C`
283310

284311
**Notes:**
285312

313+
Don't be afraid to Google stuff, no developer remembers everything
314+
286315
[index](#index)
287316

288317
# Week 2: TypeScript and Angular 101

src/week1/day4-5/expressDemo.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const express = ;
2+
const app = express();
3+
const port = 3000;
4+
5+
app.get('/', (req, res) => {
6+
res.send('Hello There!');
7+
})
8+
9+
app.listen(port, () => {
10+
console.log('Example server listening on port ' + port);
11+
console.log('Enter http://localhost:' + port + ' on your browser')
12+
})
13+
14+
// First things first, this won't work. It's your job to fix it
15+
// Just a clue, that variable called express is a module, so you need to bring it in.
16+
// If only there was some kind of MANAGER for that ;) (make sure you save it though)
17+
18+
// Once the server is working, add a new route, called "/random" that
19+
// sends out a random number between 0 and 100 as a response.
20+
21+
// ******BONUS POINTS*******
22+
// Add 2 other routes, one that does whatever you want, and another one
23+
// that load up a JSON file from the server (if you don't know what that is, Google it)
24+
// and sends the content as a string (little tip, theres a Js method for that)

src/week1/day4-5/fsDemo.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs');
2+
var fileName = "test.txt",
3+
content = "Hey There!";
4+
5+
fs.writeFile(__dirname + "/" + fileName, content, function(err) {
6+
if(err) {
7+
return console.log(err)
8+
}
9+
10+
console.log("The file was saved!");
11+
});
12+
13+
// This is a node app, this code saves a file on the current path with
14+
// the content on the variable with that name.
15+
16+
// Let's make more interesting, here's the API for the 'fs' module
17+
// https://nodejs.org/api/fs.html
18+
// Make the app check for a current file with that name, if it's there,
19+
// log some message on the console, if not, save the file like on the example
20+
21+
// *****BONUS POINTS*****
22+
// Make it with a buffer

src/week1/day4-5/index.js

Whitespace-only changes.

0 commit comments

Comments
 (0)