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
12import SuperTokens from 'supertokens-node';
13import EmailPassword from 'supertokens-node/recipe/emailpassword';
14import Session from 'supertokens-node/recipe/session';
15
16const connectionURI = (
17 process.env.BRIVEN_ENGINE_CONNECTION_URI || 'http://127.0.0.1:3567'
18).replace(/\/$/, '');
19
20const email = `e2e_${Date.now()}@example.com`;
21const password = 'E2eTest!Pass99';
22const tenantId = 'public';
23
24console.log('engine', connectionURI);
25console.log('tenant', tenantId);
26console.log('email', email);
27
28const hello = await fetch(`${connectionURI}/hello`);
29const helloText = await hello.text();
30if (!hello.ok || !/hello/i.test(helloText)) {
31 console.error('FAIL core hello', hello.status, helloText);
32 process.exit(1);
33}
34console.log('✔ core hello', helloText.trim());
35
36SuperTokens.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
48const signup = await EmailPassword.signUp(tenantId, email, password);
49console.log('signup status', signup.status);
50
51if (signup.status !== 'OK') {
52 console.error('FAIL signup', signup);
53 process.exit(1);
54}
55
56console.log('✔ userId', signup.user.id);
57console.log('✔ briven-engine local sign-up proof OK');
58process.exit(0);