1
0
Fork 0

Compare commits

...

2 commits

Author SHA1 Message Date
Sam Therapy 534a098683
Lint + secure headers 2023-10-09 19:56:19 +02:00
Sam Therapy f1fd9c84e8
Only return an image at the root 2023-10-09 17:48:56 +02:00
3 changed files with 30 additions and 12 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)
@ -17,14 +25,16 @@ app.get("/favicon.ico", (c) => c.body(null, 204))
// Politely tell robots to go away
app.get("/robots.txt", (c) => c.text("User-agent: *\nDisallow: /"))
app.all("*", (c) => {
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)