nicolai1914
nicolai19145mo ago

Cant build a node that relies on an NPM package

I want to love buildship, But I have not been successfull building a node, that relies on an NPM package, like in this example. It then just says that supabase.auth.signIn is not a function, but this is because the NPM package are not setup correctly in the node I would assume. Is there a way to interact with the node, see whats going on, should I switch to google serverless node ?
import {
createClient
} from '@supabase/supabase-js';

export default async function authenticateUserWithSupabase({
email,
password,
supabaseUrl,
supabaseKey
}) {

// Check for the existence of URL and Key, required for connecting to Supabase
if (!supabaseUrl || !supabaseKey) {
throw new Error('Supabase URL and Key must be provided.');
}

const supabase = createClient(supabaseUrl, supabaseKey);

try {
// Use Supabase client's auth.signIn() method to authenticate user credentials
const {
user,
session,
error
} = await supabase.auth.signIn({
email: email,
password: password
});

if (error) {
// Return an object with the error message to maintain security
return {
error: error.message
};
}

// If authentication is successful, return the session object
return {
session: session
};
} catch (error) {
// In a real-world scenario, you might not want to throw or return the error
// directly as it can contain sensitive details. For example:
// return { error: 'An unexpected error occurred.' };
throw error; // Uncomment the above line and comment this line for production use
}
}
import {
createClient
} from '@supabase/supabase-js';

export default async function authenticateUserWithSupabase({
email,
password,
supabaseUrl,
supabaseKey
}) {

// Check for the existence of URL and Key, required for connecting to Supabase
if (!supabaseUrl || !supabaseKey) {
throw new Error('Supabase URL and Key must be provided.');
}

const supabase = createClient(supabaseUrl, supabaseKey);

try {
// Use Supabase client's auth.signIn() method to authenticate user credentials
const {
user,
session,
error
} = await supabase.auth.signIn({
email: email,
password: password
});

if (error) {
// Return an object with the error message to maintain security
return {
error: error.message
};
}

// If authentication is successful, return the session object
return {
session: session
};
} catch (error) {
// In a real-world scenario, you might not want to throw or return the error
// directly as it can contain sensitive details. For example:
// return { error: 'An unexpected error occurred.' };
throw error; // Uncomment the above line and comment this line for production use
}
}
No description
1 Reply