CS142 Project 6_ Appserver and Database.pdf - CS142 Project 6 Appserver and Database Due Thursday at 11:59 PM In this project you will start up a

CS142 Project 6_ Appserver and Database.pdf - CS142 Project...

This preview shows page 1 - 2 out of 3 pages.

CS142 Project 6: Appserver and Database Due: Thursday, May 23, 2019 at 11:59 PM In this project you will start up a database system and convert your Photo Sharing App you built in Project #5 to fetch the views' models from it. We provide you a new webServer.js supporting the same interface as Project #5's web server but it also establishes a connection to a database. This allows you to make your app into a legitimate full stack application. Setup You should have MongoDB and Node.js installed on your system. If not, follow the installation instructions (install.html) now. Project #6 setup is di±erent from the previous projects. You start by making a copy of your project5 directory ²les into a directory named project6 . Into the project6 directory extract the contents of this zip ²le (downloads/project6react.zip). This zip ²le will overwrite the ²les package.json , webServer.js , .jshintrc, and index.html and add several new ²les and directories. In the unlikely event you had made necessary changes in any of these ²les in your project5 directory you will need to reapply the changes after doing the unzip. Once you have the Project #6 ²les, fetch the dependent software using the command: npm install For this and the rest of the assignments in the course we will be running all three tiers of the web application (browser, web server, database) on your local machine. Start and initialize the MongoDB database Once you have installed MongoDB and created the directory for the database as described in the installation instructions (install.html), you can start MongoDB by running the command: mongod Since this command doesn't return until the database is shutdown you will want to either run it in a separate window or as a background process (e.g. mongod & on Linux/MacOS). Once the MongoDB server is started you can load the photo app data set by running the command: node loadDatabase.js This program loads the fake model data from previous projects (i.e. modelData/photoApp.js ) into the database. Since our app currently doesn't have any support for adding or updating things you should only need to run loadDatabase.js once. The program erases whatever is in the database before loading the data set so it is safe to run multiple times. We use the MongooseJS () Object De²nition Language (ODL) to de²ne a schema () to store the photo app data in MongoDB. The schema de²nition ²les are in the directory schema : schema/user.js - De²nes the User collection containing the objects describing each user. schema/photo.js - De²nes the Photos collection containing the objects describing each photo. It also de²nes the objects we use to store the comments made on the photo. schema/schemaInfo.js - De²nes the SchemaInfo collection containing the object describing the schema version. These ²les are loaded both into the loadDatabase.js program where they are used to create the database and the webServer.js where they are used to access the database. Note: The object schema stored in the database is similar to but necessarily di±erent from the
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read all 3 pages?

  • Fall '14
  • JeannetteE.Myers
  • Web page, World Wide Web, Database management system

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture