CS142 Project 6: Appserver and DatabaseDue: Thursday, May 23, 2019 at 11:59 PMIn 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 anew webServer.jssupporting the same interface as Project #5's web server but it also establishes a connection to a database. This allows you to make your appinto a legitimate full stackapplication.SetupYou 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 project5directory ²les into a directory named project6. Into theproject6directory extract the contents of this zip ²le (downloads/project6react.zip). This zip ²le will overwrite the ²les package.json, webServer.js,.jshintrc,and index.htmland add several new ²les and directories. In the unlikely event you had made necessary changes in any of these ²les in yourproject5directory 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 installFor 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 databaseOnce you have installed MongoDB and created the directory for the database as described in the installation instructions (install.html), you can start MongoDB byrunning the command:mongodSince 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 &onLinux/MacOS).Once the MongoDB server is started you can load the photo app data set by running the command:node loadDatabase.jsThis 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 supportfor adding or updating things you should only need to run loadDatabase.jsonce. The program erases whatever is in the database before loading the data set so itis safe to run multiple times.We use the MongooseJS () Object De²nition Language (ODL) to de²ne a schema () to store the photoapp 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 madeon 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.jsprogram where they are used to create the database and the webServer.jswhere they are used to accessthe database. Note: The object schema stored in the database is similar to but necessarily di±erent from the
You've reached the end of your free preview.
Want to read all 3 pages?
Web page, World Wide Web, Database management system