Welcome to DEEP - learning backend development, a beginner-friendly repository that serves as your gateway to understanding essential concepts in backend development. Whether you're new to the world of backend or looking to reinforce your knowledge, this guide will provide you with a solid foundation.
- DEEP - Learning Backend Development
Follow these steps to get started with DEEP - learning backend development
Getting Started
First, fork the LearningSimpleBackend repository by clicking the "Fork" button at the top right of this page. This will create a copy of the repository in your GitHub account, allowing you to make changes and experiment freely.
Pro Tip: Don't forget to hit the "Follow" button on the Duran Enterprise GitHub profile to stay updated with the latest project developments and updates.
Git Installation
Git is a version control system that allows you to track changes in your code and collaborate with others. Follow these steps to install Git on your computer:
-
Download Git:
-
For Windows: Visit the official Git for Windows website at https://gitforwindows.org/ and download the installer. Run the installer and follow the on-screen instructions.
-
For macOS: macOS usually comes with Git pre-installed. You can open the Terminal and run
git --version
to check if Git is already installed. If it's not installed, you can download the latest version from https://git-scm.com/download/mac. -
For Linux (Ubuntu/Debian): Open your terminal and run the following command to install Git:
sudo apt-get install git
-
For Linux (Fedora): Open your terminal and run the following command to install Git:
sudo dnf install git
-
-
Configure Git:
After installing Git, you should configure it with your name and email address. Open your terminal and run the following commands, replacing
Your Name
and[email protected]
with your name and email:git config --global user.name "Your Name" git config --global user.email "[email protected]"
-
Verify Installation:
To verify that Git is installed correctly, open your terminal and run the following command:
git --version
This command should display the installed Git version.
VS Code Installation
If you haven't already, install [Visual Studio Code (VSCode)](https://code.visualstudio.com/), a popular and powerful code editor. It's highly recommended for web development.Postman Installation
Postman is a handy tool for testing APIs, which you'll be doing a lot in backend development. Install the Postman Desktop Application or Postman Extension for VSCode to make API testing more convenient.
NodeJS Installation
We recommend using the LTS (Long-Term Support) version for stability. As of this guide, version 18.18.0 LTS is available.
Follow these steps to install Node.js:
-
Download Node.js: Visit the official Node.js website at https://nodejs.org/. You'll see two options: LTS and Current. Choose the LTS version.
-
Choose Your Operating System: On the Node.js downloads page, you'll find installers for various operating systems. Select the installer that matches your operating system (e.g., Windows, macOS, or Linux).
-
Run the Installer: Once the installer is downloaded, run it on your computer. Follow the on-screen instructions to install Node.js. During installation, you can choose to include npm (Node Package Manager), which is essential for managing Node.js packages.
-
Verify Installation: After the installation is complete, open your terminal (command prompt on Windows) and run the following commands to verify that Node.js and npm are installed:
node -v
This command should display the installed Node.js version (e.g., v18.18.0).
pnpm Installation
In addition to Node.js, we recommend using pnpm as your package manager for this project. pnpm is an alternative to npm and yarn, and it offers some advantages like faster installations and efficient disk space usage.
Follow these steps to install pnpm:
-
Open your terminal: If it's not already open from the previous Node.js installation steps, open your terminal (command prompt on Windows).
-
Install pnpm: Run the following command to install pnpm globally on your system:
npm install -g pnpm
This command will download and install pnpm from the npm registry.
-
Verify Installation: After the installation is complete, run the following command to verify that pnpm is installed:
pnpm -v
This command should display the installed pnpm version (e.g., 8.8.0).
Now that you have Git, Node.js and pnpm installed, it's time to install the project dependencies specified in the package.json
file.
Follow these steps to install the dependencies and start learning:
- Navigate to your folder of choice.
- Open terminal and clone this repository.
git clone https://github.com/Duran-Enterprise/activity-basic-backend
- Install project dependencies by running the following command:
pnpm install
- Start the development server by running the following command:
pnpm dev
Introduction
Backend development is the art of building server-side components of a web application. It involves handling data, managing databases, and ensuring the smooth communication between the frontend and the server.
This repository is designed to help you grasp the fundamental concepts of backend development, starting from the ground up.
Backend Development
In the context of web development, the backend refers to the server-side of an application. It's responsible for processing requests from the frontend, handling data, and interacting with databases.
Understanding APIs
API (Application Programming Interface) defines how different software components should interact. In web development, an API is a set of rules and protocols that allow the frontend to communicate with the backend.
HTTP Requests
HTTP (Hypertext Transfer Protocol) is the foundation of data communication on the web. Learn about the different types of HTTP requests:
- GET: Retrieve data from the server.
- POST: Send data to the server.
- PUT: Update existing data on the server.
- DELETE: Remove data from the server.
Getting Started with Express.js
Express.js is a popular Node.js framework for building web applications. It simplifies the process of creating APIs and handling routes.
import express from 'express'
const app = express();
const port = 3222;
app.get('/', (req, res) => {
res.send('Hello, Express!');
});
app.listen(port, () => {
console.log(`\x1b[32m⚡️[server]\x1b[0m: Server is running at http://localhost:${port}`);
});
Middlewares
Middleware functions are the heart of Express. They can perform tasks like authentication, logging, and data manipulation before the final request handler is executed.
app.use(express.json()); // Parse JSON requests
app.use(cors()); // Enable Cross-Origin Resource Sharing
app.use(authMiddleware); // Custom authentication middleware
Express Routing
Routing involves defining how your application responds to client requests. Express provides a simple way to create routes for various endpoints.
app.get('/users', (req, res) => {
// Handle GET request for the /users endpoint
});