diff --git a/express/package.json b/express/package.json index 4a957c2..8a884d1 100644 --- a/express/package.json +++ b/express/package.json @@ -15,12 +15,14 @@ "dependencies": { "@ianvs/prettier-plugin-sort-imports": "^4.7.0", "@types/node": "^24.10.1", + "@types/nunjucks": "^3.2.6", "@vercel/ncc": "^0.38.4", "express": "^5.1.0", "nodemon": "^3.1.11", "nunjucks": "^3.2.4", "path-to-regexp": "^8.3.0", "prettier": "^3.6.2", + "ts-luxon": "^6.2.0", "ts-node": "^10.9.2", "tsx": "^4.20.6", "typescript": "^5.9.3", diff --git a/express/pnpm-lock.yaml b/express/pnpm-lock.yaml index 240c29f..c633781 100644 --- a/express/pnpm-lock.yaml +++ b/express/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@types/node': specifier: ^24.10.1 version: 24.10.1 + '@types/nunjucks': + specifier: ^3.2.6 + version: 3.2.6 '@vercel/ncc': specifier: ^0.38.4 version: 0.38.4 @@ -32,6 +35,9 @@ importers: prettier: specifier: ^3.6.2 version: 3.6.2 + ts-luxon: + specifier: ^6.2.0 + version: 6.2.0 ts-node: specifier: ^10.9.2 version: 10.9.2(@types/node@24.10.1)(typescript@5.9.3) @@ -371,6 +377,9 @@ packages: '@types/node@24.10.1': resolution: {integrity: sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==} + '@types/nunjucks@3.2.6': + resolution: {integrity: sha512-pHiGtf83na1nCzliuAdq8GowYiXvH5l931xZ0YEHaLMNFgynpEqx+IPStlu7UaDkehfvl01e4x/9Tpwhy7Ue3w==} + '@types/qs@6.14.0': resolution: {integrity: sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==} @@ -814,6 +823,10 @@ packages: resolution: {integrity: sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==} hasBin: true + ts-luxon@6.2.0: + resolution: {integrity: sha512-4I1tkW6gtydyLnUUIvfezBl5B3smurkgKmHdMOYI2g9Fn3Zg1lGJdhsCXu2VNl95CYbW2+SoNtStcf1CKOcQjw==} + engines: {node: '>=18'} + ts-node@10.9.2: resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true @@ -1103,6 +1116,8 @@ snapshots: dependencies: undici-types: 7.16.0 + '@types/nunjucks@3.2.6': {} + '@types/qs@6.14.0': {} '@types/range-parser@1.2.7': {} @@ -1588,6 +1603,8 @@ snapshots: touch@3.1.1: {} + ts-luxon@6.2.0: {} + ts-node@10.9.2(@types/node@24.10.1)(typescript@5.9.3): dependencies: '@cspotcode/source-map-support': 0.8.1 diff --git a/express/routes.ts b/express/routes.ts index 7c7e7e4..65b9312 100644 --- a/express/routes.ts +++ b/express/routes.ts @@ -1,5 +1,7 @@ /// +import nunjucks from "nunjucks"; +import { DateTime } from "ts-luxon"; import { contentTypes } from "./content-types"; import { multiHandler } from "./handlers"; import { HttpCode, httpCodes } from "./http-codes"; @@ -72,6 +74,29 @@ const routes: Route[] = [ }; }, }, + { + path: "/time", + methods: ["GET"], + handler: async (_req): Promise => { + const now = DateTime.now(); + const template = ` + + + + {{ now }} + + +`; + + const result = nunjucks.renderString(template, { now }); + + return { + code: httpCodes.success.OK, + contentType: contentTypes.text.html, + result, + }; + }, + }, ]; export { routes };