fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles * fix: added 3 dashes line before prob expl * fix: added 3 dashes line before hints * fix: added 3 dashes line before solutions
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Exercise Tracker
|
||||
---
|
||||
## Exercise Tracker
|
||||
# Exercise Tracker
|
||||
|
||||
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/apis-and-microservices-projects/exercise-tracker/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: File Metadata Microservice
|
||||
---
|
||||
## File Metadata Microservice
|
||||
# File Metadata Microservice
|
||||
|
||||
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/apis-and-microservices-projects/file-metadata-microservice/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: APIs and Microservices Projects
|
||||
---
|
||||
## APIs and Microservices Projects
|
||||
# APIs and Microservices Projects
|
||||
|
||||
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/mathematics/quadratic-equations/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Request Header Parser Microservice
|
||||
---
|
||||
## Request Header Parser Microservice
|
||||
# Request Header Parser Microservice
|
||||
|
||||
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/apis-and-microservices-projects/request-header-parser-microservice/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
|
||||
|
||||
|
@@ -2,13 +2,10 @@
|
||||
title: Timestamp Microservice
|
||||
---
|
||||
|
||||
## Timestamp Microservice
|
||||
# Timestamp Microservice
|
||||
|
||||
---
|
||||
|
||||
 Remember to use <a>**`Read-Search-Ask`**</a> if you get stuck. Try to pair program  and write your own code 
|
||||
|
||||
###  Problem Explanation:
|
||||
## Problem Explanation
|
||||
|
||||
- You need to write a microservice that will return a JSON with the date in Unix format and in a human-readable date format. The JSON format is like the example output, "{"unix":1451001600000, "utc":"Fri, 25 Dec 2015 00:00:00 GMT"}".
|
||||
- The response depends on the URL. If the API endpoint is hit with no additional information, it returns the JSON with the current time.
|
||||
@@ -20,38 +17,37 @@ title: Timestamp Microservice
|
||||
|
||||
- [Date at MDN:](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
|
||||
|
||||
##  Hint: 1
|
||||
|
||||
---
|
||||
## Hints
|
||||
|
||||
## Hint: 1
|
||||
|
||||
You will need to create the '/api/timestamp/' endpoint separately from the endpoint that reads the date to be parsed from the URL. You won't need a conditional to deal with this endpoint.
|
||||
|
||||
> _try to solve the problem now_
|
||||
|
||||
##  Hint: 2
|
||||
## Hint: 2
|
||||
|
||||
Date.valueOf() and Date.toUTCString() will generate the correct strings for unix: and utc:. No need to import the Moment library!
|
||||
|
||||
> _try to solve the problem now_
|
||||
|
||||
##  Hint: 3
|
||||
## Hint: 3
|
||||
|
||||
The Javascript Date object checks for dates that are invalid dates under ISO-8601. Use a Javascript REPL or a short Node script to try it out. [Here is a free online service that lets you test some JS code.:]https://repl.it/site/languages/javascript
|
||||
|
||||
> _try to solve the problem now_
|
||||
|
||||
## Spoiler Alert!
|
||||
|
||||

|
||||
---
|
||||
## Solutions
|
||||
|
||||
**Solution ahead!**
|
||||
|
||||
##  Basic Code Solution:
|
||||
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
||||
|
||||
```javascript
|
||||
app.get('/api/timestamp/', (req, res) => {
|
||||
app.get("/api/timestamp/", (req, res) => {
|
||||
res.json({ unix: Date.now(), utc: Date() });
|
||||
});
|
||||
|
||||
app.get('/api/timestamp/:date_string', (req, res) => {
|
||||
app.get("/api/timestamp/:date_string", (req, res) => {
|
||||
let dateString = req.params.date_string;
|
||||
|
||||
//A 4 digit number is a valid ISO-8601 for the beginning of that year
|
||||
@@ -64,15 +60,15 @@ app.get('/api/timestamp/:date_string', (req, res) => {
|
||||
|
||||
let dateObject = new Date(dateString);
|
||||
|
||||
if (dateObject.toString() === 'Invalid Date') {
|
||||
res.json({ error: 'Invaid Date' });
|
||||
if (dateObject.toString() === "Invalid Date") {
|
||||
res.json({ error: "Invaid Date" });
|
||||
} else {
|
||||
res.json({ unix: dateObject.valueOf(), utc: dateObject.toUTCString() });
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Code Explanation:
|
||||
#### Code Explanation
|
||||
|
||||
- This is a pretty straightforward application of the lessons, Basic Node and Express - Serve JSON on a Specific Route
|
||||
and Basic Node and Express - Get Route Parameter Input from the Client. The added wrinkle is the use of Javascript's native Date object.
|
||||
@@ -81,9 +77,4 @@ app.get('/api/timestamp/:date_string', (req, res) => {
|
||||
|
||||
That's it. There is no intermediate or advanced solution yet. If you have a better, more elegant solution, help us all out and contribute them!
|
||||
|
||||
##  NOTE TO CONTRIBUTORS:
|
||||
|
||||
-  **DO NOT** add solutions that are similar to any existing solutions. If you think it is **_similar but better_**, then try to merge (or replace) the existing similar solution.
|
||||
- Add an explanation of your solution.
|
||||
- Categorize the solution in one of the following categories -- **Basic**, **Intermediate** and **Advanced**. 
|
||||
|
||||
</details>
|
@@ -1,11 +1,19 @@
|
||||
---
|
||||
title: URL Shortener Microservice
|
||||
---
|
||||
## URL Shortener Microservice
|
||||
# URL Shortener Microservice
|
||||
|
||||
---
|
||||
## Problem Explanation
|
||||
The core features to complete this exercise are the creation and retrieval of URLs from the Database.
|
||||
|
||||
## Creating Short URL
|
||||
|
||||
---
|
||||
## Hints
|
||||
|
||||
### Hint 1
|
||||
|
||||
Creating Short URL
|
||||
- Connect to your database instance.
|
||||
> **Note**: It's important to check your Mongoose connection status before dive into the problem, just to check if everything is okay with your database configuration. This should help: `mongoose.connection.readyState`
|
||||
- Receive a POST request containing an URL to be saved on Database.
|
||||
@@ -16,11 +24,10 @@ The core features to complete this exercise are the creation and retrieval of UR
|
||||
- There is a bunch of samples over the internet how to generate some kind of identifier, try to explore it or create your own.
|
||||
- An example of how this should look like: `{'url': www.freecodecamp.org, 'hash': 'ef49fa8b4'}`
|
||||
|
||||
## Retrieving Short URL
|
||||
### Hint 2
|
||||
Retrieving Short URL
|
||||
- Receive a GET request containing an identifier used to find a stored URL.
|
||||
- Try to find one URL saved for this identifier
|
||||
- Redirect user to URL.
|
||||
> **Note**: The `res.redirect(url)` function need that the given url, has a defined protocol (http://, https://), or it will just concatenate it as an extension of your current domain. eg: Good URL: `https://www.freecodecamp.org`, Bad URL: `www.freecodecamp.org`. Try it out.
|
||||
- Remember to handle error situations with proper response like, `res.json({"error":"invalid URL"});
|
||||
|
||||
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
|
||||
|
Reference in New Issue
Block a user