Stork-App / StorkCodeBase

The mission of the Stork app is to provide users with a concise method of symptom-tracking by promoting medical self-advocacy to combat maternal mortality rates.
0 stars 0 forks source link

Users CRUD (BE) - Controllers #42

Open ashleysimone1 opened 9 months ago

thisischu commented 9 months ago

Create user controller has been updated

const createUser = async (req, res) => { const { session, // this req.session property is put here by the handleCookieSessions middleware db: { User }, // this req.db.User property is put here by the addModelsToRequest middleware body: { username, password }, // this req.body property is put here by the client } = req;

// TODO: check if username is taken, what should you return? const user = await User.create(username, password); session.userId = user.id;

res.send(user); };

module.exports = createUser;