Skip to content

danmanor/Landscape

Repository files navigation

Landscape

An Node.js-Express-Mongo app for sharing landscapes from around the world

check out the heroku hosted app at https://landscapes-view.herokuapp.com

Code Overview

Dependencies

  • expressjs - The server for handling and routing HTTP requests
  • express-session - A node.js module middleware for handling sessions compatible with Express
  • express-mongo-sanitize - Express 4.x middleware which sanitizes user-supplied data to prevent MongoDB Operator Injection
  • connect-mongo MongoDB session store for Connect and Express.
  • mongoose - For modeling and mapping MongoDB data to javascript
  • passport - Express-compatible authentication middleware for Node.js
  • passport-local - passport strategy for authenticating with a username and password
  • passport-local-mongoose - mongoose plugin that simplifies building username and password login with passport
  • method-override - Lets you use HTTP verbs such as PUT or DELETE in places where the client doesn't support it
  • ejs - Embedded JavaScript templates
  • ejs-mate - Express 4.x layout, partial and block template functions for the EJS template engine.
  • dotenv - module that loads environment variables from a .env file into process.env.
  • connect-flash - Flash messages are stored in the session
  • multer - Multer is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files
  • cloudinary - allows you to quickly and easily integrate your application with Cloudinary
  • multer-storage-cloudinary - A multer storage engine for Cloudinary
  • sanitize-html - provides a simple HTML sanitizer with a clear API
  • joi - schema description language and data validator for JavaScript
  • @mapbox/mapbox-sdk - A JS SDK for working with Mapbox APIs

Application Structure

  • app.js - The entry point to our application. This file configuring mongoose, session, etc. It starts the server and handling errors.
  • routes/ - This folder contains the route definitions for our API.
  • models/ - This folder contains the schema definitions for our Mongoose models.
  • conrollers/ - This folder contains the routes logic.
  • middleware.js - This file contains the middleware for the routes

Error Handling

  • ExpressError class - A class which represents an error.
  • catchAsync - a wrapper function that passes the error to the error handle middleware
  • error middleware - a middleware that renders the error view with a message.

Authentication

Utilize passport and passport-local strategy to authenticate users.

Authorization

Utilize middleware to authorize only the author to change a landscape.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published