Skip to content

Commit

Permalink
Create server.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Rosemberg authored Jul 27, 2024
1 parent af022af commit 519d668
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions server.js
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}`);
});

0 comments on commit 519d668

Please sign in to comment.