Professional Documents
Culture Documents
Step 1: Open Notepad and enter the below code. save it as index.js
Step 2:Write below code and save package.json file and execute.
{
"dependencies": {
"bcrypt": "^5.1.1",
"express": "^4.18.3",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.2.2",
"validator": "^13.11.0"
}
}
Requirements:
1. User Interface:
Create a user-friendly interface where users can easily browse books, view book
details, and add them to their cart.
Implement a search functionality allowing users to search for books by title
or author.
Display appropriate messages for users when they add books to their cart
or complete the checkout process.
2. Book Catalog:
Create a catalog of books with details such as title, author, price, ISBN,
and brief description.
Use a static array or JSON file to store the book data.
3. Shopping Cart:
Implement a shopping cart functionality allowing users to add books to
their cart and remove books from it.
Display the contents of the shopping cart, including the titles of the books,
quantities, and total price.
4. Checkout Process:
Allow users to proceed with the checkout process by entering their
shipping details.
Provide a summary of the order before finalizing the purchase.
5. Template Engine:
Use a template engine (such as EJS or Handlebars) to render dynamic web
pages.
Create templates for displaying the book catalog, individual book details,
shopping cart contents, and checkout pages.
6. Error Handling:
Implement error handling mechanisms to handle scenarios such as invalid
routes or missing data.
Additional Considerations:
Ensure that the application follows best practices for code organization,
separation of concerns, and modularity.
Use Express middleware for routing, request processing, and error handling.
// app.js
// Routes
app.get("/", (req, res) => {
res.render("index", { books: books });
});
// Start server
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
Practical: 9
Aim:- Creating a login component in Angular involves defining a component
that includes a form where users can input their credentials and a method to
handle the login process. Here's a breakdown of the steps to create a login
component in Angular:
Generate the Component:
Use Angular CLI to generate a new component named login. This will create the
necessary files and folder structure for the component.
<button
class="border p-3 border-black rounded-lg text-lg font-semibold"
(click)="onSubmit(myForm)"
>
Submit
</button>
</form>
</div>
</div>
RESTful API Endpoints: The service interacts with server-side resources via
RESTful API endpoints. These endpoints typically correspond to CRUD operations
such as creating, reading, updating, and deleting data.
Create: Method to send HTTP POST requests to the server to create new resources.
Read: Method to send HTTP GET requests to retrieve existing resources from the
server.
Update: Method to send HTTP PUT or PATCH requests to update existing resources
on the server.
Delete: Method to send HTTP DELETE requests to remove resources from the server.
Data Handling: The service handles data transmission between the Angular
application and the server, converting data to and from JSON format as required by
the REST API.
.card img {
width: 100%;
Output:-