-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pedro Rosemberg
authored
Jul 27, 2024
1 parent
af022af
commit 519d668
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { createClient } = require('@supabase/supabase-js'); | ||
const express = require('express'); // Se você estiver usando Express | ||
|
||
const app = express(); | ||
const port = 3000; | ||
|
||
// Substitua pelas suas credenciais do Supabase | ||
const supabaseUrl = 'https://seu-projeto.supabase.co'; | ||
const supabaseAnonKey = 'sua-chave-anonima'; | ||
|
||
const supabase = createClient(supabaseUrl, supabaseAnonKey); | ||
|
||
// Rota para inserir dados no Supabase | ||
app.post('/salvar-dado', async (req, res) => { | ||
const { nome, email } = req.body; // Adapte para os campos do seu formulário | ||
const { data, error } = await supabase | ||
.from('sua_tabela') | ||
.insert([{ nome, email }]) | ||
.select(); | ||
|
||
if (error) { | ||
console.error(error); | ||
res.status(500).json({ error: 'Erro ao inserir dados' }); | ||
} else { | ||
res.json(data); | ||
} | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Servidor rodando na porta ${port}`); | ||
}); |