Giter Club home page Giter Club logo

timestamp-microservice's Introduction

Clock

Timestamp Microservice ๐Ÿ—“๏ธ

This project is a RESTful API for date manipulation.

Project Made at December 2023 Code Size in bytes Main Language Project Status

About | Technologies | Usage | Resources | Documentation | Feedbacks

๐Ÿ“œ About

Designed to provide a RESTful API that responds to requests made at specific endpoints related to date manipulation for study purposes. It's the first project from freeCodeCamp. Tap here to see the instructions
It supports three main functionalities:

Date Conversion Endpoint:

  • Requests to /api/:date? return a JSON object.
  • Valid date input returns unix timestamp (in milliseconds) and utc representation.
  • Invalid date input results in { error: "Invalid Date" } response.

Date Parsing:

  • Capable of handling dates parsed by new Date(date_string).

Default Behavior:

  • An empty date parameter defaults to the current time.
  • Returns JSON object with unix timestamp and utc representation of the current time.

๐Ÿ—ƒ๏ธ Technologies

  • Node.js
  • Express.js
  • CSS
  • HTML

๐Ÿจ Example Usage (Hypothetical Situation)

Booking System for Appointments or Reservations:

Consider a scenario where users choose a date and time for an appointment. The API can assist in converting and storing these timestamps. When a user selects a date and time for an appointment, the API facilitates the conversion and storage of these timestamps in a standardized format. This ensures smooth communication between different components of the system.

Request:

Make a GET request to /api/appointment with the date parameter:

GET /api/appointment?date=1706544000000

Response:

The API returns a JSON object with the Unix timestamp and UTC string:

{
 "unix": 1706544000000,
 "utc": "Thu, 29 Jun 2023 00:00:00 GMT"
}

How It Works:

  • The code captures the date parameter from the URL (req.params.date) and checks if it's a valid Unix timestamp.
  • If it is, the code converts it to a standard format with Unix timestamp and UTC string.
  • If it's not a valid Unix timestamp, the code attempts to parse it as a date string and provides the corresponding Unix timestamp and UTC string if successful, or an error message if the parsing fails.

๐Ÿ“‹ Documentation

I used Swagger for API documentation, although the project itself doesn't contain many APIs, the purpose of this documentation is to allow manual testing.

To interact with the project, follow these steps:

  1. Install the necessary dependencies. This can be done using the command:
$ npm install
  1. Generate the documentation at project startup. This is useful if you want to view the current state of the API documentation without starting the project. Use the command:
$ npm run start-gendoc
  1. Start the project without generating the documentation. This is typically faster than the previous step, especially if you don't need to view the API documentation right away. Use the command:
$ npm start

Once the project has started, you can access the documentation at: http://localhost:3001/api-docs/

๐Ÿ“จ Feedbacks

I'm a Junior, and I really would like to hear in case there are any tips, corrections, suggestions, or comments about this little project. Your feedback is highly valued, and it helps me improve and learn!

๐Ÿ’ก Resources


timestamp-microservice's People

Contributors

kellymoreira avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.