Skip to content

Commit 682743e

Browse files
committed
first commit
0 parents  commit 682743e

15 files changed

+1268
-0
lines changed

.gitignore

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

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# "Node.js Tutorial - How to Build a Web Server"
2+
3+
[Check out my YouTube Channel with all of my tutorials](https://www.youtube.com/DaveGrayTeachesCode).
4+
5+
**Description:**
6+
7+
This repository shares the code applied during the Youtube tutorial. The tutorial is part of a [Node.js for Beginners Playlist](https://www.youtube.com/playlist?list=PL0Zuz27SZ-6PFkIxaJ6Xx_X46avTM1aYw) on my channel.
8+
9+
[YouTube Tutorial](https://youtu.be/3ZAKY-CDKog) for this repository.
10+
11+
I suggest completing my [8 hour JavaScript course tutorial video](https://youtu.be/EfAl9bwzVZk) if you are new to Javascript.
12+
13+
### Academic Honesty
14+
15+
**DO NOT COPY FOR AN ASSIGNMENT** - Avoid plagiargism and adhere to the spirit of this [Academic Honesty Policy](https://www.freecodecamp.org/news/academic-honesty-policy/).

css/style.css

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
* {
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
font-size: 36px;
9+
min-height: 100vh;
10+
color: #fff;
11+
background-color: #000;
12+
display: grid;
13+
place-content: center;
14+
}

data/data.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"firstname": "Dave",
4+
"lastname": "Gray"
5+
},
6+
{
7+
"firstname": "John",
8+
"lastname": "Smith"
9+
}
10+
]

data/data.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Just some random text.

img/img1.jpg

43.6 KB
Loading

logEvents.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { format } = require('date-fns');
2+
const { v4: uuid } = require('uuid');
3+
4+
const fs = require('fs');
5+
const fsPromises = require('fs').promises;
6+
const path = require('path');
7+
8+
const logEvents = async (message, logName) => {
9+
const dateTime = `${format(new Date(), 'yyyyMMdd\tHH:mm:ss')}`;
10+
const logItem = `${dateTime}\t${uuid()}\t${message}\n`;
11+
12+
try {
13+
if (!fs.existsSync(path.join(__dirname, 'logs'))) {
14+
await fsPromises.mkdir(path.join(__dirname, 'logs'));
15+
}
16+
17+
await fsPromises.appendFile(path.join(__dirname, 'logs', logName), logItem);
18+
} catch (err) {
19+
console.log(err);
20+
}
21+
}
22+
23+
module.exports = logEvents;

0 commit comments

Comments
 (0)