import { Hono } from "hono";
import { createClient } from '@neondatabase/neon-js';
const app = new Hono();
const client = createClient({
auth: {
url: Deno.env.get("NEON_AUTH_URL"),
},
dataApi: {
url: Deno.env.get("NEON_DATA_API_URL"),
},
});
app.post('/', async (c) => {
const { username } = await c.req.json();
if (!username) return c.json({
error: "Invalid Input", message: "The request body is missing the required field."}, 400);
const result = await client.auth.signUp.email({
email: '[email protected]',
password: 'password123',
name: username,
})
if (result.error) {
console.error('Sign up error:', result.error.message)
} else {
console.log('User created:', result.data.user)
}
return c.json(result.data);
});
Deno.serve(app.fetch);
import { Hono } from "hono";
import { createClient } from '@neondatabase/neon-js';
const app = new Hono();
const client = createClient({
auth: {
url: Deno.env.get("NEON_AUTH_URL"),
},
dataApi: {
url: Deno.env.get("NEON_DATA_API_URL"),
},
});
app.post('/', async (c) => {
const { username } = await c.req.json();
if (!username) return c.json({
error: "Invalid Input", message: "The request body is missing the required field."}, 400);
const result = await client.auth.signUp.email({
email: '[email protected]',
password: 'password123',
name: username,
})
if (result.error) {
console.error('Sign up error:', result.error.message)
} else {
console.log('User created:', result.data.user)
}
return c.json(result.data);
});
Deno.serve(app.fetch);