mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
change semantics
Update README deployment steps and add deploy:secrets script to package.json update local inference script and README update lockfile reconfigure package scripts for development update test execution pass server tests Update README with revised Bun commands and workspace details remove pnpm package manager designator create bun server
This commit is contained in:

committed by
Geoff Seemueller

parent
1055cda2f1
commit
497eb22ad8
57
packages/server/services/ContactService.ts
Normal file
57
packages/server/services/ContactService.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
// ContactService.ts
|
||||
import { types, flow, getSnapshot } from "mobx-state-tree";
|
||||
import ContactRecord from "../models/ContactRecord.ts";
|
||||
|
||||
export default types
|
||||
.model("ContactStore", {})
|
||||
.volatile((self) => ({
|
||||
env: {} as Env,
|
||||
ctx: {} as ExecutionContext,
|
||||
}))
|
||||
.actions((self) => ({
|
||||
setEnv(env: Env) {
|
||||
self.env = env;
|
||||
},
|
||||
setCtx(ctx: ExecutionContext) {
|
||||
self.ctx = ctx;
|
||||
},
|
||||
handleContact: flow(function* (request: Request) {
|
||||
try {
|
||||
const {
|
||||
markdown: message,
|
||||
email,
|
||||
firstname,
|
||||
lastname,
|
||||
} = yield request.json();
|
||||
const contactRecord = ContactRecord.create({
|
||||
message,
|
||||
timestamp: new Date().toISOString(),
|
||||
email,
|
||||
firstname,
|
||||
lastname,
|
||||
});
|
||||
const contactId = crypto.randomUUID();
|
||||
yield self.env.KV_STORAGE.put(
|
||||
`contact:${contactId}`,
|
||||
JSON.stringify(getSnapshot(contactRecord)),
|
||||
);
|
||||
|
||||
yield self.env.EMAIL_SERVICE.sendMail({
|
||||
to: "geoff@seemueller.io",
|
||||
plaintextMessage: `WEBSITE CONTACT FORM SUBMISSION
|
||||
${firstname} ${lastname}
|
||||
${email}
|
||||
${message}`,
|
||||
});
|
||||
|
||||
return new Response("Contact record saved successfully", {
|
||||
status: 200,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error processing contact request:", error);
|
||||
return new Response("Failed to process contact request", {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
}),
|
||||
}));
|
Reference in New Issue
Block a user