From 98962cad6cf0d8d42e786c6b2fa73dbc53cc11a5 Mon Sep 17 00:00:00 2001 From: niedexi Date: Tue, 21 Mar 2023 19:39:13 -0400 Subject: [PATCH 1/3] add Express.md --- .DS_Store | Bin 0 -> 6148 bytes README.md | 112 ++++++++++++++-------------- Topics/Tech_Stacks.md | 5 ++ Topics/Tech_Stacks/Express.md | 133 ++++++++++++++++++++++++++++++++++ 4 files changed, 195 insertions(+), 55 deletions(-) create mode 100644 .DS_Store create mode 100644 Topics/Tech_Stacks/Express.md diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f03b3d4cd628f19aa9b4131f6db5a18a866034a8 GIT binary patch literal 6148 zcmeHK!AiqG5Z!HSO%SmM!5;VGt%s(ELJvZy_25lN(Su4&OtFEOElq0CSjlhbANd9T zjx)R4La83Sh}fAh`(|fncG;J(lVyzY?lg25t1-qbP{fiA%@=~>sB2O(9z?F@xMgWD zOUFShgSBXK{6z-v-BnqiNj7E?TYZ1;!8nf6tl9kFrE+Dfx^3C;>{{2}NY1>>&!%bD zpIl<^%+E%FvHMcSOWP05qv32&+dq~`=10kJqLQO<2q9M&Q4-2oS5A{KRr7dy0N1ex zwR)aA?N&o{oOwg!PP64SM7z_T&u#1A&^bE2xqp1hpXV>HnpqAXp^`m=3wQ%#Ws?uy zB#C8m2mVFQB9@RCAO?tm4Pd|=eb&wf?3K1i3=ji9V*t+w0gC7vEHtX40~-8&#PJFu z3fOp;KokaDgM~&I0pU6oP^WTp#o#&}{KCY!1`CZkopH4?%wtyO=7z%6>fjeDoN-qp zwZs51u*yJLcWYSxPrkqZuO?BC7$64z6$8A|^Lky_lBun0o5NZwKyN@%Fs{(JOaVic gVu;03TnAMGet`y{Yp~D=9uWEwP&80O4E!nspR+eoLI3~& literal 0 HcmV?d00001 diff --git a/README.md b/README.md index 32c9f1974..862eaa26f 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,76 @@ ## Intro -Welcome to Learning Software Engineering Repository. This is intended as a resource for students new to software engineering to contribute to the ever growing body of knowledge of software engineering by adding/editing their input to help other students learn better. + +Welcome to Learning Software Engineering Repository. This is intended as a resource for students new to software engineering to contribute to the ever growing body of knowledge of software engineering by adding/editing their input to help other students learn better. Readers are expected to know the foundation of software engineering and computer science (e.g., basics of algorithms, foundations of programming). Following files are present in this directory. You may contribute to any of these of your choice. If you are contributing by forming multiple pages, consider structuring your files into a new sub-directory within the topic's directory. Contribute to the readme files within each topic directory as appropriate. ------ +--- Potential Topics-- - Tech stacks - 1. Django - 1. Django Rest Framework + 1. Django + 1. Django Rest Framework + 2. Node.js + 1. Express - Software Tools - 1. Git - 1. Git Workflows + 1. Git + 1. Git Workflows - Software Engineering - 1. Methodologies & Frameworks - 1. Agile - 1. Scrum - 2. Kanban - 3. XP - 2. Waterfall + 1. Methodologies & Frameworks + 1. Agile + 1. Scrum + 2. Kanban + 3. XP + 2. Waterfall - Task management software - 1. Linear.app - 2. Jira - 3. GitHub Projects + + 1. Linear.app + 2. Jira + 3. GitHub Projects - Development Process - 1. GitFlow - 2. Trunk-based Development - 3. Coding Standards - 4. Pull-requests - 5. DevOps - 1. Automated Testing - 1. Unit testings - 2. Integration testing - 2. Build tools - 1. Maven - 2. Gradle - 3. Build requirements - 1. requirements.txt - 2. packages - 4. Deployment - 1. Heroku - 2. AWS - 1. Django Project Deployment: AWS, Vercel and Railway - 3. Firebase - 4. Digital Ocean - 5. Software development best practices: - 6. Vercel Frontend Deployment (Automated) - 1. Designer Patterns - 2. Clean Coding - 1. Choose a coding style and stick to it - 3. SOLID Principles - 4. Code Smells + 1. GitFlow + 2. Trunk-based Development + 3. Coding Standards + 4. Pull-requests + 5. DevOps + 1. Automated Testing + 1. Unit testings + 2. Integration testing + 2. Build tools + 1. Maven + 2. Gradle + 3. Build requirements + 1. requirements.txt + 2. packages + 4. Deployment + 1. Heroku + 2. AWS + 1. Django Project Deployment: AWS, Vercel and Railway + 3. Firebase + 4. Digital Ocean + 5. Software development best practices: + 6. Vercel Frontend Deployment (Automated) + 6. Designer Patterns + 7. Clean Coding + 1. Choose a coding style and stick to it + 8. SOLID Principles + 9. Code Smells - Professionalism - 1. Customer engagement - 1. Meeting best practices - 2. Progress Updates - 2. Communication - 1. Asking questions - 1. Hi everyone, I am working on ____, and I am stuck on ____. I tried ____, it didn’t work because _____. I also tried _____, and it didn’t work because ____. I am assuming _____ and ____. Does anyone have any hints as to what might be wrong? - 3. Presentations - - + 1. Customer engagement + 1. Meeting best practices + 2. Progress Updates + 2. Communication + 1. Asking questions + 1. Hi everyone, I am working on \_**\_, and I am stuck on \_\_**. I tried \_**\_, it didn’t work because \_\_\_**. I also tried **\_**, and it didn’t work because \_**\_. I am assuming \_\_\_** and \_\_\_\_. Does anyone have any hints as to what might be wrong? + 3. Presentations - User Experience - 1. Overview - 2. Areas of User Experience - 3. Helpful Courses + 1. Overview + 2. Areas of User Experience + 3. Helpful Courses - Product Management - 1. Beginner's guide to product management and becoming a successful product manager + 1. Beginner's guide to product management and becoming a successful product manager - Other useful resources - Teamwork diff --git a/Topics/Tech_Stacks.md b/Topics/Tech_Stacks.md index d37422b95..bcc7c31d6 100644 --- a/Topics/Tech_Stacks.md +++ b/Topics/Tech_Stacks.md @@ -1,6 +1,11 @@ ## Tech Stacks ### [Learning MySQL for databases](./Tech_Stacks/Learning_MySQL.md) + ### [How to access and use salesforce API](./Tech_Stacks/salesforce_api.md) + ### [React Resources](./Tech_Stacks/React.md) + ### [Angular Resources](./Tech_Stacks/Angular.md) + +### [Express Resoursec](./Tech_Stacks/Express.md) diff --git a/Topics/Tech_Stacks/Express.md b/Topics/Tech_Stacks/Express.md new file mode 100644 index 000000000..ca12621b0 --- /dev/null +++ b/Topics/Tech_Stacks/Express.md @@ -0,0 +1,133 @@ +# Setting up a Basic RESTful Server with Node.js and Express + +## Table of contents + +### [Introduction](#introduction-1) + +### [Prerequisites](#prerequisites-1) + +### [Setting up the project](#setting-up-the-project-1) + +### [Installing Express](#installing-express-1) + +### [Creating a basic server](#creating-a-basic-server-1) + +### [Defining RESTful routes](#defining-restful-routes-1) + +## Introduction + +This guide will help you set up a simple RESTful server using Express, a popular web framework for Node.js. We will create a basic server that listens for HTTP requests and sends responses. + +## Prerequisites + +[Node.js](https://nodejs.org/en/download) +[npm](https://www.npmjs.com/package/npm) + +## Setting up the project + +First, let's create a new directory for our project and navigate to it using the terminal. + +```bash +mkdir express-server +cd express-server +``` + +Now, initialize the project with the `npm init` command. Follow the prompts or use `npm init -y` to accept the defaults. + +```bash +npm init -y +``` + +## Installing Express + +To install Express, run the following command: + +```bach +npm install express +``` + +## Creating a basic server + +Create a new file named `app.js` in the project directory and add the following code: + +```javascript +const express = require("express"); +const app = express(); +const PORT = process.env.PORT || 3000; + +app.get("/", (req, res) => { + res.send("Hello, World!"); +}); + +app.listen(PORT, () => { + console.log(`Server is running on port ${PORT}`); +}); +``` + +This code imports the Express library, creates an instance of it, and sets up a basic server that listens on port 3000. + +## Defining RESTful routes + +Next, we'll define some RESTful routes for a simple resource. For this example, we'll use an in-memory array to represent a list of items. + +Add the following code to `app.js`: + +```javascript +const items = []; + +app.use(express.json()); + +app.get("/items", (req, res) => { + res.json(items); +}); + +app.post("/items", (req, res) => { + const newItem = req.body; + items.push(newItem); + res.status(201).json(newItem); +}); + +app.get("/items/:id", (req, res) => { + const id = parseInt(req.params.id); + const item = items.find((i) => i.id === id); + + if (!item) { + return res.status(404).json({ error: "Item not found" }); + } + + res.json(item); +}); + +app.put("/items/:id", (req, res) => { + const id = parseInt(req.params.id); + const index = items.findIndex((i) => i.id === id); + + if (index === -1) { + return res.status(404).json({ error: "Item not found" }); + } + + items[index] = req.body; + res.json(items[index]); +}); + +app.delete("/items/:id", (req, res) => { + const id = parseInt(req.params.id); + const index = items.findIndex((i) => i.id === id); + + if (index === -1) { + return res.status(404).json({ error: "Item not found" }); + } + + const deletedItem = items.splice(index, 1)[0]; + res.json(deletedItem); +}); +``` + +We have defined the following routes for our items resource: + +`GET /items`: Retrieve all items \ +`POST /items`: Create a new item \ +`GET /items/`:id: Retrieve a specific item by ID \ +`PUT /items/`:id: Update an existing item by ID \ +`DELETE /items/`:id: Delete an item by ID \ +The `app.use(express.json());` line tells Express to parse incoming JSON payloads, allowing us to access the request body data. From 87e06b9889b178619ec65d2219baa3a1acf41010 Mon Sep 17 00:00:00 2001 From: niedexi Date: Tue, 21 Mar 2023 19:54:03 -0400 Subject: [PATCH 2/3] add external resources --- .DS_Store | Bin 6148 -> 0 bytes Topics/Tech_Stacks.md | 2 +- Topics/Tech_Stacks/Express.md | 19 +++++++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index f03b3d4cd628f19aa9b4131f6db5a18a866034a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!AiqG5Z!HSO%SmM!5;VGt%s(ELJvZy_25lN(Su4&OtFEOElq0CSjlhbANd9T zjx)R4La83Sh}fAh`(|fncG;J(lVyzY?lg25t1-qbP{fiA%@=~>sB2O(9z?F@xMgWD zOUFShgSBXK{6z-v-BnqiNj7E?TYZ1;!8nf6tl9kFrE+Dfx^3C;>{{2}NY1>>&!%bD zpIl<^%+E%FvHMcSOWP05qv32&+dq~`=10kJqLQO<2q9M&Q4-2oS5A{KRr7dy0N1ex zwR)aA?N&o{oOwg!PP64SM7z_T&u#1A&^bE2xqp1hpXV>HnpqAXp^`m=3wQ%#Ws?uy zB#C8m2mVFQB9@RCAO?tm4Pd|=eb&wf?3K1i3=ji9V*t+w0gC7vEHtX40~-8&#PJFu z3fOp;KokaDgM~&I0pU6oP^WTp#o#&}{KCY!1`CZkopH4?%wtyO=7z%6>fjeDoN-qp zwZs51u*yJLcWYSxPrkqZuO?BC7$64z6$8A|^Lky_lBun0o5NZwKyN@%Fs{(JOaVic gVu;03TnAMGet`y{Yp~D=9uWEwP&80O4E!nspR+eoLI3~& diff --git a/Topics/Tech_Stacks.md b/Topics/Tech_Stacks.md index bcc7c31d6..a824ed6ad 100644 --- a/Topics/Tech_Stacks.md +++ b/Topics/Tech_Stacks.md @@ -8,4 +8,4 @@ ### [Angular Resources](./Tech_Stacks/Angular.md) -### [Express Resoursec](./Tech_Stacks/Express.md) +### [Express Resourses](./Tech_Stacks/Express.md) diff --git a/Topics/Tech_Stacks/Express.md b/Topics/Tech_Stacks/Express.md index ca12621b0..dd16f9f07 100644 --- a/Topics/Tech_Stacks/Express.md +++ b/Topics/Tech_Stacks/Express.md @@ -14,17 +14,21 @@ ### [Defining RESTful routes](#defining-restful-routes-1) +### [Additional Resources](#additional-resources-1) + ## Introduction This guide will help you set up a simple RESTful server using Express, a popular web framework for Node.js. We will create a basic server that listens for HTTP requests and sends responses. ## Prerequisites -[Node.js](https://nodejs.org/en/download) +[Node.js](https://nodejs.org/en/download) \ [npm](https://www.npmjs.com/package/npm) ## Setting up the project +[Express Getting Started](https://expressjs.com/en/starter/installing.html) + First, let's create a new directory for our project and navigate to it using the terminal. ```bash @@ -127,7 +131,14 @@ We have defined the following routes for our items resource: `GET /items`: Retrieve all items \ `POST /items`: Create a new item \ -`GET /items/`:id: Retrieve a specific item by ID \ -`PUT /items/`:id: Update an existing item by ID \ -`DELETE /items/`:id: Delete an item by ID \ +`GET /items/:id`: Retrieve a specific item by ID \ +`PUT /items/:id`: Update an existing item by ID \ +`DELETE /items/:id`: Delete an item by ID \ The `app.use(express.json());` line tells Express to parse incoming JSON payloads, allowing us to access the request body data. + +## Additional Resources + +[Official Reference](https://expressjs.com/en/4x/api.html) \ +[GitHub Page](https://github.com/expressjs/express) \ +[MDN Express Example](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs) \ +[Tutorialspoint](https://www.tutorialspoint.com/nodejs/nodejs_express_framework.htm) From d08e091e6796ca8e08e2fdac382f9ca296c471c4 Mon Sep 17 00:00:00 2001 From: niedexi Date: Tue, 21 Mar 2023 20:01:34 -0400 Subject: [PATCH 3/3] fix typo --- Topics/Tech_Stacks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Topics/Tech_Stacks.md b/Topics/Tech_Stacks.md index a824ed6ad..131ac5f02 100644 --- a/Topics/Tech_Stacks.md +++ b/Topics/Tech_Stacks.md @@ -8,4 +8,4 @@ ### [Angular Resources](./Tech_Stacks/Angular.md) -### [Express Resourses](./Tech_Stacks/Express.md) +### [Express Resources](./Tech_Stacks/Express.md)