fix: lint, scripts and updadte reeadme

This commit is contained in:
Ruidy 2021-05-18 09:23:06 +02:00
parent df159cc6cb
commit 75448f34b0
4 changed files with 15 additions and 8 deletions

2
.gitignore vendored
View file

@ -26,3 +26,5 @@ Icon
Network Trash Folder
Temporary Items
.apdisk
.coverage

View file

@ -4,5 +4,8 @@ cli:
.PHONY: run
run:
deno run --allow-net server.ts
.PHONY: lint
deno lint --unstable
tests:
deno test --coverage --unstable
deno test --coverage=.coverage --unstable
deno coverage .coverage

View file

@ -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

View file

@ -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`);