FreeCodeCamp-APIs and Microservices — Timestamp Microservice Project

FreeCodeCamp

Our goal is freeCodeCamp APIs and Microservices certificate. We have to do five project. First one is Timestamp Microservice 🕒🚀

I used freeCodeCamp Glitch boilerplate project. Here is a starter link.

package.json

I used Node.Js, Express for my project also cors for the freeCodeCamp tests.

Let’s get start to write our codes 👨‍💻

We have got one javascript file called as a server.js for the app run. First thing to do we need call packages to server.js file and create an Express application.

Call the Packages and Create an Express Application

We have to handle six conditions for our api.

1-) It should handle a valid date, and return the correct unix timestamp

2-) It should handle a valid date, and return the correct UTC string

3-) It should handle a valid unix date, and return the correct unix timestamp

4-) It should return the expected error message for an invalid date

5-) It should handle an empty date parameter, and return the current time in unix format

6-) It should handle an empty date parameter, and return the current time in UTC format

Our dateString input types are like this formats [2019–12–07],[1575741823145],[ ],[invalid-randomtext].

First of all if our input is an empty value we need to check this condition and create a new Date() variable. Else we need to check input is a dateString or a unixtime. If our input is not empty or valid date types, we’ll set to it is invalid.

After that we need to shows our index.html file. We used our public(style,javascript) folder and render the index.html file.

I used freeCodeCamp starter index.html file. I think it’s explaining clearly.

Last thing we have to listen request for our app on port 3000. We can check the console if it works properly we can see the force 😉

It’s working. We need to add this url to our projects url …. /api/timestamp/

Output is should be like this format .

It’s my birthday 👅

Here is the live version >>> https://bdev-fcctimestamp.glitch.me

--

--

--

Full Stack Developer👨🏻‍💻 Camper 🏕️

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Complete Guide to Building Your On-Demand Grocery App with React Native

JavaScript — Promises to the rescue

How to optimize React applications with Lazy Loading 😴

Creating Signup and Login system using React Native, PHP and MySQL

Create an Animated Banner with Vanilla JavaScript and the Canvas API

Gatsby Blog + Netlify CMS Tutorial — Part 1

https://youtu.be/u02mUklYS2A

5 reasons to build your backend using Node.js

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Barış Türe

Barış Türe

Full Stack Developer👨🏻‍💻 Camper 🏕️

More from Medium

What is JWT. How to implement JWT based authentication in NodeJs?

How to implement JWT based authentication in NodeJs

Getting Started with Node.js

Mongoose.