content updates
This commit is contained in:
26
server/actions/contact.actions.ts
Normal file
26
server/actions/contact.actions.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
'use server';
|
||||
import { createTransport } from "nodemailer";
|
||||
import SMTPTransport from "nodemailer/lib/smtp-transport";
|
||||
|
||||
export async function submitMessage({ from, text }: { from: string, text: string }) {
|
||||
// const transport = createTransport({
|
||||
// host: "unknown",
|
||||
// port: 0,
|
||||
// auth: {
|
||||
// user: env.SMTP_USER,
|
||||
// pass: ""
|
||||
// },
|
||||
// subject: "Contact Form Submission | mikayla.dev",
|
||||
// to: env.SMTP_USER,
|
||||
// from,
|
||||
// text,
|
||||
// } as SMTPTransport.Options);
|
||||
|
||||
// const result = await transport.sendMail(sendMailOptions)
|
||||
// const failed = result.rejected.concat(result.pending).filter(Boolean);
|
||||
|
||||
// if (failed.length) {
|
||||
// throw new Error("Failed to send email verification");
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
import { Project, isProject } from "../entities/project";
|
||||
import createClient from "../services/pg";
|
||||
|
||||
export default class ProjectRepository {
|
||||
async createProject(data: Project) {
|
||||
const client = await createClient();
|
||||
if (!client) return null;
|
||||
await client.connect();
|
||||
|
||||
const { rows } = await client.query(
|
||||
"INSERT INTO project (name, description, created, updated) VALUES ($1, $2, $3, $4) RETURNING *"
|
||||
, [
|
||||
data.name,
|
||||
data.description,
|
||||
data.created,
|
||||
data.updated,
|
||||
]);
|
||||
|
||||
await client.end();
|
||||
|
||||
if (rows.every(row => isProject(row))) {
|
||||
return rows[0] as Project;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async getProjects() {
|
||||
const client = await createClient();
|
||||
if (!client) return null;
|
||||
|
||||
const { rows } = await client.query("SELECT * FROM project");
|
||||
await client.end();
|
||||
|
||||
if (rows.every(row => isProject(row))) {
|
||||
return rows as Project[];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async getProjectById(id: string) {
|
||||
const client = await createClient();
|
||||
if (!client) return null;
|
||||
await client.connect();
|
||||
|
||||
const { rows } = await client.query("SELECT * FROM project WHERE id = $1", [id]);
|
||||
await client.end();
|
||||
|
||||
if (rows.every(row => isProject(row))) {
|
||||
return rows[0] as Project;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { env } from "@/env.mjs";
|
||||
import pg from 'pg';
|
||||
const { Client } = pg;
|
||||
|
||||
export class PostgresError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = "PostgresError";
|
||||
}
|
||||
}
|
||||
|
||||
export default async function createClient() {
|
||||
try {
|
||||
return new Client({
|
||||
connectionString: env.POSTGRES_URL,
|
||||
user: env.POSTGRES_USER,
|
||||
password: env.POSTGRES_PASSWORD,
|
||||
ssl: { rejectUnauthorized: false }
|
||||
});
|
||||
} catch(e) {
|
||||
console.log('error creating client', e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user