This project represents work from the 12th, 13th, and 14th projects for the web-dev course. These projects build upon each other, first setting up a server with Node.js and Express.js, then integrating with a MongoDB database. The server has a custom RESTful API connecting it to my previous front-end React project (transcompiled w/ Create-React-App, Web-Pack, Babel).
Project 15: Backend user login/creation, middleware auth., Azure cloud deployment
Project 14: Frontend features on React-Around-Auth repo, login/register pages, user auth.
Project 13: RESTful API desing, MongoDB setup, Basic authorization
Project 12: Initial setup of Express.js, file structure, and routing
This server uses Express.js, launching on Local Port 3000.
Mongoose used for models and MongoDB interactions.
- Mongoose
- MongoDB
- Express.js
- Node.js
- Git/GitHub
npm run start
โ to launch the server.
npm run dev
โ to launch the server with the hot reload feature.
- Altered centralized error handler to catch and properly label Celebrate errors
- Added Celebrate prescreening to createCard route
- Added period to middle of URL regex to catch more invalid URLs
- Explicitly defined error handling in createCard and createUser functions
- Modified getUserById() function to return error if findById() returns null data
- Note: When using Mongoose's findById() method, if the given ID param is of the expected length, it will return null instead of an error
- Changed error response codes to 500 for file read errors in cards.js and users.js
- Addressed error handling for server-side file reading by changing promises in both cards.js and users.js, errors now print to user
- Fixed route files:
- Removed extra null route handlers
- Used fs promises for data reading
- Added status 200 to all successful responses
- Rewrote file paths using path.join correctly
- Added error handling to promises that notifies users
- Added "Resource not found" message to app.js to catch all errant urls
- Instead of importing JSON data with require(), used Node's fs module and readFile() method