diff --git a/.gitignore b/.gitignore index 4b7f392..9f26340 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ Icon Network Trash Folder Temporary Items .apdisk + +.coverage \ No newline at end of file diff --git a/Makefile b/Makefile index 5bf9fbe..8d2a00f 100644 --- a/Makefile +++ b/Makefile @@ -4,5 +4,8 @@ cli: .PHONY: run run: deno run --allow-net server.ts +.PHONY: lint + deno lint --unstable tests: - deno test --coverage --unstable \ No newline at end of file + deno test --coverage=.coverage --unstable + deno coverage .coverage \ No newline at end of file diff --git a/README.md b/README.md index 4f073e8..b19297a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Hello Server -Web app which returns the iconic Hello, World in various locales +Web app which returns the iconic `Hello, World` in various locales. ## Features @@ -11,6 +11,7 @@ Web app which returns the iconic Hello, World in various locales - [x] Use with CLI - [x] Basic HTTP server - [x] HTML frontend +- [ ] Rebuild using [Aleph.js](https://alephjs.org/docs) - [ ] Deployment ## Installation diff --git a/server.ts b/server.ts index 7e5998e..1ebc671 100644 --- a/server.ts +++ b/server.ts @@ -5,7 +5,7 @@ import { htmlBody } from "./view.ts"; const port = 8000; type AppOpts = { port: number }; -const get_application = ({ port }: AppOpts): Application => { +const getApplication = ({ port }: AppOpts): Application => { const router = new Router(); router.get("/", (ctx: RouterContext) => { @@ -13,7 +13,7 @@ const get_application = ({ port }: AppOpts): Application => { }).get("/:id", (ctx: RouterContext) => { try { const value = ctx.params.id; - if (!!value) { + if (value) { const id = new ID(parseInt(value, 10)); ctx.response.body = htmlBody(sayHello(id)); } @@ -27,13 +27,14 @@ const get_application = ({ port }: AppOpts): Application => { app.use(router.routes()); - app.addEventListener("listen", ({ port }) => { - console.log(`Server listening on http://localhost:${port}/`); - }); + app.addEventListener( + "listen", + () => console.log(`Server listening on http://localhost:${port}/`), + ); return app; }; -const app = get_application({ port }); +const app = getApplication({ port }); await app.listen({ port }); console.log(`Finished`);