briven-engine-signup-smoke.mjs58 lines · main
| 1 | /** |
| 2 | * Local-only: sign up one user on briven-engine (public tenant). |
| 3 | * |
| 4 | * Multitenancy createTenant needs SuperTokens LICENSE_KEY (free key available |
| 5 | * from SuperTokens). Until set, isolation can use public + project metadata, |
| 6 | * or set BRIVEN_ENGINE_LICENSE_KEY on the engine container. |
| 7 | * |
| 8 | * cd apps/api |
| 9 | * BRIVEN_ENGINE_CONNECTION_URI=http://127.0.0.1:3567 bun scripts/briven-engine-signup-smoke.mjs |
| 10 | */ |
| 11 | |
| 12 | import SuperTokens from 'supertokens-node'; |
| 13 | import EmailPassword from 'supertokens-node/recipe/emailpassword'; |
| 14 | import Session from 'supertokens-node/recipe/session'; |
| 15 | |
| 16 | const connectionURI = ( |
| 17 | process.env.BRIVEN_ENGINE_CONNECTION_URI || 'http://127.0.0.1:3567' |
| 18 | ).replace(/\/$/, ''); |
| 19 | |
| 20 | const email = `e2e_${Date.now()}@example.com`; |
| 21 | const password = 'E2eTest!Pass99'; |
| 22 | const tenantId = 'public'; |
| 23 | |
| 24 | console.log('engine', connectionURI); |
| 25 | console.log('tenant', tenantId); |
| 26 | console.log('email', email); |
| 27 | |
| 28 | const hello = await fetch(`${connectionURI}/hello`); |
| 29 | const helloText = await hello.text(); |
| 30 | if (!hello.ok || !/hello/i.test(helloText)) { |
| 31 | console.error('FAIL core hello', hello.status, helloText); |
| 32 | process.exit(1); |
| 33 | } |
| 34 | console.log('✔ core hello', helloText.trim()); |
| 35 | |
| 36 | SuperTokens.init({ |
| 37 | supertokens: { connectionURI }, |
| 38 | appInfo: { |
| 39 | appName: 'Briven Auth e2e', |
| 40 | apiDomain: 'http://localhost:3001', |
| 41 | websiteDomain: 'http://localhost:3000', |
| 42 | apiBasePath: '/v1/auth-core/fdi', |
| 43 | websiteBasePath: '/auth', |
| 44 | }, |
| 45 | recipeList: [Session.init(), EmailPassword.init()], |
| 46 | }); |
| 47 | |
| 48 | const signup = await EmailPassword.signUp(tenantId, email, password); |
| 49 | console.log('signup status', signup.status); |
| 50 | |
| 51 | if (signup.status !== 'OK') { |
| 52 | console.error('FAIL signup', signup); |
| 53 | process.exit(1); |
| 54 | } |
| 55 | |
| 56 | console.log('✔ userId', signup.user.id); |
| 57 | console.log('✔ briven-engine local sign-up proof OK'); |
| 58 | process.exit(0); |