mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-06 01:56:40 +00:00
fix: lint, scripts and updadte reeadme
This commit is contained in:
parent
df159cc6cb
commit
75448f34b0
4 changed files with 15 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -26,3 +26,5 @@ Icon
|
|||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
.coverage
|
||||
5
Makefile
5
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
|
||||
deno test --coverage=.coverage --unstable
|
||||
deno coverage .coverage
|
||||
|
|
@ -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
|
||||
|
|
|
|||
13
server.ts
13
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`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue