The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Adds a Netlify deploy button
Paul Copplestone1e49eaeb7e05
diff --git a/examples/slack-clone/README.md b/examples/slack-clone/README.mdindex f6c741f4d31..e3d0b67293d 100644--- a/examples/slack-clone/README.md+++ b/examples/slack-clone/README.md@@ -13,6 +13,13 @@ Build a simple slack clone using Supabase, Postgres and React hooks.## How to use+++[)](https://github.com/supabase/supabase/tree/master/examples/slack-clone)+++## For developers+**Clone the this folder**```sh@@ -32,14 +39,7 @@ cd examples/slack-clone-basicnpm install```-**Start the backend**--```sh-# Open a terminal and run:-docker-compose up-```--**Start the frontent**+**Start the frontend**```sh# Open a terminal and run:diff --git a/examples/slack-clone/db/00-schema.sql b/examples/slack-clone/db/00-schema.sqldeleted file mode 100644index a3b008059b0..00000000000--- a/examples/slack-clone/db/00-schema.sql+++ /dev/null@@ -1,37 +0,0 @@---- Create the Replication publication-CREATE PUBLICATION supabase_realtime FOR ALL TABLES;---- USERS-CREATE TYPE public.user_status AS ENUM ('ONLINE', 'OFFLINE');-CREATE TABLE public.users (- id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,- auth_id uuid REFERENCES auth.users,- username text,- status user_status DEFAULT 'ONLINE'::public.user_status-);-ALTER TABLE public.users REPLICA IDENTITY FULL; -- Send "previous data" to supabase-COMMENT ON COLUMN public.users IS 'Profile data for each user.';-COMMENT ON COLUMN public.users.auth_id IS 'References the internal Supabase Auth user.';---- CHANNELS-CREATE TABLE public.channels (- id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,- inserted_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- data jsonb DEFAULT null,- slug text NOT NULL UNIQUE-);-ALTER TABLE public.users REPLICA IDENTITY FULL; -- Send "previous data" to supabase-COMMENT ON COLUMN public.channels IS 'Topics and groups.';---- MESSAGES-CREATE TABLE public.messages (- id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,- inserted_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- message text,- user_id bigint REFERENCES users NOT NULL,- channel_id bigint REFERENCES channels NOT NULL-);-ALTER TABLE public.messages REPLICA IDENTITY FULL; -- Send "previous data" to supabase-COMMENT ON COLUMN public.channels IS 'Individual messages sent by each user.';-diff --git a/examples/slack-clone/db/01-dummy-data.sql b/examples/slack-clone/db/01-dummy-data.sqldeleted file mode 100644index 6d1bbf6ad95..00000000000--- a/examples/slack-clone/db/01-dummy-data.sql+++ /dev/null@@ -1,19 +0,0 @@-INSERT INTO- public.users (username)-VALUES- ('supabot'),- ('kiwicopple'),- ('awailas'),- ('dragarcia');--INSERT INTO- public.channels (slug)-VALUES- ('public'),- ('random');--INSERT INTO- public.messages (message, channel_id, user_id)-VALUES- ('Hello World 👋', 1, 1),- ('Perfection is attained, not when there is nothing more to add, but when there is nothing left to take away.', 2, 1);\ No newline at end of filediff --git a/examples/slack-clone/docker-compose.yml b/examples/slack-clone/docker-compose.ymldeleted file mode 100644index e50eea43387..00000000000--- a/examples/slack-clone/docker-compose.yml+++ /dev/null@@ -1,31 +0,0 @@-version: '3'--services:- supabase:- image: supabase/supabase-dev:0.1.9- ports:- - "8000:8000"- environment:- DB_HOST: postgres- DB_NAME: postgres- DB_USER: postgres- DB_PASSWORD: postgres- DB_PORT: 5432- DB_SCHEMA: public- depends_on:- - postgres- postgres:- image: postgres:12- ports:- - "5432:5432"- volumes:- - ./db:/docker-entrypoint-initdb.d/- command:- - "postgres"- - "-c"- - "wal_level=logical"- environment:- POSTGRES_DB: postgres- POSTGRES_USER: postgres- POSTGRES_PASSWORD: postgres- POSTGRES_PORT: 5432diff --git a/examples/slack-clone/netlify.toml b/examples/slack-clone/netlify.tomlnew file mode 100644index 00000000000..4d7c238cc84--- /dev/null+++ b/examples/slack-clone/netlify.toml@@ -0,0 +1,8 @@+[build]+ base = "examples/slack-clone"+ publish = "out"+ command = "npm run build"++[template.environment]+ NEXT_PUBLIC_SUPABASE_URL = "Find the Supabase URL in the your auto-generated docs at app.supabase.io"+ NEXT_PUBLIC_SUPABASE_KEY = "Add your Supabase client key"\ No newline at end of filediff --git a/examples/slack-clone/package-lock.json b/examples/slack-clone/package-lock.jsonindex 7b971f2c4da..f984fc5409f 100644--- a/examples/slack-clone/package-lock.json+++ b/examples/slack-clone/package-lock.json@@ -233,64 +233,6 @@"@babel/types": "^7.10.4"}},- "@babel/helper-member-expression-to-functions": {- "version": "7.10.5",- "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.5.tgz",- "integrity": "sha512-HiqJpYD5+WopCXIAbQDG0zye5XYVvcO9w/DHp5GsaGkRUaamLj2bEtu6i8rnGGprAhHM3qidCMgp71HF4endhA==",- "requires": {- "@babel/types": "^7.10.5"- }- },- "@babel/helper-module-imports": {- "version": "7.10.4",- "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz",- "integrity": "sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==",- "requires": {- "@babel/types": "^7.10.4"- }- },- "@babel/helper-module-transforms": {- "version": "7.10.5",- "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.5.tgz",- "integrity": "sha512-4P+CWMJ6/j1W915ITJaUkadLObmCRRSC234uctJfn/vHrsLNxsR8dwlcXv9ZhJWzl77awf+mWXSZEKt5t0OnlA==",- "requires": {- "@babel/helper-module-imports": "^7.10.4",- "@babel/helper-replace-supers": "^7.10.4",- "@babel/helper-simple-access": "^7.10.4",- "@babel/helper-split-export-declaration": "^7.10.4",- "@babel/template": "^7.10.4",- "@babel/types": "^7.10.5",- "lodash": "^4.17.19"- }- },- "@babel/helper-optimise-call-expression": {- "version": "7.10.4",- "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz",- "integrity": "sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg==",- "requires": {- "@babel/types": "^7.10.4"- }- },- "@babel/helper-replace-supers": {- "version": "7.10.4",- "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.4.tgz",- "integrity": "sha512-sPxZfFXocEymYTdVK1UNmFPBN+Hv5mJkLPsYWwGBxZAxaWfFu+xqp7b6qWD0yjNuNL2VKc6L5M18tOXUP7NU0A==",- "requires": {- "@babel/helper-member-expression-to-functions": "^7.10.4",- "@babel/helper-optimise-call-expression": "^7.10.4",- "@babel/traverse": "^7.10.4",- "@babel/types": "^7.10.4"- }- },- "@babel/helper-simple-access": {- "version": "7.10.4",- "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.4.tgz",- "integrity": "sha512-0fMy72ej/VEvF8ULmX6yb5MtHG4uH4Dbd6I/aHDb/JVg0bbivwt9Wg+h3uMvX+QSFtwr5MeItvazbrc4jtRAXw==",- "requires": {- "@babel/template": "^7.10.4",- "@babel/types": "^7.10.4"- }- },"@babel/helper-split-export-declaration": {"version": "7.10.4","resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.4.tgz",@@ -304,16 +246,6 @@"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz","integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw=="},- "@babel/helpers": {- "version": "7.10.4",- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz",- "integrity": "sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA==",- "requires": {- "@babel/template": "^7.10.4",- "@babel/traverse": "^7.10.4",- "@babel/types": "^7.10.4"- }- },"@babel/highlight": {"version": "7.10.4","resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz",@@ -4224,14 +4156,6 @@"websocket": "^1.0.31"},"dependencies": {- "@babel/runtime": {- "version": "7.10.5",- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.10.5.tgz",- "integrity": "sha512-otddXKhdNn7d0ptoFRHtMLa8LqDxLYwTjB4nYgM1yy5N6gU/MUf8zqyyLltCH3yAVitBzmwK4us+DD0l/MauAg==",- "requires": {- "regenerator-runtime": "^0.13.4"- }- },"query-string": {"version": "6.13.1","resolved": "https://registry.npmjs.org/query-string/-/query-string-6.13.1.tgz",@@ -4242,11 +4166,6 @@"strict-uri-encode": "^2.0.0"}},- "regenerator-runtime": {- "version": "0.13.7",- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",- "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew=="- },"strict-uri-encode": {"version": "2.0.0","resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",@@ -4255,9 +4174,9 @@}},"@supabase/supabase-js": {- "version": "0.35.2",- "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-0.35.2.tgz",- "integrity": "sha512-tlwTx3LHWnH1ZkwO7P1QVZBlyv/XsVZZQw53B+Vfy9XOGrp987eFSof/o9w9CSM+yQ256Lw2J+DCDbvEaFmuzQ==",+ "version": "0.35.8",+ "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-0.35.8.tgz",+ "integrity": "sha512-hiETKk/zON5Lkva3Kf4k9Jh9rjY9BCHXs/RY5BA3UCqj68ohYu45/KfouIaIx3z5WCuKlw/ZSEvyQaYNTWF1Zg==","requires": {"@supabase/doctest-js": "^0.1.0","@supabase/postgrest-js": "^0.17.0",@@ -4339,9 +4258,9 @@}},"@types/node": {- "version": "14.0.26",- "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.26.tgz",- "integrity": "sha512-W+fpe5s91FBGE0pEa0lnqGLL4USgpLgs4nokw16SrBBco/gQxuua7KnArSEOd5iaMqbbSHV10vUDkJYJJqpXKA=="+ "version": "14.0.27",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz",+ "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g=="},"@types/normalize-package-data": {"version": "2.4.0",diff --git a/examples/slack-clone/package.json b/examples/slack-clone/package.jsonindex f1674049da0..27eabb519ad 100644--- a/examples/slack-clone/package.json+++ b/examples/slack-clone/package.json@@ -4,11 +4,12 @@"license": "MIT","scripts": {"dev": "next",+ "export": "next export","build": "next build","start": "next start"},"dependencies": {- "@supabase/supabase-js": "^0.35.2",+ "@supabase/supabase-js": "^0.35.8","next": "^9.5.0","react": "^16.7.0","react-dom": "^16.7.0",diff --git a/examples/slack-clone/pages/_app.js b/examples/slack-clone/pages/_app.jsindex 445f022874c..4b31fd7769c 100644--- a/examples/slack-clone/pages/_app.js+++ b/examples/slack-clone/pages/_app.js@@ -22,30 +22,25 @@ export default class SupabaseSlackClone extends App {else Router.push('/')}- /**- * Dummy function- * DO NOT USE IN PRODUCTION- */- signIn = async (username) => {- var user = {}- console.log('username', username)- let { body } = await supabase.from('users').match({ username }).select('id, username')- console.log('body', body)- if (!body.length) {- let res = await supabase.from('users').insert([{ username }], { upsert: true })- console.log('res', res)+ signIn = async (id, username) => {+ try {let { body } = await supabase.from('users').match({ username }).select('id, username')- user = body[0].id- } else {- user = body[0].id+ const existing = body[0]+ const { body: user } = existing?.id+ ? await supabase.from('users').update({ id, username }).match({ id }).single()+ : await supabase.from('users').insert([{ id, username }]).single()++ localStorage.setItem('supabase-slack-clone', user.id)+ this.setState({ user: user.id }, () => {+ Router.push('/channels/[id]', '/channels/1')+ })+ } catch (error) {+ console.log('error', error)}- localStorage.setItem('supabase-slack-clone', user)- this.setState({ user }, () => {- Router.push('/channels/[id]', '/channels/1')- })}signOut = () => {+ supabase.auth.logout()localStorage.removeItem('supabase-slack-clone')this.setState({ user: null })Router.push('/')diff --git a/examples/slack-clone/pages/index.js b/examples/slack-clone/pages/index.jsindex 9570f127f3f..94692480654 100644--- a/examples/slack-clone/pages/index.js+++ b/examples/slack-clone/pages/index.js@@ -16,12 +16,13 @@ const Home = () => {const handleLogin = async (type, username, password) => {try {- const user =+ const { body } =type == 'LOGIN'? await supabase.auth.login(username, password): await supabase.auth.signup(username, password)- let parsed = JSON.parse(user.text)- if (!!parsed) signIn(username)++ const user = await supabase.auth.user()+ if (!!user) signIn(user.id, user.email)} catch (error) {console.log('error', error)alert(error.error_description || error)@@ -45,7 +46,7 @@ const Home = () => {<div className="mb-4"><label className="font-bold text-grey-darker block mb-2">Password</label><input- type="text"+ type="password"className="block appearance-none w-full bg-white border border-grey-light hover:border-grey px-2 py-2 rounded shadow"placeholder="Your password"value={password}