Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"intmax2",
"blockchain",
"function",
"api"
"api",
"token"
],
"engines": {
"node": ">=20.0.0",
Expand Down
5 changes: 5 additions & 0 deletions packages/indexer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ curl http://localhost:3000/v1/health | jq
curl -X GET 'http://localhost:3000/v1/indexer/builders' | jq
curl -X GET 'http://localhost:3000/v1/indexer/builders/meta' | jq
curl -X GET 'http://localhost:3000/v1/indexer/builders/registration/0x...' | jq

# for proxy
curl -X GET 'http://localhost:3000/v1/proxy/meta' | jq

# time
curl -X GET 'http://localhost:3000/v1/time' | jq
```
7 changes: 7 additions & 0 deletions packages/indexer/src/controllers/time.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Context } from "hono";
import * as timeService from "../services/time.service";

export const getTime = (c: Context) => {
const result = timeService.getTime();
return c.json(result);
};
5 changes: 5 additions & 0 deletions packages/indexer/src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BASE_PATH, healthRoute } from "@intmax2-function/shared";
import { route as indexerRoute } from "./indexer.route";
import { route as proxyRoute } from "./proxy.route";
import { route as timeRoute } from "./time.route";

export const routes = [
{
Expand All @@ -15,4 +16,8 @@ export const routes = [
path: `${BASE_PATH}/proxy`,
route: proxyRoute,
},
{
path: `${BASE_PATH}/time`,
route: timeRoute,
},
];
6 changes: 6 additions & 0 deletions packages/indexer/src/routes/time.route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Hono } from "hono";
import * as timeController from "../controllers/time.controller";

export const route = new Hono();

route.get("/", timeController.getTime);
35 changes: 35 additions & 0 deletions packages/indexer/src/services/time.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export const getTime = () => {
const now = new Date();

const year = now.getUTCFullYear();
const month = now.getUTCMonth() + 1;
const day = now.getUTCDate();
const hour = now.getUTCHours();
const minute = now.getUTCMinutes();
const seconds = now.getUTCSeconds();
const milliSeconds = now.getUTCMilliseconds();

const dateTime = now.toISOString();
const date = `${month.toString().padStart(2, "0")}/${day.toString().padStart(2, "0")}/${year}`;
const time = `${hour.toString().padStart(2, "0")}:${minute.toString().padStart(2, "0")}`;
const dayOfWeek = now.toLocaleDateString("en-US", {
weekday: "long",
timeZone: "UTC",
});

return {
year,
month,
day,
hour,
minute,
seconds,
milliSeconds,
dateTime,
date,
time,
timeZone: "UTC",
dayOfWeek,
dstActive: false,
};
};