2026-08-21 14:16
Status:
Tags: IBM IBM Full Stack Software Developer Professional Certificate IBM Developing Back-End Applications with Node Node JavaScript Back End Web Development Package Management Servers
DBAN - Module 1 - Introduction to Server-Side JavaScript
==Introduction To Server-Side JavaScript
-
What is Back-End Development?:
- Client-Server applications such as browser based or cloud based applications generally consist of front end & back end applications
- The previous notes, see IBM - Developing Front-End Apps with React covered on the front end portion of this, where code is run inside of the browser, giving a user the actual elements they can interact with and manage
- This is unlike the backend, which runs on the back-end server, not the front-end client browser
- It is exactly this browser engine and back-end server that communicate with each other to exchange things like data and other information
- Back-End Developers write code to communicate with the browser’s engine and back-end server, ensuring that the actual functions and data needed for an application are working correctly
- This code generally pertains to databases, servers, and applications
- Back-end Technologies- tend to include things like servers, databases, APIs, programming languages, frameworks, and runtimes
- Server are hardware or software (depends on virtualization in a VM or cloud environment) and help to communicate and provide functionality to a website for a client
- Servers can also communicate with each other of course
- There can be many different kinds of servers:
- Database- these house, retrieve, and deliver the actual data to the given request and what not
- Web Server these ensure that a client request is actually responded to, and does not just hang until it times out, often does so via HTTP or HTTPS requests. Also making things like actual routing choices on what the user can and cannot see
- Application- these in turn host and deliver the application through HTTP, they sit between a database server and a web server, and transform data into dynamic logic
- Web API- these, application programming interfaces, allow for two pieces of software to communicate with each other, and a web service is a type of web API as well, they communicate with each other using HTTP requests
- Back-End Programming languages, include: Java, JavaScript, PHP, Python, Ruby, C# and some other ones as well
- Frameworks are basically a structure for your code, they are more than a library where they actually dictate the structure of how your project environment is going to look.
- Common back-end frameworks
Django (python), Ruby on Rails (ruby), Express,js (JavaScript) Express.jsis a framework that is actually running on top ofNode.jswhich is a environment that allows for javascript code to run server side instead of just in the browser, it handles thehttprequests made to the web-server- It is a framework on top of
Node, everything inexpressis sort of just syntactic sugar fornode - Runtime Environment a runtime is like a mini-operating system that provides the resources necessary for an application to run
- The actual runtime is the infrastructure that supports the execution of a code base
- The hardware and software environment in which an application gets executed
- So for something like Java, the runtime would be something like the JVM i would presume, and for javascript it would be a browser engine or Node for server-side
- Back-End Responsibility: Scalability this is the actual responsibility of the back end devs, and it is on them to make sure that the incoming traffic load from a website is handled well and can properly provide services to all of the users that would need them. This is generally just something to keep in mind
- Other responsibilities include security, authentication, and good performance
-
Back-end and Front-end Development overview:
- Key Components of Back-end Development
Server: The hardware or software that provides resources, data, services, or programs to clients over a network.
Database: A structured collection of data that can be easily accessed, managed, and updated.
- SQL Databases: Relational databases like MySQL, PostgreSQL, and SQLite.
- NoSQL Databases: Non-relational databases like MongoDB, Cassandra, and Redis.
Server-Side Languages: Programming languages used to build the back-end logic.
- Node.js: A JavaScript runtime built on Chrome’s V 8 JavaScript engine.
- Python: A high-level programming language known for its readability and efficiency.
- Ruby: A dynamic, open-source programming language with a focus on simplicity.
- Java: A versatile and powerful programming language used for large-scale applications.
Frameworks and Libraries:
- Express: A minimal and flexible Node. js web application framework.
- Django: A high-level Python web framework that encourages rapid development.
- Ruby on Rails: A server-side web application framework written in Ruby.
- Spring: A comprehensive framework for enterprise Java development.
- Below are detailed the Key Componets of Front-end
-
Front-end Development
-
Front-end development, also known as client-side development, involves creating the part of a website or application that users interact with directly. This includes everything the user experiences visually and through interactions.
-
Key Components of Front-end Development
-
HTML (HyperText Markup Language): The structure of web pages, defining elements such as headings, paragraphs, images, and links.
-
CSS (Cascading Style Sheets): The styling of web pages, including layout, colors, fonts, and responsiveness.
-
JavaScript: The behavior of web pages, enabling interactive features such as forms, animations, and dynamic content updates.
-
Frameworks and Libraries:
- React: A JavaScript library for building user interfaces.
- Angular: A TypeScript-based framework for building web applications.
- Vue.js: A progressive JavaScript framework for building user interfaces.
-
-
Getting Started with Node.js:
-
-
Node. js basically came about because people say how good Javascript was for validation of HTML pages and cross platform compatibility, and so they developed JS further for server-side code, which is what made Node
-
V 8 Engine- Inside of Node. js, Javascript code is actually executed using the open-source Google V 8 Engine, which is integrated into all Google Chrome browsers and modern browsers too, it basically is the compiler and interpreter for JS code, and since Node uses JS, node uses it too
-
Server Processes are either Single Threaded, or Multi Threaded, a single threaded environment means that only a single command is processed as a time, whereas a multi-threaded environment means that multiple commands can run at once
-
Node itself is actually single-threaded, but still performs efficiently due to asynchronous / non-blocking nature, meaning that while a process is executed, the program does not need to wait for it to finish
-
Node itself is event driven so whenever it performs something like I/O, an event is triggered, and instead of blocking the thread and consuming processor time, node.js resumes operations when the response is received
-
This lets servers to remain responsive
-
JSON Payload
-
JSON stands for JavaScript Object Notation and is formatted as key-value pairs. The payload represents the data transmitted between the client and the server.
-
When the client needs to send data to the server, it does so in the form of a JSON object, as shown below:
{ "name": "John", "age": "24", "email": "[email protected]" }-
The above object is a JSON. When this data is sent as part of the request, its values can be extracted using request.name and so on.
-
Similarly, the response is also sent as JSON. An example is shown below:
{ "status": "ok", "message": "Successfully added" }-
Express Framework
-
While Node.js provides packages to create a server, the Express framework simplifies the process of creating APIs and endpoints.
-
An API endpoint is a specific point of entry for a request from the client to the server.
-
-
Introduction to Node.js:
-
Node. js is an open-source language that runs on
V8, which itself is the open source engine that was mentioned inside of the above notes -
Functionality developers would generally use JavaScript code for things like Front-End functionality, however Node takes that idea and flips it on it’s head, allowing you to use the same JS language for actual server components
-
Node. js is event driven and uses asynchronous, non-blocking I/O as described above
-
JavaScript with Node. js- Below is a diagram that show cases the difference in how the actual javascript code runs within of a Web-Browser and how it would run inside of the Node Server
-
-
Basically what happens is the user is served with an HTML/CSS web-page that they interactively use in order to access whatever information or service it is that they want to have provided to them. Then using the JS logic for this front end (a form submission or whatever), data is sent over via
HTTP/JSONto the Node server in which aREST web serviceis waiting there on an open port listening for incoming requests. It would then fetch the data or authenticate a user or something like that, and send back the request over to the web browser, and then whatever needs to be done would get done -
Node. js was generally a little bit more limited inside of the early stages of it’s existence, however now devs can use Node in the same components of architecture as they would things like
Java, Perl, C++, Python, & Ruby -
With Node being a VERY popular form of back-end, it is used by all things like Uber, Yahoo!, LinkedIn, eBay, and even PayPal
-
Express. js is basically sort of like an extra library on top of the Node framework in way and it needs node in order to run, but the thing is that it generally just makes it much more configurable for building applications
-
*Express abstracts lower-level APIs in Node. js by using HTTP utility methods and middleware
-
Which lets you handle parsing data and actually responding and getting calls in MUCH cleaner and easier way, see Node.js + Express — Backend Fundamentals for more nuance on the topic
-
-
Import and Require:
-
Modules- are files containing related, encapsulated JS code that serves a specific purpose, they can be a single file or a folder containing files, I always just thought of them as mini-libraries that you install in so you can use the code functionality
-
They are very usable and basically act exactly like a library
-
Purpose of import() & require()
- When an external application needs to use the code inside of a module, the application needs to actually call that module, and this module is called using a
import()orrequire()statement, with the name of whatever you require passed in as the argument - The different one you would need depends on the specification of the library
- When an external application needs to use the code inside of a module, the application needs to actually call that module, and this module is called using a
-
Package a directory with one or more modules
-
Module Specifications- are conventions and standards used to create packages, with
commonJSandESmodule conventions being the most common -
By default,
Node.jstreats any form of javascript code as a basiccommonJsmodule, and you as the dev need to enable things likeESmodules in order to use them, and this is done by changing the file extension of the package frompackagename.js -> packgename.mjs -
-
Okay so basically, a
commonJSspecification for a module would use therequire()function, so something likerequire(better-sqlite3)or something like that, where as the actualESspecifications require something more akin to the use of theimport()function, either way, both are just ways to import more usable code for functionality inside of your own application -
To then export code out of your own given file or something like that, you use the
module.exportsforcommonJSand then justexportforES, and this would look something likemodule.exports = databasewhere the thing that this file is exporting whenever it is included in another file, is a database object, at least I think so -
Differences calling require() and import()
-
-
Basically the
require()function can be called ANYWHERE at ANYTIME in the code, whileimport()has to be called as the START OF THE FILE -
This means that require() can generally run inside of things like functions and conditions and different scopes, but it also therefore means that you would not know you have a binding error until you find one in runtime, meaning nasty bugs
-
However, this is until
importwhere you would find yourself with a binding error bug found at runtime since the actual binding is static -
Another difference is that require() modules are synchronous in nature, while import() modules are Asynchronous in nature, meaning that like the above notes say, they run differently, one is linear, while the other is parallel, meaning they load in at different times
-
-
Okay basically as it looks like, for the sample code inside of the require portion of the bit, you generally set some kind of module. exports variable that you assign a given value which is then shared to the file you want to import it to through the syntax specified in
require('./example.js)and put inside of a variable that you can then access -
The
import()way looks a lot more similar to python or React, where you use{}in order to export some form of data using a different name you can give, and then you import it inside of the next file withimport { myvalue } from module.jswhich is probable because this needs to be static and so a given name for each thing you want to export makes it easier to track, somethingrequiredoes not make you use
-
-
Introduction to Server-Side JavaScript:
- JavaScript is a programming language for client-side interactive web applications that run in a web browser, however using the
v8 google engine, you can actually run it server side - Some features I already know about JS is that it is interpreted, compiled inside of the browser, was developed to create dynamic interactions for web applications, AND IT IS NOT A DERIVATION OF JAVA, it was also made in 10 days by a mad-man and is an absolute shit language
- You generally build an application with HTML, style it with CSS, and then add in features using JS, generally all modern browsers would support JavaScript and it is the top tool for full-stack developers
- Server-Side JavaScript- node. js applications process and route web service requests from the client, most of the actual steps from the above diagram are IDENTICAL, with the only real difference being on the backend
- Where the REST web service (this happens in the diagram as well but for context) nabs the JSON/HTTP data, and then instead of a traditional Java server, Node. js hosts an application written inside of Javascript, which runs on the server and not the web-browser, while still letting you do all the same things you can with a Java backend
-
Creating a Web Server with Node.js:
- Node. js is a server-side programming framework that uses JS as it’s programming language, many devs already know how to actually use JS and hence why node is so popular
- It places heavy emphasis on concurrent programming with the lightweight JS language, generally it is a single-threaded application that handles I/O via events that do not actually stop the existing programming from continuing to run
- It is good for server applications that are scalable, concurrent, and need to be quickly developed
- Every JavaScript file is a module in Node. js there are some pre-existing ones that you can import in, or you can write your own and include them in other portions of your own current use case, letting you generally develop things like packages which is a collection of one or more nodes
- With the
http Node.js moduleyou can develop an application that listens to http requests and returns http response messages, allowing for real communication with the front-end - In
nodeto create a simple web server: http, you would use thehttp.createServer(function(request, response))line of code after having imported the required modules - This generally lets you have an object which can listen in to the
requestfrom a given server at a URL, and then also send back aresponse - These are basically the variables from which you will handle all of your information with
- You can also then set the application on a given port, using something like
server.listen(8080);, which lets you run the application and any incoming requests on that given port will be used inside of your code
-
Working With Node.js Modules:
- Package. json this is the module manifest, and is the file that actually describes the details about a given Node. js module, things like the version, licence, name, and other such things generally
- Generally, note that if no
package.jsonis actually found, then Node. js assumes that theindex.jsis the main file, so that means thepackage.jsonalso basically specifies the actual entry for your program - You can obviously just change this by specifying a different main script for your module using a relative path from the module directory inside of
package.json - Importing Node. js modules- use the
require or importfunctions as described above in order to actually take in theexportor whatever object there actually is that holds whatever functionality you would need from the imported module - It generally creates an object that creates an object representative of the imported Node.js Module
- See above notes for more details
- Note to be made about
require(./example)basically, if the actual path you passed in is found out to not actually be a file, but then instead be a directory, then the require function will look for something likerequire(./example/index.js)and will assume the default script file can be found inside of that given directory, I assume it errors if it cannot find either - If you want your own file to actually be exportable, you need to have something like a
module.exports = a;at the very end of your file so that way there is an actual object with whatever data you want that is passed through whenever you reference it, this generally lets you do things like have an object that you yourself can reference
-
Advanced Node.js Modules:
-
In Node.js, reusable code is organized into modules. There are three types of modules: core, local, and third-party.
-
Core Node.js modules are built-in modules that provide essential functionality for developing Node.js applications.
-
Local modules are the next type of Node.js module. Local modules are the modules written by you and the development team as part of creating your Node.js application.
-
Third-party modules are created by external developers and are typically available through package registries such as npm. These modules are distributed under different licenses, and developers should review license terms before use
-
Commonly used core modules include
http, path, fs, os, util, url, and querystring.Below are code examples for some of these -
-
The above hand code is used to actually receive and send back http requests from a web browser, it is run using the
createServerfunction which takes in thereq & resinputs, which are described in more detail above, it also lets you dictate the port on which your server is going to be listening for these requests -
-
-
As the diagram says, the
fsmodule is used for interaction with a file system, this means that if you say want to upload, download, or read a file from the user, you can, and it is done through the various different functions that are outline above
-
-
Overview of Node Package Manager:
-
Package managers- are sets of tools to deal with modules and packages containing dependencies, they basically allow for you to manage your packages without the needed hassle of constantly updating and managing the dependencies for a given module you want to install
-
Generally, node uses one called the
node package managerornpm, and this package manager is what you can use in order to install whatever dependencies, like the ones in the previous note, that you might need for your application -
They install things from the internet generally, and the package manager just makes this a lot easier to deal with, it finds, installs, upgrades, configures, maintains, and removes packages
-
The
npmis a little bit different though because it does a few things- For one, it provides a command line interface (like most package managers) in order to publish and download packages
- However, because of this, it also lowkey works as an online repository of JavaScript packages
-
As previously said, all packages require a
package.jsonwhich is located inside of the project’s root directory, and holds a good bit of metadata that is then used by thenpmto determine and install the dependencies needed for that package, -
which is done in the form of key value pairs, that MUST contain project name, and project version number
-
Two ways for NPM to install packages
- Locally this one is the one that is the default behavior of npm and is used to actually install files that you want to use for your applications, you just run a local install from the CLI and thats really it, you can do so using
npm install <package_name> - Globally a global install means ,that the installed package will be used by ALL packages ON THE MACHINE, so you should use this generally only if you really really need to, and if it all has different compatibility, you might break your code bases, so just be careful with this one
- You can install things globally using
npm install -g <package_name>
- Locally this one is the one that is the default behavior of npm and is used to actually install files that you want to use for your applications, you just run a local install from the CLI and thats really it, you can do so using
-
-
Module Summary:
- Backend technologies include various types of servers and supporting infrastructure, such as programming languages and frameworks.
- Node.js is a JavaScript runtime environment used for server-side development.
- The require statement can be called from anywhere in the application code, is bound dynamically, and loads modules synchronously.
- The import statement must be called at the beginning of a file and is bound statically. Module loading with import is asynchronous.
- Client-side JavaScript is used to process front-end user interface elements, while server-side JavaScript enables access to different kinds of servers and web applications.
- With server-side JavaScript, Node.js applications process and route web service requests from the client.
- To make a function or a value available to Node.js applications that import your module, add a property to the exports object.
- Core modules provide essential functionality, local modules are those that you create for your application, and third-party modules are created by the Node.js community.
- A local install means only the application within the installation directory can access the package, whereas a global install means that any application on the machine can access the package.
==Glossary
| Term | Definition |
|---|---|
| Anonymous Function | A function that is not named. An anonymous function is often passed into another function as a parameter. |
| Application Server | Transforms data into dynamic content and runs the business logic, which is the data storage and transfer rules. |
| Asynchronous | A process that runs independently of other processes. |
| Callback Function | A function passed into another function as a parameter, which is then invoked inside the outer function to complete an action. Instead of blocking on asynchronous I/O operations, callback functions are used to handle results when the operations complete. |
| Database Server | A server dedicated to providing database services. |
| Dependencies | Code, usually in the form of libraries and packages, that are called from other modules and reused in a program. |
| Event-Driven | Where the flow of a program is determined by particular events such as user input. |
| Express.js | A highly configurable web framework for building applications on Node.js. |
| Framework | Generates code that cannot be altered to perform common tasks. Examples include Django, Ruby on Rails, and Express.js. |
| HTTP Server | A type of software-based server that understands URLs and hypertext transfer protocol. |
| Load | Refers to the number of concurrent users, the number of transactions, and the amount of data transferred back and forth between the clients and servers. |
| Module | Files containing related, encapsulated JavaScript code that serve a specific purpose. |
| Multi-Threaded | Where multiple tasks are executed simultaneously. |
| Node.js | A JavaScript runtime environment that runs on Google Chrome’s V8 engine. |
| Non-Blocking | Failure of a given thread does not cause failure in another, and the execution of a task is not blocked until execution of another task is completed. |
| Npm | Stands for node package manager. It is the default package manager for the Node.js runtime environment. |
| Package | A directory with one or more modules bundled together. |
| Package.json | Contains metadata information about the project, including dependencies and scripts. |
| Payload | The data transmitted between client and server. |
| Runtime Environment | Behaves similarly to a mini operating system that provides the resources necessary for an application to run. It is the infrastructure that supports the execution of a codebase. It is the hardware and software environment in which an application gets executed. Node.js is an example of a backend runtime environment. |
| Scalability | The application’s ability to dynamically handle the load as is or shrinks without it affecting the application’s performance. |
| Server.js | A file that contains the code that handles server creation. |
| Single-Threaded | Where only one command is processed at a given point of time. |
| Web Server | Ensures client requests are responded to, often using HTTP. |
| Web Service | A type of web API that communicates using HTTP requests. It is the web service in the programming interface that sends and receives requests using HTTP among web servers and the client. |
==Cheat-Sheet
| Package/Method | Description | Code Example |
|---|---|---|
| http/createServer | http package is used for establishing remote connections to a server or to create a server which listens to client. createServer - Takes a requestListener, a function which takes request and response parameters, where request is the handle to the request from the client and response is the handle to be sent to the client. | const http = require(‘http’);const requestListener = function(req, res) { res.writeHead(200); res.end(‘Hello, World!’);}const port = 8080;const server = http.createServer(requestListener);console.log(‘server listening on port: ’+ port);server.listen(port); |
| new Date() | new Date() method returns the current date as an object. You can invoke methods on the date object to format it or change the timezone. | module.exports.getDate = function getDate() { let aestTime = new Date().toLocaleString(“en-US”, {timeZone: “Australia/Brisbane”}); return aestTime;} |
| import() | The import statement is used to import modules that some other module has exported. A file that includes reusable code is known as a module. | // addTwoNos.mjsfunction addTwo(num) { return num + 4;}export { addTwo };// app.jsimport { addTwo } from ’./addTwoNos.mjs’;// Prints: 8console.log(addTwo(4)); |
| require() | The built-in NodeJS method require() is used to incorporate external modules that are included in different files. The require() statement essentially reads and executes a JavaScript file before returning the export object. | module.exports = ‘Hello Programmers’;let msg = require(’./messages.js’);console.log(msg); |















