From 4cb341715c7479716ff9d1923827051d8ed44df9 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Thu, 4 Mar 2021 22:02:31 +0100 Subject: [PATCH] frontend --- README.md | 2 +- server.ts | 4 ++-- view.ts | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 28d294d..4f073e8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Web app which returns the iconic Hello, World in various locales - [x] Select the locale by id - [x] Use with CLI - [x] Basic HTTP server -- [ ] HTML frontend +- [x] HTML frontend - [ ] Deployment ## Installation diff --git a/server.ts b/server.ts index 26873dd..7e5998e 100644 --- a/server.ts +++ b/server.ts @@ -9,13 +9,13 @@ const get_application = ({ port }: AppOpts): Application => { const router = new Router(); router.get("/", (ctx: RouterContext) => { - ctx.response.body = htmlBody(JSON.stringify(sayRandomHello(), null, 2)); + ctx.response.body = htmlBody(sayRandomHello()); }).get("/:id", (ctx: RouterContext) => { try { const value = ctx.params.id; if (!!value) { const id = new ID(parseInt(value, 10)); - ctx.response.body = htmlBody(JSON.stringify(sayHello(id), null, 2)); + ctx.response.body = htmlBody(sayHello(id)); } } catch (error) { console.error(error); diff --git a/view.ts b/view.ts index 5a7784a..f1fcc04 100644 --- a/view.ts +++ b/view.ts @@ -1,8 +1,10 @@ -export const htmlBody = (content: string) => +import { Locale } from "./src/repositories/locales.ts"; + +export const htmlBody = ({ locale: language, message: hello }: Locale) => ` -