diff --git a/quiz copy/index.js b/quiz copy/index.js new file mode 100644 index 0000000..440ef30 --- /dev/null +++ b/quiz copy/index.js @@ -0,0 +1 @@ +require('./src/server'); diff --git a/quiz copy/package.json b/quiz copy/package.json new file mode 100644 index 0000000..d2473bf --- /dev/null +++ b/quiz copy/package.json @@ -0,0 +1,25 @@ +{ + "name": "cl_project", + "version": "1.0.0", + "description": "This is a sample node project", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "code", + "louisville", + "sample", + "project" + ], + "author": "Aaron W. Johnson", + "license": "ISC", + "dependencies": { + "angular": "^1.6.1", + "body-parser": "^1.16.0", + "express": "^4.14.0", + "jquery": "^3.1.1", + "mongoose": "^4.8.4", + "pug": "^2.0.0-beta10" + } +} diff --git a/quiz copy/readme.md b/quiz copy/readme.md new file mode 100644 index 0000000..99a0fa7 --- /dev/null +++ b/quiz copy/readme.md @@ -0,0 +1,80 @@ +# FSJS Project Week 1 + +## Install NodeJS + +- [Windows (http://blog.teamtreehouse.com/install-node-js-npm-windows)](http://blog.teamtreehouse.com/install-node-js-npm-windows) +- [Mac (http://blog.teamtreehouse.com/install-node-js-npm-mac)](http://blog.teamtreehouse.com/install-node-js-npm-mac) +- [Linux (http://blog.teamtreehouse.com/install-node-js-npm-linux)](http://blog.teamtreehouse.com/install-node-js-npm-linux) + +## Start a project +Starting a project in node is simple: +``` +mkdir my_awesome_project +cd my_awesome_project +npm init +``` + +`npm init` simply creates a `package.json` file a populates it with the answers to some questions. You can edit it in a text editor. + +## Sample project organization +When starting a project, a good practice is to lay out your directory structure and create some empty, basic files: +``` +. +├── index.js // Entry point +├── package.json +└── src + ├── config // application configuration + │   └── index.js + ├── models // Database models + │   └── index.js + ├── routes // HTTP(S) routing/controllers + │   └── index.js + └── server.js // Set up server and listen on port +``` + +## Add a library +Perhaps the primary use of `npm` is to add packages to your project. We're going to add the 'E' of 'MEAN' to our project right now: + +``` +npm install express --save +``` + +This tells `npm` to download the 'express' package, save it in a newly created `node_modules` directory, and then add a line in `package.json` to make note of the fact that we need 'express' for this project (that's what the `--save` part does). + +## require() is a big deal +Yes it is. The full documentation for require() (really, for Node modules in general) can be found [here (https://nodejs.org/api/modules.html)](https://nodejs.org/api/modules.html). + +`require()` is what allows you to organize your code in to easy-to-understand (hopefully) directories and files, but join them all together in to a single application. + +For comparison: in a browser environment, if you want to make content from multiple file available to the larger application you can 1) concatenate them all in to one file or 2) load them individually via a `