Created
January 15, 2026 13:31
-
-
Save miku-orb/0a36748b3d765720471d4a40fba304e7 to your computer and use it in GitHub Desktop.
HAN Login Test (REST web service login, from a local file)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| bun run han_login_test.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const server = Bun.serve({ | |
| port: "8001", | |
| hostname: "127.0.0.1", | |
| routes: { | |
| "/han_login": { | |
| POST: async req => { | |
| const data = await import("./han_login_test_users.toml"); | |
| const users = data.users as { username: string; password: string }[]; | |
| const body = await req.json(); | |
| const valid = users.some(u => u.username === body.user && u.password === body.pass); | |
| const our_response = { valid }; | |
| console.log({ req, body, our_response }); | |
| return Response.json(our_response); | |
| }, | |
| }, | |
| }, | |
| fetch(req) { | |
| console.log("Not found fallback", { req }); | |
| return new Response("Not Found", { status: 404 }); | |
| }, | |
| }); | |
| console.log(`Server running at ${server.url}`); | |
| // In HAN Cconfig: | |
| // Description: REST web service Login | |
| // Label: LOCAL-FILE-TEST | |
| // Service configuration | |
| // PasswordField: pass | |
| // UserAgent: Test | |
| // UserField: user | |
| // Url: https://127.0.0.1:8001/han_login | |
| // ResponseField: valid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [[users]] | |
| username = "user1" | |
| password = "pass1" | |
| [[users]] | |
| username = "user2" | |
| password = "pass2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment