Skip to content

Latest commit

 

History

History
68 lines (45 loc) · 9.03 KB

README.md

File metadata and controls

68 lines (45 loc) · 9.03 KB

Express.js Badge React Badge Redux Toolkit Badge Node.js Badge JavaScript Badge CSS3 Badge Vite Badge Render Badge

Timestamp microservice

An API and GUI React App for it to convert date time between javascript

  • milliseconds timestamps and
  • UTC date time string representation of it

Example:

  • timestamp 1451001600000 and
  • date time string Fri, 25 Dec 2015 00:00:00 GMT

API Usage

call response response JSON format
/ run the React App (HTML) not returned
/api/ get the JSON of current time {"unix":1690638937740,"utc":"Sat, 29 Jul 2023 13:55:37 GMT"}
/api/1451001600000 get the Successful JSON of converted timestamp {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}
/api/Fri, 25 Dec 2015 00:00:00 GMT get the Successful JSON of converted date time string {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}
/api/invalid-date get the Error JSON {"error":"Invalid Date"}

Run the App Online

https://timestamp-microservice-t7m9.onrender.com/ (Will take 30 seconds to spin up the inactive server)

Build and Run App Locally

Pre-dependencies

Program Download link Note
Node.js https://nodejs.org/en/download Also installs npm package manager
Git https://git-scm.com/downloads
(Optional) pnpm https://pnpm.io/installation This is a different package manager used for reduced disk space when installing below packages.
This is optional, the builtin npm will work too with below commands,
Just replace pnpm with npm

Dependencies

Step Terminal commands Notes
clone the repository or download it as ZIP file git clone https://github.com/new-AF/timestamp-microservice.git
enter the directory of the now local repository cd timestamp-microservice
install the dependencies pnpm install
Run the backend server pnpm exec server/server.js
  • For npm run
    npx nodemon server/server.js

  • most API calls like will work except the root paththese will not run the React App because they look for the index.html in the missing directory dist that is created and updated by running pnpm run build each time you edit the React App to run the most recent version.
  • To avoid running the build command each time, access the React App from the frontend server below.
Run the frontend server and the React App pnpm run dev