-
Notifications
You must be signed in to change notification settings - Fork 0
BrianLovelace128/WebDevProject
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Download Node.js installer from: https://nodejs.org/en/download/ Install: This will install Node and Npm: Node is the runtime environment which will allow you to run your javascript code on the server. Npm (Node Package Manager) is an application which will help you manage and install third party Node modules like Express. Create a new directory for the project. Get this code to that directory. If you are using a unix based shell you may type this command: git clone https://github.com/BrianLovelace128/WebDevProject.git Open the node shell (or powershell or a unix terminal) and navigate to this directory. Now try to run this command: node server.js ^^ This should fail with a "ReferenceError: expressed is not defined" Express is a module used by the server. You must first install this module and make it accessible to the node runtime. You can do this using Npm. Type: npm install express --save Once it's done you will see a series messages showing you all the things that it did. If you type "ls" into the shell, you should also see that a new file called node_modules has been created. DO NOT EDIT THIS FILE! It is for node's internal book keeping. Now you have configured node to run your server. So lets try to start it again. Type: node server.js You should now see the following output on your shell: Server running at http://localhost:8080 What is the "node server.js" command doing? "node" is the name of the application you are running. You are running it with a command line argument to tell it how to run your program. Node then constructs an environment from which it can run javascript code, and starts your program. If you are familiar with javascript, you may associate it with the code inside of <script> tags in your HTML. This javascript is the very same language, but with several BIG differences in it's runtime environment. Mainly, javascript code running with node has no access to a global "document" object. Javascript running within HTML uses this "document" object to manipulate what you see on the web page. From within node, there is no webpage. Node's runtime comes with the ability to create and import javascript modules using "exports" and "require". You'll notice the text "express = require('express');" as the first line. This is importing the express module into the variable express. "var app = express()" is creating an express object, which is in tern used as a listener for the server. What to do next? Take a look at the code in client/index.htm. Unless you're already familiar with angular, it will most likely not make a lot of sense to you. That's okay! You don't need to understand how the front end works in order to set up the back end. And that's the purpose of this project: Write the back end! Look for where index.htm makes its API calls, and get those hooks into the server. Check out out db.json and questions.json to understand the format in which index.htm is sending and expecting data. Use these things to piece together a picture of how the system talks to itself, and fill in the blanks on the server side. And once that's done? You may have noticed that surveys.htm is blank. Now you get to write the front end. Think about the type of data you can present to the user and how you'd like to do it. Read about AJAX and manipulating the DOM (Document Object Model). Here you have control of both the front end and the back end, so you can do whatever you want! Enjoy.
About
Starter project for the UA Node.js practice problem
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published