mirror of
				https://github.com/khairul169/cebol.git
				synced 2025-10-31 03:39:33 +07:00 
			
		
		
		
	feat: add basic auth
This commit is contained in:
		
							parent
							
								
									e27b047f65
								
							
						
					
					
						commit
						ad1ec66e62
					
				| @ -1,2 +1,6 @@ | ||||
| # Static assets/page directory | ||||
| SERVE_STATIC= | ||||
| 
 | ||||
| # Authentication | ||||
| AUTH_USERNAME= | ||||
| AUTH_PASSWORD= | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { Hono } from "hono"; | ||||
| import { basicAuth } from "hono/basic-auth"; | ||||
| import HomePage from "../views/pages/home"; | ||||
| import LinksSection from "../views/sections/links"; | ||||
| import db from "../lib/database"; | ||||
| @ -7,6 +8,13 @@ import type { Link } from "../types/link"; | ||||
| 
 | ||||
| const router = new Hono(); | ||||
| 
 | ||||
| router.use( | ||||
|   basicAuth({ | ||||
|     username: process.env.AUTH_USERNAME || "cebol", | ||||
|     password: process.env.AUTH_PASSWORD || "cebol", | ||||
|   }) | ||||
| ); | ||||
| 
 | ||||
| router.get("/", (c) => { | ||||
|   const links = db | ||||
|     .query("SELECT * FROM links ORDER BY id DESC") | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user