mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
- Add SessionConfigSchema with persistIndefinitely, maxHistoryMessages, saveInputHistory - Implement Session.truncateHistory() method for limiting message history - Update HandleMessage to support history truncation and input history toggle - Add config flow through useSession and App components - Add 19 unit tests for SessionConfigSchema - Update CHANGELOG.md and ROADMAP.md for v0.22.2
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
/**
|
|
* Demo application entry point
|
|
*/
|
|
|
|
import { UserService } from "./services/user"
|
|
import { AuthService } from "./auth/service"
|
|
import { createLogger } from "./utils/logger"
|
|
|
|
const logger = createLogger("App")
|
|
|
|
async function main(): Promise<void> {
|
|
logger.info("Starting demo application")
|
|
|
|
// Initialize services
|
|
const userService = new UserService()
|
|
const authService = new AuthService(userService)
|
|
|
|
try {
|
|
// Create a demo user
|
|
const user = await userService.createUser({
|
|
email: "demo@example.com",
|
|
name: "Demo User",
|
|
password: "password123",
|
|
role: "admin",
|
|
})
|
|
|
|
logger.info("Demo user created", { userId: user.id })
|
|
|
|
// Login
|
|
const token = await authService.login("demo@example.com", "password123")
|
|
logger.info("Login successful", { token: token.token })
|
|
|
|
// Verify token
|
|
const verifiedUser = await authService.verifyToken(token.token)
|
|
logger.info("Token verified", { userId: verifiedUser.id })
|
|
|
|
// Logout
|
|
await authService.logout(token.token)
|
|
logger.info("Logout successful")
|
|
} catch (error) {
|
|
logger.error("Application error", error as Error)
|
|
process.exit(1)
|
|
}
|
|
|
|
logger.info("Demo application finished")
|
|
}
|
|
|
|
main()
|