Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove date-fns and add Moment library #1

Merged
merged 1 commit into from Dec 23, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+27 −23
Diff settings

Always

Just for now

@@ -1,2 +1,5 @@
# myapp
Simple web server written in Node for Up and running with Git article series. Find the accompanying article [here](https://www.attosol.com/getting-started-with-git-part-1/).

### Modified the greeting
Now we greet on all the days!
@@ -1,24 +1,25 @@
const dfns = require('date-fns');
const url = require('url');
const moment = require('moment');

let handler = (req, res) => {
let queryData = url.parse(req.url, true).query;
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');

let greetString = "";
if (queryData.name) {
greetString = "Hello user!\n";
}
else {
greetString = "Hello World!\n";
}
let friday = dfns.isFriday(new Date());
if (friday) {
greetString += "It's Friday!"
}
res.end(greetString);
let queryData = url.parse(req.url, true).query;
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');

}
let greetString = "";
if (queryData.name) {
greetString = "Hello user!\n";
} else {
greetString = "Hello World!\n";
}

let day = moment().format('dddd');
if (day === "Friday") {
greetString += "Thank God! It is FRIDAY!"
} else {
greetString += ("It's " + day);
}
res.end(greetString);
};

module.exports = handler;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -9,6 +9,6 @@
"author": "Ramit",
"license": "ISC",
"dependencies": {
"date-fns": "^1.29.0"
"moment": "^2.23.0"
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.