The first API project for the Back End Development Certification on FreeCodeCamp. It uses Nodejs and Expressjs to return, as a JSON object, the Unix timestamp and the natural representation of a date string passed to it.
Click here to see the demo hosted on Heroku.
Objective: Build a full stack JavaScript app that is functionally similar to this and deploy it to Heroku.
User stories:
- I can pass a string as a parameter, and it will check to see whether that string contains either a unix timestamp or a natural language date (example: January 1, 2016)
- If it does, it returns both the Unix timestamp and the natural language form of that date.
- If it does not contain a date or Unix timestamp, it returns null for those properties.
https://timestamp-api-r4meau.herokuapp.com/December%2015,%202015
https://timestamp-api-r4meau.herokuapp.com/1450137600
{ "unix": 1450137600, "natural": "December 15, 2015" }
Although there is a demo online, if you want to try this project by yourself or you just want to test it locally, feel free to keep reading.
For this project, you'll need:
Alrighty, First, clone/download this repo on your computer and cd
into it:
git clone http://github.com/r4meau/timestamp-api
cd timestamp-api
Then install the necessary packages:
npm install
Now run the server:
npm start
That's it! Now go to http://localhost:8080 and test it.
Great, I really recommend you to create an account on FreeCodeCamp and get started there if you are a total beginner, but read on to get started.
This is a beginner to intermediate Nodejs project so it's assuming you know how to:
- code in JavaScript. More precisely on the Date object.
- setup a server with Nodejs and Expressjs
- handle basic get requests with Expressjs
- handle basic templating with EJS. You might like how I do it ;)
Alright, if you're ready, read the project description and start away, if you think you're still not ready, make sure you do more research on the above subjects.
You'll get better understanding of the Expressjs framework, the Date Object of JavaScript and just a simple introduction to RESTful API Development.
So when you're done, I encourage you to sign up to FreeCodeCamp and do more of those projects to get better at Back end Web Development. Don't forget to submit your project on there.
Or send it to me, I don't mind at all.
If you're having any problem with my code, just leave an issue and I'll reply as soon as possible.
Enjoy.