Skip to content

Latest commit

 

History

History
executable file
·
67 lines (53 loc) · 1.99 KB

README.md

File metadata and controls

executable file
·
67 lines (53 loc) · 1.99 KB

Before the interview

  1. Create a Supabase account at https://supabase.com

  2. Create a new project and copy the following from your project settings > .env:

    • Project URL
    • Project API anon key
    • Project API service_role key (secret key)
  3. Go to auth inside supabase, click email and disable the confirmation email step.

  4. Seed the database with the following SQL. This will create the users table and a trigger function to automatically create a user entry when a new user signs up via Supabase Auth.

/** 
* USERS
* Note: This table contains user data. Users should only be able to view and update their own data.
*/
create table users (
  -- UUID from auth.users
  id uuid references auth.users not null primary key,
  full_name text,
  avatar_url text,
  -- The customer's billing address, stored in JSON format.
  billing_address jsonb,
  -- Stores your customer's payment instruments.
  payment_method jsonb,
  email text
);
alter table users enable row level security;
create policy "Can view own user data." on users for select using (auth.uid() = id);
create policy "Can update own user data." on users for update using (auth.uid() = id);

/**
* This trigger automatically creates a user entry when a new user signs up via Supabase Auth.
*/ 
create function public.handle_new_user() 
returns trigger as $$
begin
  insert into public.users (id, full_name, email, avatar_url)
  values (new.id, new.raw_user_meta_data->>'full_name', new.email, new.raw_user_meta_data->>'avatar_url');
  return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.handle_new_user();

During the interview

  1. Clone the repository

  2. Go to your project and install dependencies:

    npm install
  3. You can now run the Next.js local development server:

    npm run dev

The starter kit should now be running on localhost:3000.