From 6cbd72743d07aea79bc802297b6f7629bf1c4638 Mon Sep 17 00:00:00 2001
From: Ilenia <26656284+ilenia-magoni@users.noreply.github.com>
Date: Mon, 30 Sep 2024 21:39:28 +0200
Subject: [PATCH] chore(curriculum): add timestamp microservice lab to cert
(#56358)
Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com>
---
client/i18n/locales/english/intro.json | 5 +-
.../lab-timestamp-microservice/index.md | 9 ++
.../lab-timestamp-microservice/meta.json | 10 ++
.../bd7158d8c443edefaeb5bdef.md | 144 ++++++++++++++++++
4 files changed, 167 insertions(+), 1 deletion(-)
create mode 100644 client/src/pages/learn/front-end-development/lab-timestamp-microservice/index.md
create mode 100644 curriculum/challenges/_meta/lab-timestamp-microservice/meta.json
create mode 100644 curriculum/challenges/english/25-front-end-development/lab-timestamp-microservice/bd7158d8c443edefaeb5bdef.md
diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json
index a654e969b02..061c50da03d 100644
--- a/client/i18n/locales/english/intro.json
+++ b/client/i18n/locales/english/intro.json
@@ -2717,7 +2717,10 @@
"In this course, you'll learn the basics of Node and Express including how to create a server, serve different files, and handle different requests from the browser."
]
},
- "zzhp": { "title": "372", "intro": [] },
+ "lab-timestamp-microservice": {
+ "title": "Build a Timestamp Microservice",
+ "intro": ["In this lab you will build a timestamp microservice"]
+ },
"lab-request-header-parser-microservice": {
"title": "Build a Request Header Parser Microservice",
"intro": [
diff --git a/client/src/pages/learn/front-end-development/lab-timestamp-microservice/index.md b/client/src/pages/learn/front-end-development/lab-timestamp-microservice/index.md
new file mode 100644
index 00000000000..e8f458589a3
--- /dev/null
+++ b/client/src/pages/learn/front-end-development/lab-timestamp-microservice/index.md
@@ -0,0 +1,9 @@
+---
+title: Introduction to the Build a Timestamp Microservice
+block: lab-timestamp-microservice
+superBlock: front-end-development
+---
+
+## Introduction to the Build a Timestamp Microservice
+
+In this lab you will build a timestamp microservice
diff --git a/curriculum/challenges/_meta/lab-timestamp-microservice/meta.json b/curriculum/challenges/_meta/lab-timestamp-microservice/meta.json
new file mode 100644
index 00000000000..cbfd598769d
--- /dev/null
+++ b/curriculum/challenges/_meta/lab-timestamp-microservice/meta.json
@@ -0,0 +1,10 @@
+{
+ "name": "Build a Timestamp Microservice",
+ "isUpcomingChange": true,
+ "dashedName": "lab-timestamp-microservice",
+ "order": 372,
+ "superBlock": "front-end-development",
+ "challengeOrder": [{ "id": "bd7158d8c443edefaeb5bdef", "title": "Build a Timestamp Microservice" }],
+ "helpCategory": "Backend Development",
+ "blockType": "lab"
+}
diff --git a/curriculum/challenges/english/25-front-end-development/lab-timestamp-microservice/bd7158d8c443edefaeb5bdef.md b/curriculum/challenges/english/25-front-end-development/lab-timestamp-microservice/bd7158d8c443edefaeb5bdef.md
new file mode 100644
index 00000000000..81d99c89ec9
--- /dev/null
+++ b/curriculum/challenges/english/25-front-end-development/lab-timestamp-microservice/bd7158d8c443edefaeb5bdef.md
@@ -0,0 +1,144 @@
+---
+id: bd7158d8c443edefaeb5bdef
+title: Build a Timestamp Microservice
+challengeType: 4
+dashedName: lab-timestamp-microservice
+---
+
+# --description--
+
+Build a full stack JavaScript app that is functionally similar to this: https://timestamp-microservice.freecodecamp.rocks. Working on this lab will involve you writing your code using one of the following methods:
+
+- Clone this GitHub repo and complete your project locally.
+- Use our Gitpod starter project to complete your project.
+- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
+
+**Note:** Time zones conversion is not a purpose of this project, so assume all sent valid dates will be parsed with `new Date()` as GMT dates.
+
+# --hints--
+
+You should provide your own project, not the example URL.
+
+```js
+(getUserInput) => {
+ assert(
+ !/.*\/timestamp-microservice\.freecodecamp\.rocks/.test(getUserInput('url'))
+ );
+};
+```
+
+A request to `/api/:date?` with a valid date should return a JSON object with a `unix` key that is a Unix timestamp of the input date in milliseconds (as type Number)
+
+```js
+(getUserInput) =>
+ $.get(getUserInput('url') + '/api/2016-12-25').then(
+ (data) => {
+ assert.equal(
+ data.unix,
+ 1482624000000,
+ 'Should be a valid unix timestamp'
+ );
+ },
+ (xhr) => {
+ throw new Error(xhr.responseText);
+ }
+ );
+```
+
+A request to `/api/:date?` with a valid date should return a JSON object with a `utc` key that is a string of the input date in the format: `Thu, 01 Jan 1970 00:00:00 GMT`
+
+```js
+(getUserInput) =>
+ $.get(getUserInput('url') + '/api/2016-12-25').then(
+ (data) => {
+ assert.equal(
+ data.utc,
+ 'Sun, 25 Dec 2016 00:00:00 GMT',
+ 'Should be a valid UTC date string'
+ );
+ },
+ (xhr) => {
+ throw new Error(xhr.responseText);
+ }
+ );
+```
+
+A request to `/api/1451001600000` should return `{ unix: 1451001600000, utc: "Fri, 25 Dec 2015 00:00:00 GMT" }`
+
+```js
+(getUserInput) =>
+ $.get(getUserInput('url') + '/api/1451001600000').then(
+ (data) => {
+ assert(
+ data.unix === 1451001600000 &&
+ data.utc === 'Fri, 25 Dec 2015 00:00:00 GMT'
+ );
+ },
+ (xhr) => {
+ throw new Error(xhr.responseText);
+ }
+ );
+```
+
+Your project can handle dates that can be successfully parsed by `new Date(date_string)`
+
+```js
+(getUserInput) =>
+ $.get(getUserInput('url') + '/api/05 October 2011, GMT').then(
+ (data) => {
+ assert(
+ data.unix === 1317772800000 &&
+ data.utc === 'Wed, 05 Oct 2011 00:00:00 GMT'
+ );
+ },
+ (xhr) => {
+ throw new Error(xhr.responseText);
+ }
+ );
+```
+
+If the input date string is invalid, the API returns an object having the structure `{ error : "Invalid Date" }`
+
+```js
+(getUserInput) =>
+ $.get(getUserInput('url') + '/api/this-is-not-a-date').then(
+ (data) => {
+ assert.equal(data.error.toLowerCase(), 'invalid date');
+ },
+ (xhr) => {
+ assert(xhr.responseJSON.error.toLowerCase() === 'invalid date');
+ }
+ );
+```
+
+An empty date parameter should return the current time in a JSON object with a `unix` key
+
+```js
+(getUserInput) =>
+ $.get(getUserInput('url') + '/api').then(
+ (data) => {
+ var now = Date.now();
+ assert.approximately(data.unix, now, 20000);
+ },
+ (xhr) => {
+ throw new Error(xhr.responseText);
+ }
+ );
+```
+
+An empty date parameter should return the current time in a JSON object with a `utc` key
+
+```js
+(getUserInput) =>
+ $.get(getUserInput('url') + '/api').then(
+ (data) => {
+ var now = Date.now();
+ var serverTime = new Date(data.utc).getTime();
+ assert.approximately(serverTime, now, 20000);
+ },
+ (xhr) => {
+ throw new Error(xhr.responseText);
+ }
+ );
+```
+