I’ve created a chat app in React + Vite and I’m preparing it for deployment. I’ve already added the necessary files such as netlify.toml
and _redirects
, but there are just a few questions I have.
Here’s the link to my GitHub repo: GitHub - fantasy-thrill/yapper-msg-app at test
My app also uses the Express framework via Node.js. The app.js
file uses the multer
package to handle images uploaded by users when they create a new account. This package would save image uploads to an "/uploads"
directory in the local version of my project. However, I’ve looked into Netlify Blobs which can store images remotely. I just want to know how I can integrate it into my Node.js file (app.js
) if possible.
Could I do it like this?:
const { getStore } = require("@netlify/blobs")
async function uploadEndpoint(request) {
const fileUpload = request.file;
const userUploadStore = getStore({ name: "UserUpload", consistency: "strong" });
await userUploadStore.set("ProfilePics", fileUpload);
return redirect("/success");
}
app.post("/create-account", async (req, res) => {
try {
const { name, user_id, email, password } = req.body
const realUsers = db.collection(process.env.DB_USER_COLLECTION)
const hashedPassword = await bcrypt.hash(password, 10)
await uploadEndpoint(req)
const newUser = {
name: name,
uid: user_id,
email: email,
password: hashedPassword
}
// Extra info handling...
}
I also want to know if my other files for deployment, such as the TOML and redirects file, are correct. I’ve downloaded the serverless-http
, @netlify/functions
, and @netlify/blobs
packages if necessary. I wrote the serverless-http
into my app.js
file to run the backend Express functions when needed. Please let me know your thoughts.