How many times have you looked glumly at yet another lunch from the same old place and wondered where your classmates were getting theirs? Surely there must be enough recommendations that it would be worth seeing them all in one place.
LunchPad allows you to do just that. Anyone working, studying or otherwise routinely occupying themselves at a given location can start a LunchPad community -- or join one that already exists -- and invite others to join them in posting brief reports on where they have had lunch. Users log in and instantly see the most recent lunch experiences for their community, including time required, price and quality of the fare, and whether or not it was a worthwhile pick. Experiences can be grouped either by vendor or by user, and LunchPad allows you to save your favorite users in order to quickly access just their experiences. Have someone whose recommendations you especially value? Just add them to your favorites.
- Point your browser to lunch-fellows.herokuapp.com.
- Click "Sign Up" and enter your desired username and password; if a username is taken you will be prompted to try another.
- At the next screen you will be able to either join an existing community or create a new one. If you know the community for your location, type that name; otherwise get it from someone else. If your location has no LunchPad community, you can be the first! Just choose a name, enter it, and click "Create a community".
- If you are joining an existing community you will see a list of the most recently-reported restaurants with their average stats for price, time required and lunch-worthines. If you're the first member, it's time to post the first lunch experience!
- To view the 25 most recent experiences for a vendor on the list just click on that vendor. Users' lunch experiences will expand to a full detail view.
- To post a new lunch experience first click the "POST" button at the top of the screen.
- Fill out the form and click "Submit". You will now see your experience in the detail view when that vendor is clicked in the community list.
- To see the experiences for a particular user click the user's name in one of their posts. The experience detail view will expand into the main view. To add the user to your favorites just click "Favorites" at the top of the screen.
- To edit your own previously posted experiences click your name on one of your own posts.
- You will see your 25 most recent posts arranged chronologically under your name.
- To edit, just click the edit button on the post, and then fill out and resubmit the form.
- ES6 coding conventions are standard for this project.
- Core coding standards apply primarily to format and are as defined in
.eslintrc.- NOTE that all scripts use strict mode globally.
- Arrow functions and other modern syntax are preferred, though destructuring is used sparingly.
constandletare generally preferred overvarfor declaring value references.- Generally speaking, code blocks should be offset by one line of white space if they represent a distinct concern; blocks that are chained in some way or otherwise serve a shared purpose may be grouped without interspersed white space.
- Functions and other objects containing nested code blocks may include a line of white space at the end to offset the outer scope from that of the last nested scope; this applies only to the outermost scope of a nested grouping.
- The application proper is organized into a
/liband a/publicdirectory with only ancillary configuration files stored at the project root along with this document and the main executable, calledserver.js - All npm installs are included in the
/node_modulesdirectory, also at project root. Additionally, a third-partynormalize.cssis included in/public/vendors/styles; otherwise, all code originates within this project. - In tree order, the project is organized as follows:
- The
/lib/authdirectory contains gatekeeper middleware for issuing, signing, and checking authorization and user-role data using tokens. /lib/modelscontains Mongoose database Models defining document structure for each of the project's four MongoDB database collections./lib/routescontains backend routes for connecting to the DB in order to carry out CRUD operations./lib/app.jscontains all of the possible calls to each of these routes./lib/error-handler.jsand/lib/setup-mongoose.jsare error handling and database connection middleware, respectively./public/scripts/controllerscontains event handling and CRUD routing files for the front end./public/scripts/modelscontains models for the three sub-views available in Community and User views./public/stylescontains the project-specific css file./testcontains all unit and e2e testing files for the project and is relevant only to developers.
- The
- LunchPad is a single-page app, meaning that
/public/index.htmlis the only html file used. All page views are simulated by jQuery transitions, executed via route calls through the pagejs library, which hide and reveal specified htmlsectionelements. - The initial pathway into the app is as follows:
- On server start
appis invoked as exported by/lib/app.js, and in turn loads/public/index.htmlon the default route. index.htmlloads/public/scripts/controllers/page-routes.jsalong with its other scripts, thus also calling that file'spage('/')front-end route withauthController.renderas its callback (found in/public/scripts/controllers/signup-signin.js) in order to show only the#signup-signin-div(actually a<section>) ofindex.html.- The user now has access to a set of three event listeners in
#signup-signin-div, the last of which emits asubmitevent triggering a call to thepage('/community/:id')front end route in/public/scripts/controllers/page-routes.js, either directly or via/public/scripts/controllers/choose-community, depending on previous input. - This route calls, in succession,
communityController.render,userController.hideUser, andviewController.showCommunityfrom/public/scripts/controllers/community-controller.js,/public/scripts/controllers/see-user.jsand/public/scripts/controllers/view-controller.js, respectively. ¶The first function passes pagejs context parameters to the backend in order to fetch user experience data from the MongoDBUsersandExperiencescollections (see below); ¶the second either empties or conceals any visible DOM elements displaying user-specific information (which may be displayed in subsequent views but at this point has never been populated) and shows the signup/signin view with the#experience-interface<div>to display user experience information; ¶and the third shows the enclosing (again somewhat misleadingly id'd)#community-div<section>as if it were the current page.- Specifically,
communityController.render, uses superagentjs to pass the current user'scommunityIdin an AJAX call to theapp.use(/lunch/community/)backend route with itsensureAuth(/lib/auth/ensure-auth.js) andcommunities(/lib/routes/communities.js) callbacks toExpress.routerin order to assemble user posts (or "experiences") associated with the user's community from the backend, sort them from most to least recent and return them in the response. communityController.renderthen aggregates key data from these chronologically-ordered posts into capsule views according to the vendor reviewed, extracts the relevant community name for display in the#current-community<h3>element of#community-divand passes the rest on toexperienceView.populateHandlebars, a handlebarsjs method that populates the display template for post views, renders the results and finally appends them to the#experiences<div>element of the#community-div<section>.
- Specifically,
- Along with associated navigation and display controls, the resulting page view shows the current user's login name and community along with names of vendors reviewed in that community from most to least-recent, and aggregate review data for each one covering the relative cost, time required, and trade-worthiness of that vendor as averaged from all users posting about the vendor.
- On server start
- Fork from
https://github.com/TheLunchBunch/lunch/tree/development/lib/auth, clone to a local directory and setoriginandupstreamto reflect your personal fork and the organization remote, respectively. - Make sure you have
package.jsonin project root andnmp installin the same destination to get all dependencies up and running. - Make a new branch called
developmentto use as development master. Do all local work on feature branches off ofdevelopmentONLY. - Push ONLY to your own GitHub
originand then make PRs from there. PR will automatically redirect to the upstream; make sure you are setting the PR to merge intodevelopmentand notmaster. - To test, simply type
npm testin the cli. New unit tests should be added to/test/unit-testing, API tests to/test/e2e. - To run, set your local PORT variable as desired and type either
nodemon server.jsornode server.jsin the cli and hitreturn.
- Point a browser to
localhost:PORTto test-drive the app. - Robomongo recommended for direct db management.
- Postman recommended for backend CRUD operations.