├── sample.env ├── .gitignore ├── .gitpod.yml ├── README.md ├── public └── style.css ├── package.json ├── index.js └── views └── index.html /sample.env: -------------------------------------------------------------------------------- 1 | PORT=3000 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | image: gitpod/workspace-node-lts 2 | 3 | ports: 4 | - port: 3000 5 | onOpen: open-preview 6 | visibility: public 7 | 8 | tasks: 9 | - init: npm install 10 | command: npm run start 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Timestamp Microservice 2 | 3 | This is the boilerplate code for the Timestamp Microservice project. Instructions for building your project can be found at https://www.freecodecamp.org/learn/apis-and-microservices/apis-and-microservices-projects/timestamp-microservice 4 | -------------------------------------------------------------------------------- /public/style.css: -------------------------------------------------------------------------------- 1 | /****** Main Styling ******/ 2 | 3 | body { 4 | font-family: 'Roboto', sans-serif; 5 | font-size: 16px; 6 | color: #222; 7 | background-color: #FaFaFa; 8 | text-align: center; 9 | line-height: 1.4em; 10 | } 11 | 12 | .container { 13 | padding: 0; 14 | margin-top: 40px; 15 | } 16 | 17 | h3 { 18 | margin-top: 30px; 19 | } 20 | 21 | hr { 22 | margin: 25px; 23 | } 24 | 25 | .footer { 26 | margin-top: 40px; 27 | } 28 | 29 | code { 30 | font-family: monospace; 31 | padding: 2px; 32 | color: black; 33 | background-color: #fff; 34 | } 35 | 36 | ul { 37 | list-style-type: none; 38 | } 39 | 40 | li { 41 | margin-bottom: 0.5em; 42 | } 43 | 44 | a { 45 | color: #2574A9; 46 | } 47 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fcc-api-projects-boilerplate", 3 | "version": "0.0.1", 4 | "description": "An FCC Backend Challenge", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js" 8 | }, 9 | "dependencies": { 10 | "express": "^4.12.4", 11 | "cors": "^2.8.0" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/freeCodeCamp/boilerplate-project-timestamp.git" 16 | }, 17 | "bugs": { 18 | "url": "https://github.com/freeCodeCamp/freeCodeCamp/issues" 19 | }, 20 | "homepage": "https://github.com/freeCodeCamp/boilerplate-project-timestamp#readme", 21 | "author": "freeCodeCamp ", 22 | "keywords": [ 23 | "node", 24 | "express", 25 | "freeCodeCamp" 26 | ], 27 | "license": "MIT" 28 | } 29 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // index.js 2 | // where your node app starts 3 | 4 | // init project 5 | var express = require('express'); 6 | var app = express(); 7 | 8 | // enable CORS (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) 9 | // so that your API is remotely testable by FCC 10 | var cors = require('cors'); 11 | app.use(cors({optionsSuccessStatus: 200})); // some legacy browsers choke on 204 12 | 13 | // http://expressjs.com/en/starter/static-files.html 14 | app.use(express.static('public')); 15 | 16 | // http://expressjs.com/en/starter/basic-routing.html 17 | app.get("/", function (req, res) { 18 | res.sendFile(__dirname + '/views/index.html'); 19 | }); 20 | 21 | 22 | // your first API endpoint... 23 | app.get("/api/hello", function (req, res) { 24 | res.json({greeting: 'hello API'}); 25 | }); 26 | 27 | 28 | 29 | // Listen on port set in environment variable or default to 3000 30 | var listener = app.listen(process.env.PORT || 3000, function () { 31 | console.log('Your app is listening on port ' + listener.address().port); 32 | }); 33 | -------------------------------------------------------------------------------- /views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Timestamp Microservice | freeCodeCamp.org 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Timestamp Microservice

13 |
14 |
15 |

Example Usage:

16 | 20 | 21 |

Example Output:

22 |

23 | {"unix":1451001600000, "utc":"Fri, 25 Dec 2015 00:00:00 GMT"} 24 |

25 |
26 | 31 | 32 | 33 | --------------------------------------------------------------------------------