1
0
Fork 0

Lint + secure headers

This commit is contained in:
Sam Therapy 2023-10-09 19:56:19 +02:00
parent f1fd9c84e8
commit 534a098683
Signed by: sam
GPG Key ID: 4D8B07C18F31ACBD
3 changed files with 29 additions and 11 deletions

View File

@ -4,29 +4,37 @@ It's like foxrudor.de for anime girls, but worse
## How to use
Open the web site up and see the predefined anime girls, or define your own tags like:
Open the web site up and see the predefined anime girls, or define your own tags
like:
https://waifurudor.de/?tags=tohsaka_rin,-feet,-underwear,rating:safe
## Server Install
Clone the repo to where ever you will be hosting this and run the following command to install the dependencies.
Clone the repo to where ever you will be hosting this and run the following
command to install the dependencies.
```sh
npm i
```
Now that the dependencies are taken care of you can verify it runs with `npm start` in the root directory of the project. If it tells you it is listening on a port you're probably good to go.
Now that the dependencies are taken care of you can verify it runs with
`npm start` in the root directory of the project. If it tells you it is
listening on a port you're probably good to go.
## Running as a service
I don't know anything so I spent some time (10 minutes) creating the provided sample systemd service file.
I don't know anything so I spent some time (10 minutes) creating the provided
sample systemd service file.
The user in the file needs accesss to the assets directory under `./waifurudor.de/src/public/` so the """app""" can pull images from Danbooru.
The user in the file needs accesss to the assets directory under
`./waifurudor.de/src/public/` so the """app""" can pull images from Danbooru.
## Nginx
Yeah I set up a .conf file for this for my test instance but it sucks and you could probably do better so I won't share it just know it is possible to actually run this as a website.
Yeah I set up a .conf file for this for my test instance but it sucks and you
could probably do better so I won't share it just know it is possible to
actually run this as a website.
### What's next

View File

@ -4,6 +4,6 @@
},
"imports": {
"booru/": "https://deno.land/x/booru@v3.0.2/",
"booru/": "https://deno.land/x/booru@v3.0.2/"
}
}

View File

@ -1,11 +1,19 @@
import { Hono } from "npm:hono"
import { logger } from 'npm:hono/logger'
import { logger } from "npm:hono/logger"
import { compress } from "npm:hono/compress"
import { secureHeaders } from "npm:hono/secure-headers"
import { SearchQuery } from "./helpers/types.ts"
import Search from "./helpers/search.ts"
const app = new Hono()
app.use('*', logger())
export const customLogger = (message: string, ...rest: string[]) => {
console.log(message, ...rest)
}
app.use("*", secureHeaders())
app.use("*", logger(customLogger))
app.use("*", compress())
app.onError((err, c) => {
console.error(err)
@ -20,11 +28,13 @@ app.get("/robots.txt", (c) => c.text("User-agent: *\nDisallow: /"))
app.all("/", (c) => {
const query: SearchQuery = {
site: c.req.query("booru") ?? "safebooru",
tags: c.req.query("tags") ?? c.req.header("Host") === "rint.osaka" ? "tohsaka_rin" : "",
tags: c.req.query("tags") ?? c.req.header("Host") === "rint.osaka"
? "tohsaka_rin"
: "",
}
customLogger(`Host: ${c.req.header("Host")}`)
return Search(c, query)
})
Deno.serve(app.fetch)