Skip to content

Commit 17d11da

Browse files
committed
Updated the user data model to include passwords.
1 parent 80f0d27 commit 17d11da

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

shatter-backend/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shatter-backend/src/controllers/user_controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ export const createUser = async (req: Request, res: Response) => {
2424
try {
2525
// Destructure the req body sent by the client
2626
// The ?? {} ensures we don't get error if req.body is undefined
27-
const { name, email } = req.body ?? {};
27+
const { name, email, password} = req.body ?? {};
2828

2929
// Basic validation to ensure both name and email are provided
3030
// if not respond with bad request and stop further processes
31-
if (!name || !email) {
32-
return res.status(400).json({ error: 'name and email required' });
31+
if (!name || !email || !password) {
32+
return res.status(400).json({ error: 'name, email required, and password' });
3333
}
3434

3535
// create a new user doc in DB using Mongoose's .create()
36-
const user = await User.create({ name, email });
36+
const user = await User.create({ name, email, password});
3737
// respond with "created" and send back created user as JSON
3838
res.status(201).json(user);
3939
} catch(err: any) {

shatter-backend/src/models/user.ts

Whitespace-only changes.

shatter-backend/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function start() {
2121

2222
// start listening for incoming HTTP requests on chosen port
2323
app.listen(PORT, () => {
24-
console.log('Server running on http://localhost:${PORT}');
24+
console.log(`Server running on http://localhost:${PORT}`);
2525
});
2626
} catch (err) { // if connection goes wrong, log the error
2727
console.error('Failed to start server:', err);

0 commit comments

Comments
 (0)