AWD Questions Final Exam - Final
AWD Questions Final Exam - Final
UNIT 1
1. Routing: Express allows you to define routes for handling incoming HTTP
requests. You can specify the HTTP method (GET, POST, PUT, DELETE, etc.) and
the URL pattern to match. When a request matches a defined route, the
corresponding handler function is executed.
2. Middleware: Middleware functions are a central concept in Express.
Middleware sits between the request and response and can perform various
tasks such as logging, authentication, data parsing, error handling, and more.
Middleware functions can be added to the application pipeline to process
requests sequentially.
3. Template Engines: Express can integrate with various template engines like
EJS (Embedded JavaScript), Pug (formerly Jade), and Handlebars, enabling you
to dynamically generate HTML pages on the server side and serve them to
clients.
4. Static File Serving: Express allows you to serve static files (e.g., CSS,
JavaScript, images) directly from a directory on the server, making it easy to
serve client-side resources.
5. Error Handling: Express provides mechanisms to handle errors in a
centralized way, ensuring consistent error responses to clients.
6. Database Support: Although Express doesn't come with built-in database
support, it is often used alongside databases like MongoDB, MySQL, or
PostgreSQL through various database libraries and ORMs (Object-Relational
Mappers).
Applications of Express:
Express's popularity and the extensive range of third-party packages and plugins
available through npm (Node Package Manager) make it a powerful choice for web
development with Node.js. Its flexibility allows developers to structure their
applications according to their specific needs while keeping the codebase clean and
maintainable.
UNIT 2
While the MEAN stack offers a comprehensive and powerful solution for
building web applications, it is essential to consider the specific
requirements and complexities of your project to determine whether it is
the most suitable choice. Alternative stacks like MERN (MongoDB,
Express.js, React, Node.js) and MEVN (MongoDB, Express.js, Vue.js, Node.js)
also offer similar benefits and can be used depending on your team's
expertise and project needs.
UNIT 3
MongoDB's features make it a versatile and powerful choice for various use cases, such as web
applications, mobile apps, content management systems, IoT (Internet of Things) applications,
and big data analytics. Its scalability, flexibility, and ease of use have contributed to its
widespread adoption in the development community. However, like any database system, it is
essential to consider the specific requirements of your application and data to determine whether
MongoDB is the best fit for your project.
MongoDB provides a command-line interface called the MongoDB Shell, also known
as the mongo shell, which allows you to interact with the MongoDB database. It
allows you to perform various administrative tasks, query data, and manage the
database. Here are some of the basic commands you can use in the MongoDB Shell:
This command connects you to the default MongoDB server running on the local
machine. If your MongoDB server is running on a different host or port, you can
specify the connection details using the --host and --port options.
Use this command to switch to a specific database. If the database does not exist,
MongoDB will create it when you insert data into it.
UNIT 4
With a properly implemented RESTful API, clients, whether they are web applications, mobile
apps, or other services, can interact with MongoDB and perform CRUD operations on data by
making HTTP requests to the defined endpoints. This allows for a decoupled architecture, where
the front-end and back-end are separate entities communicating through standardized API
endpoints, providing flexibility and scalability to the application.
4. Explain GET POST method in Mongo DB
In the context of MongoDB, the terms "GET" and "POST" methods typically refer to
HTTP methods used to interact with a RESTful API that communicates with the
MongoDB database. These methods are part of the standard HTTP protocol and are
used to perform different operations on the data.
1. GET Method:
The GET method is used to retrieve data from the server. In the context of a RESTful
API connected to MongoDB, the GET method is commonly used to perform "Read"
operations on the database. When a client sends a GET request to the API endpoint,
the server retrieves the requested data and returns it in the response.
For example, let's say we have a RESTful API that interacts with a MongoDB database
containing a collection of "users." The API endpoint to retrieve all users could be:
The server will then take this data and insert a new document with these fields into
the "users" collection in MongoDB.
It's important to note that the POST method should not be used for retrieval or read
operations. Its primary purpose is to create new resources on the server.
HTML:
In this example, we create a simple AngularJS application that displays a greeting
message and allows users to enter their name. When the user clicks the "Say Hello"
button, it triggers the sayHello() function defined in the controller, which displays an
alert with the personalized greeting.
Remember that the code provided here is for AngularJS, not the current version of
Angular (Angular 2+). If you are starting a new project, it is recommended to use the
latest version of Angular, as it has significant improvements and is actively supported
by the Angular team.
13. Write short notes on SPA (single page applications) and MPA (multiple page
applications)
SPA, short for Single Page Applications, is a web application architecture where the entire
application is contained within a single HTML page. The content of the page dynamically changes
based on user interactions, such as clicking on links or buttons, without requiring a full page
reload. Instead of navigating to separate pages for different actions, SPA loads data and updates
the view dynamically using JavaScript.
1. Improved User Experience: SPAs provide a smoother and more responsive user
experience since page transitions happen instantly without full page reloads.
2. Efficient Data Exchange: SPAs typically communicate with the server using AJAX
(Asynchronous JavaScript and XML) or more modern technologies like Fetch API,
enabling efficient data exchange without disrupting the user interface.
3. Better Performance: SPAs reduce server load and bandwidth consumption by loading
only the necessary data and resources, minimizing redundant page rendering.
4. Rich UI Interactions: SPA frameworks like Angular, React, and Vue.js enable developers
to build complex and interactive user interfaces with ease.
5. State Management: SPAs rely heavily on client-side state management techniques to
maintain application state across user interactions.
6. SEO Challenges: Historically, SPAs faced SEO challenges since search engine crawlers had
difficulty understanding JavaScript-heavy content. However, modern solutions like server-
side rendering and pre-rendering have mitigated these issues to a large extent.
MPA, short for Multiple Page Applications, is the traditional web application architecture where
each user action typically results in a full page reload, and different pages serve different content.
When users click on links or submit forms, the server responds by delivering a complete new
HTML page.
Key characteristics of MPAs:
1. Separate Pages for Each Action: MPAs have dedicated pages for different tasks or
actions, leading to separate HTML, CSS, and JavaScript files.
2. Full Page Reloads: Each user action results in a full page reload, which can cause a delay
and interrupt the user experience.
3. Simple Server-Side Rendering: MPAs rely on server-side rendering to generate HTML
content and serve it to the client.
4. Better SEO: MPAs are generally more SEO-friendly since search engine crawlers can
easily understand the separate pages and their content.
5. Less Interactive: MPAs can be less interactive compared to SPAs since user interactions
often result in full page reloads, leading to a less seamless experience.
6. Standard Architecture: MPAs follow a standard web application architecture and have
been the conventional approach for a long time.
Both SPA and MPA have their strengths and weaknesses, and the choice between them depends
on the specific requirements of the application and the desired user experience. SPAs are popular
for modern web applications that demand real-time interactions, while MPAs are still used in
various scenarios, especially when SEO is a critical concern or for applications where complex
client-side interactions are not required.