import { serveStatic } from 'hono/bun'
import { logger } from 'hono/logger'
import { cors } from 'hono/cors'
import { type WithSession, Hono, sessionMiddleware, store } from './Hono'
import home from './pages/home'
import login from './routes/login'
import logout from './routes/logout'
import auth from './routes/auth'
const app = new Hono<WithSession>()
app.use(
'*',
sessionMiddleware({
store,
encryptionKey: Bun.env.SAGE_SESSION_ENCRYPTION_KEY,
// Required for CookieStore, recommended for others
expireAfterSeconds: 15 * 60, // Expire session after 15 minutes of inactivity
cookieOptions: {
sameSite: 'Lax', // Recommended for basic CSRF protection in modern browsers
path: '/', // Required for this library to work properly
httpOnly: true, // Recommended to avoid XSS attacks
},
}),
)
app.use(logger())
app.use(cors())
app.use('/*', serveStatic({ root: './src/public' }))
app.route('/', home)
app.route('/login', login)
app.route('/logout', logout)
app.route('/auth', auth)
export default app