32 lines
717 B
TypeScript
32 lines
717 B
TypeScript
|
import { authenticated, login, logout, signUp } from "./auth/auth.ts"
|
||
|
import { startBackgroundSessionCleanup } from "./auth/session.ts"
|
||
|
import { listUserBookmarks } from "./bookmark/handlers.ts"
|
||
|
import { migrateDatabase } from "./database.ts"
|
||
|
import { httpHandler } from "./http-handler.ts"
|
||
|
import { createDemoUser } from "./user/user.ts"
|
||
|
|
||
|
function main() {
|
||
|
migrateDatabase()
|
||
|
createDemoUser()
|
||
|
startBackgroundSessionCleanup()
|
||
|
|
||
|
Bun.serve({
|
||
|
routes: {
|
||
|
"/api/login": {
|
||
|
POST: httpHandler(login),
|
||
|
},
|
||
|
"/api/sign-up": {
|
||
|
POST: httpHandler(signUp),
|
||
|
},
|
||
|
"/api/logout": {
|
||
|
POST: authenticated(logout),
|
||
|
},
|
||
|
"/api/bookmarks": {
|
||
|
GET: authenticated(listUserBookmarks),
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
main()
|