Following LinkedIn Learning tutorial at https://www.linkedin.com/learning/building-restful-web-apis-with-node-js-and-express/
Using the Following Technologies (see package.json - npm install upon clone of repo):
- Express: https://expressjs.com/
- Node: https://nodejs.org/en/download/
- Mongoose: https://mongoosejs.com/docs/api.html
- Babel: babel-preset-es2015 babel-preset-stage-0 https://babeljs.io/docs/en/plugins
- Nodemon: (use nodemon instead of node in CLI - nodemon monitors changes/saves in your code & restarts your server automatically!!) https://nodemon.io/
- Body-parser: https://www.npmjs.com/package/body-parser
- MongoDB Community https://docs.mongodb.com/manual/tutorial/getting-started/
-
Postman - this is used in conjunction with HTTP Requests GET POST PUT DELETE - './src/routes/crmRoutes.js'
https://www.getpostman.com/ || https://learning.getpostman.com/docs/postman/collections/creating_collections/#how-to-create-collections -
Robomongo/Robo Studio 3T - this tool is used to CONNECT to Mongodb (after running mongod in CLI):
Note: you must set a connection (name, verify that it's on the port that output in CLI)
https://robomongo.org/download
MongoDB Community: https://docs.mongodb.com/manual/tutorial/getting-started/
====================================
CLI Commands & Process:
Have 3 Terminals Open:
Terminal/CLI #1:
navigate to 'C://data/db'
Start Mongo: 'mongod'
Console #2:
navigate to 'node-mongo-crm' root dir
Start 'node-mongo-crm' App: 'npm start'
Console #3 (optional):
navigate to 'node-mongo-crm' root dir
Git status / push / pull
Robomongo:
Have Postman Open for HTTP API request checking. Validation that custom HTTP/API endpoints are working.
(Studio 3T connected to mongodb instance via port # - verify correct port from Console #1)
Have MongoDB Compass open (for viewing data)
Navigate To:
Open the following in browser: localhost://4200
Note: you will see "Node & express server running on port 4200" if everything worked.
Try navigating to localhost://4200 & note changes on Console #2!
Navigate to localhost://4200/sky.jpeg (example of static image loading using this single line of code
in index.js: 'app.use(express.static('public/images'));'
===========================================================================
Setup:
git clone repo
npm install && npm update
have downloaded MongoDB, Postman, and Robomongo
start mongo with 'mongod' (from 'C://data/db') ---
^^^ TROUBLESHOOTING WINDOWS: make sure the application route is in your PATH variable
(Ref: https://teamtreehouse.com/community/windows-add-mongodb-directory-to-path-environmental-variable-for-easy-command-line-interaction)
from node-mongo-crm folder, run 'npm start'
^^^ TROUBLESHOOTING WINDOWS: If application keeps stopping, you may have to kill process at port# 4200
(Ref: https://developers.de/blogs/indraneel/archive/2017/10/18/kill-a-process-in-windows-by-port-number.aspx)
navigate to localhost://4200
have run mongod command BEFOREconnecting to your port in Robomongo/Studio 3T
create collection in postman specifically for this app - localhost://4200 is default. ENSURE for POST & PUT
routes/endpoints you select "x-www-form-urlencoded" under Body radio button. This is for json data.
have fun :)
===========================================================
Next Steps:
- Create different endpoints for different data.
- Hook up to form with fields - contact form with submission via nodemailer.
- Incorporate https://koajs.com/#introduction
- Try https://loopback.io/getting-started/
- Try https://swagger.io/solutions/api-design/