Full Stack Web Development Lab Manual
Full Stack Web Development Lab Manual
ODD SEMESTER
NAME:
REGISTER NUMBER:
YEAR/SEM:
COURSE/BRANCH:
RECORD NOTE BOOK
REGISTER NUMBER: ………………………………………..
Certified that this is a Bonafide observation of Practical work done by Mr. / Ms. ........................................
Laboratory.
VISION
To be an Institute of repute in the field of Engineering and Technology by implementing the best
educational practices akin to global standards for fostering domain knowledge and developing research
attitude among students to make them globally competent
MISSION
VISION
MISSION
M1: To develop competent and quality IT professionals by imparting state-of the art technology learning
methodologies.
M2: To promote Industry – Institution relationships among the students to become more employable and
better citizens to solve societal issues.
M3: To constantly upgrade the Faculty qualification with cutting edge technology to achieve high status
in technical and research areas.
PO1 Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals
and an engineering specialization to the solution of complex engineering problems.
PO2 Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences and
engineering sciences.
PO3 Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health, safety, cultural, societal and environmental considerations.
PO4 Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis, and interpretation of data and synthesis of the information to
provide valid conclusions.
PO5 Modern tool usage: Create, select, apply appropriate techniques, resources, modern engineering and
IT tools including prediction and modeling to complex engineering activities with an understanding of
the limitations.
PO6 The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal, cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
PO7 Environment and sustainability: Understand the impact of the professional engineering solutions in
societal, environmental contexts, demonstrate the knowledge and need for sustainable development.
PO8 Ethics: Apply ethical principles, commit to professional ethics, responsibilities and norms of the
engineering practice.
PO9 Individual and team work: Function effectively as an individual, as a member or leader in diverse
teams and in multidisciplinary settings.
PO10 Communication: Communicate effectively on complex engineering activities with the engineering
community with society at large being able to comprehend, write effective reports, design
documentation, make effective presentations and receive clear instructions.
PO11 Project management and finance: Demonstrate knowledge, understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.
PO12 Life-long learning: Recognize the need, ability to engage in independent and life-long learning in
the broadest context of technological change.
To create, select, and apply appropriate techniques, resources, modern engineering and IT tools including
prediction and modelling to complex engineering activities with an understanding of the limitations.
To manage complex IT projects with consideration of the human, financial, ethical and environmental
factors and an understanding of risk management processes, and operational and policy implications.
PEO 1: To ensure graduates will be proficient and core competent by utilizing the fundamental knowledge
of Basic Sciences, Engineering, Mathematics and Information Technology for the applications of various
Engineering and Technology disciplines.
PEO 2: To enable graduates to think logically and will have the capacity to understand the social, business,
environmental based hardware and software issues by designing optimal solutions through lifelong
learning.
PEO 3: To enable graduates to gain employment in organizations and establish themselves as
professionals by applying their technical skills to solve real world problems and meet the diversified needs
of industry, academia and research.
INDEX
8
PORTFOLIO WEBSITE
Ex. No.:
Date:
Develop a portfolio website for yourself which gives details about yourself for a potential recruiter.
Aim:
To develop a portfolio website for the developer itself which gives details about a developer for a
potential recruiter
Algorithm:
1. Add HTML Skeleton
2. Add Navigation Bar
3. Add Hero section
4. Add About Me section
5. Add Work Experience section
6. Add Contact section
7. Add Footer section
Source Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Project</title>
</head>
<body>
<!--Header(start)-->
<table id="header" border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="#4CAF50">
<tr>
<td>
<table border="0" cellpadding="15" cellspacing="0" width="90%" align="center">
<tr>
<td>
</td>
<td>
<font face="Comic sans MS" size="6">
<b>AVCCE - Dept of IT</b>
</font>
</td>
<td width="15%">
</td>
<td>
<a href="#home" style="text-decoration:none">
<font face="Verdana" size="5" color=black> Home
</font>
</a>
</td>
<td>
|
</td>
<td>
<a href="#about" style="text-decoration:none">
<font face="Verdana" size="5" color=black> About
</font>
</a>
</td>
<td>
|
</td>
<td>
<a href="#projects" style="text-decoration:none">
<font face="Verdana" size="5" color=black> Projects
</font>
</a>
</td>
<td>
|
</td>
<td>
<a href="#achievements" style="text-decoration:none">
<font face="Verdana" size="5" color=black> Achievements
</font>
</a>
</td>
<td>
|
</td>
<td>
<a href="#contact" style="text-decoration:none">
<font face="Verdana" size="5" color=black> Contact
</font>
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--Header(end)-->
<!--Home(start)-->
<table id="home" border="1" width="100%" cellpadding="20" cellspacing="0" bgcolor="black">
<tr>
<td>
Myself student of ABC Engineering College, Mayiladuthurai.I am pursuing B.TECH - IT - III Year @
AVCCE. I loves to solve programming problems in most efficient ways.
<hr color="black">
I do my work mainly in C-Language,
Python and JAVA. Data Structure
& Algorithm are my stronger section. Besides these I know Web Development, LINUX and database as
well.
<hr color="black">
Thanks again for reading this, because of people like you, it exists and prospers!
<hr color="black"> Cheers,
<br>
<b>AVCCE</b>
</font>
</td>
</tr>
</table>
<hr color="black">
<hr color="black">
<hr color="black">
</td>
</tr>
</table>
<!--About(end)-->
<!--Projects(start)-->
<table id="projects" border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="#c2c0c3">
<tr>
<td>
<table border="0" cellpadding="15" cellspacing="0" width="80%" align="center">
<tr>
<td height="180" align="center" valign="middle" colspan="2">
<font face="Verdana" size="7" color="black">
Projects
</font>
<hr color="black" width="90">
</td>
</tr>
<tr>
<td height="10">
<font face="Times New Roman" size="5" color="black">
<ul>
<li>
BMI Calculator
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Calculator
<a href="#" style="text-decoration:none" color="#c2c0c3">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Calendar
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> ChatBot
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Contact Saver
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Daily Quiz
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Emplyoyee Record System
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Guess the Number-Game
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Random Password Generator
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Stone Paper Scissor
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Tic Tac Toe
<a href="#" style="text-decoration:none">
?
</a>
</li>
<li>
<hr color="#c2c0c3"> Tic Tac Toe(GUI)
<?a href="#" style="text-decoration:none">
</a>
</li>
<li>
<hr color="#c2c0c3"> ToDo App
<a href="#" style="text-decoration:none">
? </a>
</li>
<li>
<hr color="#c2c0c3"> Travel Management System
<a href="#" style= "text-decoration:none"> ?
</a>
</li>
</ul>
<hr color="#c2c0c3">
<hr color="#c2c0c3">
<hr color="#c2c0c3">
<hr color="#c2c0c3">
</font>
</td>
<td width="45%">
<img src="img.png" alt="Project" width="75%">
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--Projects(end)-->
<!--Achievement(start)-->
<table id="achievements" border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="black">
<tr>
<td>
<table border="0" cellpadding="15" cellspacing="0" width="80%" align="center">
<tr>
<td height="180" align="center" valign="middle">
<font face="Verdana" size="7" color="#4CAF50"> Achievements
<hr color="#4CAF50" width="100">
</font>
</td>
</tr>
<tr>
<td>
<font face="Verdana" size="4" color="white">
<ul>
<li>
<b>Intern at ZOHO.</b>
<ul>
<li>
December,2020 - Present.
</li>
<li>
Write technical articles
on programming related topics.
</li>
</ul>
</li>
<li>
<hr color="black">
<hr color="black">
<hr color="black">
<b> Class Representative</b>
<ul>
<li>
August,2023 - Present.
</li>
<li>
Participated events and workshops on different technologies.
</li>
</ul>
</li>
<li>
<hr color="black">
<hr color="black">
<hr color="black">
<b>Student Ambassador</b>
<ul>
<li> October,2021.
</li>
<li>
Selected for Intern at TCS
</li>
<hr color="black">
<hr color="black">
<hr color="black">
<hr color="black">
<hr color="black">
</ul>
</li>
</ul>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--Achievement(end)-->
<!--Contact(start)-->
<table id="contact" border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="#c2c0c3">
<tr>
<td>
<table border="0" cellpadding="15" cellspacing="0" width="80%" align="center">
<tr>
<td height="180" align="center" valign="middle" colspan="2">
<font face="Verdana" size="7" color="black">
Contact
</font>
<hr color="black" width="90">
</td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" width="50%" cellpadding="15 ellspa Inga="0" align="center" bgcolor="black">
<tr>
<td width="30%">
<hr color="black">
<font face="Verdana" size="4" color="#ffffff">
Name
</font>
</td>
<td width="70%">
<font face="Verdana" size="4" color="#ffffff">
<input type="text" size="40">
</font>
</td>
</tr>
<tr>
<td width="30%">
<font face="Verdana" size="4" color="#ffffff">
Email
</font>
</td>
<td width="70%">
<font face="Verdana" size="4" color="#ffffff">
<input type="email" size="40">
</font>
</td>
</tr>
<tr>
<td width="30%">
<font face="Verdana" size="4" color="#ffffff">
Number
</font>
</td>
<td width="70%">
<font face="Verdana" size="4" color="#ffffff">
<input type="number" size="12">
</font>
</td>
</tr>
<tr>
<td width="30%">
<font face="Verdana" size="4" color="#ffffff">
Message
</font>
</td>
<td width="70%">
<font face="Verdana" size="4"
color="#ffffff">
<textarea rows="5" cols="37">
</textarea>
</font>
</td>
</tr>
<tr>
<td width="30%">
</td>
<td width="70%">
<button type="Submit">
<font face="Verdana" size="4" color="black">
<b>Submit</b>
</font>
</button>
<hr color="black">
<hr color="black">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--Contact(end)-->
<!--Footer1(start)-->
<table id="footer" border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="#4CAF50">
<tr>
<td>
<table border="0" cellpadding="15" cellspacing="0" width="90%" align="center">
<tr>
<td width="13%" valign="top">
<b>LinkedIn</b>
<a href="#" style="text-decoration:none">
?
</a>
</td>
<td>
|
</td>
<td width="13%" valign="top">
<b>GitHub</b>
</td>
<td width="13%" valign="top">
<b>Website</b>
<a href="#" style="text-decoration:none">
?
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--Footer1(end)-->
<!--Footer2(start)-->
<table id="footer" border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="black">
<tr>
<td>
<table border="0" cellpadding="15" cellspacing="0" width="90%" align="center">
<tr>
<td width="80%" valign="top">
<font face="Verdana" color="#4CAF50" size="5">
©Copyright 2050 by nobody. All rights reserved.
</font>
</td>
<td width="10%">
<font face="arial" color="black" size="5">
<a href="#header" style="text-decoration:none">
<font face="Verdana" color="#4CAF50" size="6">
<b>TOP</b>
</font>
</a>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--Footer2(end)-->
</body>
</html>
Screenshot:
Result:
Todo List Application
Ex. No.:
Date:
Create a web application to manage the TO-DO list of users, where users can login and manage
their to-do items
Aim:
To create a web application to manage the TO-DO list of users, where users can login
and manage their to-do items.
Algorithms:
Source Code
index.ejs
<html>
<head>
<title> ToDo App </title>
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet">
<link href="/styles.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h2> A Simple ToDo List App </h2>
index.js
Screenshot:
Result:
Micro Blogging Application
Ex. No. :
Date:
Create a simple micro blogging application (like twitter) that allows people to post their content
which can be viewed by people who follow them
Aim:
To create a simple micro blogging application (like twitter) that allows people to post
their content which can be viewed by people who follow them.
Algorithm:
1. Social media web application clone along the lines of Signal, Facebook, a Twitter.
2. Using React we will able to develop our website.
3. Using Node.js to handle package management.
4. Download and run node js.
5. Open folder and navigate to client folder.
6. From here open terminal and do npm i
7. You might need to install a few packages .Then do npm start.
8. Website should launch locally in browser. We have mainly 3 pages 1.App.js 2.Post.js 3.Posts.js
9. This is the Structure of the project.
Source Code:
App.js
Posts.js
import React from "react";
import "./style.css"; import Post from "./Post"; const Posts = () => { const blogPosts = [
{
title: "JAVASCRIPT",
body: `JavaScript is the world most popular lightweight, interpreted compiled programming
language. It is also known as scripting language for web pages. It is well-known for
the development of web pages, many non-browser
environments also use it. JavaScript can be used for Client-side developments as well as Server-
side developments`,
author: "Nishant Singh ", imgUrl:
"https://media.geeksforgeeks.org/img-practice/banner/diving-into-excel- thumbnail.png",
},
{
title: "Data Structure ",
body: `There are many real-life examples of
a stack. Consider an example of plates stackedover one another in the canteen. The plate which is
at the top is the first one to be removed, i.e. the plate which has been placed at the bottommost
position remains in the stack for the longest period of time. So, it
can be simply seen to follow LIFO(Last InFirst Out)/FILO(First In Last Out) order.`,author:
"Suresh Kr", imgUrl:
"https://media.geeksforgeeks.org/img-practice/banner/coa-gate-2022- thumbnail.png",
},
{
title: "Algorithm",
body: `The word Algorithm means “a processor set of rules to be followed in calculations
or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that
step-
by-step define how a work is to be executed upon in order to get the expected results. `,
author: "Monu Kr", imgUrl:
"https://media.geeksforgeeks.org/img-practice/banner/google-test-series- thumbnail.png",
},
{
title: "Computer Network",
body: `An interconnection of multiple devices, also known as hosts, that are connected using
multiple paths for the purpose of sending/ receiving data media.
Computer networks can also include multiple devices/mediums which help in the communication
between two differentdevices; these are known as Network devices and include things such as
routers, switches, hubs, and bridges. `,
author: "Sonu Kr", imgUrl:
"https://media.geeksforgeeks.org/img-practice/banner/cp-maths-java- thumbnail.png",
},
];
return (
<div className="posts-container">
{blogPosts.map((post, index) => (
<Post key={index} index={index} post={post} />
))}
</div>
);
};
export default Posts;
Post.js
import React from "react"; import "./style.css";
const Post = ({ post: { title, body,
imgUrl, author }, index }) => { return (
<div className="post-container">
<h1 className="heading">{title}</h1>
<img className="image" src={imgUrl} alt="post" />
<p>{body}</p>
<div className="info">
<h4>Written by: {author}</h4>
</div>
</div>
);
};
export default Post;
Now we will style the project
Style.css in componenets folder
body {
background-color: #0e9d57;
}
.posts-container { display: flex;
justify-content: center; align-items: center;
}
.post-container { background: #e2e8d5; display: flex;
flex-direction: column; padding: 3%;
margin: 0 2%;
height: 40%;
}
.heading { height: 126px;
text-align: center; display: flex;
align-items: center;
}
.image { width: 100%; height: 210px;
}
Screenshot
Result:
Food Delivery Website
Ex. No. :
Date:
Create a food delivery website where users can order food from a particular restaurant listed in
the website.
Aim:
To create a food delivery website where users can order food from a particular restaurant listed
in the website.
Algorithm:
Online-Food-Ordering-Web-App.
Online Food Ordering System Website using basic PHP, SQL, HTML & CSS. You can use any one of
XAMPP, WAMP or LAMP server to run the Web App on your local machine.
It has a food ordering module for a customer.
It also provides menu, orders and user management module for admin. Admin Login & Password (You
can change this in phpmyadmin): Login: admin Password: admin Technologies Used
NodeJS
Express
CSS
HTML
JavaScript Tools Used
How to Install and Use
1. Download and install XAMPP/WAMP/LAMP server and download the files of this project
2. Copy the folder of this project in your xampp/htdocs/www folder
3. Start XAMMP. Start Apache and SQL server. Go to phpmyadmin and create a new database
named 'food'
4. Go to the food database created and click on 'Import' option in the top menu
Source Code
index.js
//import modules
var express = require('express'),
bodyParser = require('body-parser'),
morgan = require('morgan'),
cors = require('cors');
path = require('path');
require('dotenv').config()
//Http logger
app.use(morgan('dev'));
app.use(function (req,res,next){
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type,
Accept");
next();
});
//adding routes
app.use('/api', allRoutes);
module.exports = mysqlConnection.sequelize.define(
'customers', {
id_customer: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
fname: {
type: Sequelize.STRING
},
lname: {
type: Sequelize.STRING
},
email: {
type: Sequelize.STRING
},
phone:{
type: Sequelize.STRING
},
dob:{
type: Sequelize.DATE,
},
password: {
type: Sequelize.STRING,
},
acc_state: {
type: Sequelize.INTEGER
},
createdAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW
},
updatedAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW
}
}
);
user.js
module.exports = mysqlConnection.sequelize.define(
'users', {
id_user: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
fname:{
type: Sequelize.STRING
},
lname:{
type: Sequelize.STRING
},
username: {
type: Sequelize.STRING
},
email: {
type: Sequelize.STRING
},
password: {
type: Sequelize.STRING,
},
roles: {
type: Sequelize.STRING,
},
status:{
type: Sequelize.INTEGER,
},
createdAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW
},
updatedAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW
}
}
);
db_mysqli.js
module.exports = {
database: db};
dbconnect.js
operatorAliases: false,
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},
});
mysqlConnection.sequelize = sequelize;
mysqlConnection.Sequelize = Sequelize;
Screenshot
Result
E-COMMERCE WEBSITE
Ex. No.:
Date:
Aim:
Algorithm:
Source Code:
profile.ejs
<div class="container">
<!-- Flash messages -->
<div class="row mt-3 mb-3">
<div class="col-md-8 m-auto">
<% if (successMsg) { %>
<div id="success" class="alert alert-success">
<%= successMsg %>
</div>
<% } else { %>
<div id="success" class="alert alert-success d-none"></div>
<% } %>
</div>
<div class="col-md-8 m-auto">
<% if (errorMsg) { %>
<div id="error" class="alert alert-danger">
<%= errorMsg %>
</div>
<% } else { %>
<div id="error" class="alert alert-danger d-none"></div>
<% } %>
</div>
</div>
<!-- User's orders -->
<div class="row mt-4">
<div class="col-md-8 m-auto">
<% if (orders != null && orders.length > 0) { %>
<h3>My orders</h3>
<% orders.forEach( order => { %>
<div class="card m-3">
<div class="card-body">
<p class="card-text ">
<ul class="list-group">
<% order.cart.items.forEach( item => { %>
<li class="list-group-item d-flex justify-content-between align-items-center">
<%= item.title %> | <%= item.qty %> Units
<span class="badge badge-info badge-pill"><%= item.price %></span>
</li>
<%}) %>
</ul>
</p>
</div>
<div class="card-footer">
<strong>Total Price: $<%= order.cart.totalCost %></strong>
</div>
</div>
<%}) %>
<%} else { %>
<h3 class="text-center" >You have not made any orders yet</h3>
<%} %>
</div>
</div>
</div>
signin.ejs
<div class="container">
<div class="row">
<div class="col-md-8 m-auto">
<h1 class="mt-4 mb-4">Sign In Page</h1>
<!-- Flash message -->
<% if(errorMsg !=null && errorMsg.length>0) {%>
<div id="flash-msg" class="alert alert-danger">
<%=errorMsg %>
</div>
<%}%>
<form action="/user/signin" method="POST">
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" name="email" id="email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input
type="password"
class="form-control"
name="password"
id="password"
/>
</div>
<input type="hidden" name="_csrf" value="<%= csrfToken %>" />
<button type="submit" class="btn btn-primary button-style">
Sign In
</button>
</form>
<p class="mt-3">
Don't have an account? <a href="/user/signup"> Sign Up!</a>
</p>
</div>
</div>
</div>
signup.ejs
<div class="container">
<div class="row">
<div class="col-md-8 m-auto">
<h1 class="mt-4 mb-4">Sign Up Page</h1>
<% if(errorMsg != null && errorMsg.length>0) {%>
<div id="flash-msg" class="alert alert-danger">
<%=errorMsg %>
</div>
<%}%>
<form action="/user/signup" method="POST">
<div class="form-group">
<label for="name">Name</label>
<input
type="name"
class="form-control"
name="name"
id="name"
required
/>
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" name="email" id="email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input
type="password"
class="form-control"
name="password"
id="password"
/>
</div>
<div class="form-group">
<label for="password2">Verify Password</label>
<input
type="password"
class="form-control"
name="password2"
id="password2"
/>
</div>
<input type="hidden" name="_csrf" value="<%= csrfToken %>" />
<button type="submit" class="btn btn-primary button-style">
Sign Up
</button>
</form>
</div>
</div>
</div>
cart.js
catagory.js
mongoose.plugin(slug);
order.js
product.js
user.js
app.js
require("dotenv").config();
const createError = require("http-errors");
const express = require("express");
const path = require("path");
const cookieParser = require("cookie-parser");
const logger = require("morgan");
const mongoose = require("mongoose");
const session = require("express-session");
const passport = require("passport");
const flash = require("connect-flash");
const Category = require("./models/category");
var MongoStore = require("connect-mongo")(session);
const connectDB = require("./config/db");
// mongodb configuration
connectDB();
// view engine setup
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
// admin route
const adminRouter = require("./routes/admin");
app.use("/admin", adminRouter);
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
store: new MongoStore({
mongooseConnection: mongoose.connection,
}),
//session expires after 3 hours
cookie: { maxAge: 60 * 1000 * 60 * 3 },
})
);
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
// add breadcrumbs
get_breadcrumbs = function (url) {
var rtn = [{ name: "Home", url: "/" }],
acc = "", // accumulative url
arr = url.substring(1).split("/");
//routes config
const indexRouter = require("./routes/index");
const productsRouter = require("./routes/products");
const usersRouter = require("./routes/user");
const pagesRouter = require("./routes/pages");
app.use("/products", productsRouter);
app.use("/user", usersRouter);
app.use("/pages", pagesRouter);
app.use("/", indexRouter);
// error handler
app.use(function (err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get("env") === "development" ? err : {};
module.exports = app;
Screenshot:
Result:
LEAVE MANAGEMENT SYSTEM
Ex. No.:
Date:
Develop a leave management system for an organization where users can apply different types of
leaves such as casual leave and medical leave. They also can view the available number of days.
Aim:
To develop a leave management system for an organization where users can apply different types
of leaves such as casual leave and medical leave.
Algorithm:
Source code:
server.js
mongoose.connect((database), {
useUnifiedTopology: true,
useFindAndModify: false,
useNewUrlParser: true,
useCreateIndex: true,
})
.then(async () => {
vm.log("connected to database", database);
})
.catch(err => vm.log("error mongodb", err));
app.listen(port, () => vm.log("server running on port:", port));
auth.model.js
},
manager: {
type: Schema.Types.ObjectId,
ref: "user"
},
email: {
type: String
},
password: {
type: String
},
role: {
type: String,
enum: ['manager', 'staff'],
default: 'staff'
},
deleted: {
type: Boolean,
default: false
}
}, {timestamps: true});
auth.validation.js:
'use strict';
const Validator = require("validatorjs");
};
const validator = new Validator(obj, rules);
return {
errors: validator.errors.all(),
passed: validator.passes(),
}
},
};
auth.controller.js
const UserValidator = require("./auth.validator");
const _ = require("underscore");
/**
* @controller User authentication controller
* */
/**
* @param
* */
//CREATE ACCOUNT
exports.CreateAccount = async (req, res, next) => {
try {
let obj = req.body;
const validateUserInput = await UserValidator.validateAccount(obj);
if (!validateUserInput.passed) {
return res.status(400)
.json({
status: false,
code: 400,
message: "There's error in your inputs",
errors: validateUserInput.errors,
})
}
const checkUserEmail = await User.findOne({email: req.body.email})
if (checkUserEmail) {
return res.status(409)
.json(vm.ApiResponse(false, 409, 'email already exist'))
} else if (!checkUserEmail) {
_.extend(obj, {
password: await vm.hashedPassword(obj.password, 10),
});
const account_object = await new User(obj);
const saveAccount = await account_object.save();
if (!saveAccount) {
return res.status(400)
.json(vm.ApiResponse(false, 400, "Oops! an error occurr"))
} else {
saveAccount.password = null;
return res.status(201)
.json(vm.ApiResponse(true, 200, `account created`, account_object));
}
}
} catch (e) {
return next(e);
}
//LOGIN
exports.login = async (req, res, next) => {
try {
const checkEmail = await User.findOne({email: req.body.email});
if (!checkEmail) {
return res.status(400)
.json(vm.ApiResponse(false, 400, 'email not found'))
} else {
const compareEmail = vm.comparepassword(checkEmail.password, req.body.password);
if (compareEmail) {
const signtoken = vm.signToken(checkEmail._id, 'yourSecret');
checkEmail.password = null;
return res.status(200)
.json(vm.ApiResponse(true, 200, "login sucessfull", {user: checkEmail, token: signtoken}))
}
}
} catch (e) {
return next(e);
}
};
//list manager so when staff needs to register they can select their managers
exports.listManagers = async (req, res, next) => {
try {
auth.route.js
'use strict';
const {Router} = require('express');
const UserController = require("./auth.controller");
module.exports = router;
mailer.js
'use strict';
const Helper = require("sendgrid").mail;
const sg = require('sendgrid')('yourkey');
const vm = require("v-response");
module.exports.sendMail = sendMail;
function sendMail(from, to, subject, content, template) {
let fromEmail = new Helper.Email(from);
let toEmail = new Helper.Email(to);
let emailContent = new Helper.Content("text/html", content);
let mail = new Helper.Mail(fromEmail, subject, toEmail, emailContent);
if (err) {
vm.log("error");
vm.log("err in sendgrid: ", err);
isEmailSent = false;
}
vm.log("sendgrid body:", response.statusCode);
isEmailSent = true;
});
return isEmailSent;
Leave.model.js
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
}, {timestamps: true})
Leave.controller.js
const {sendMail} = require("../util/mailer");
//request leave
exports.requestLeave = async (req, res, next) => {
try {
const find_user = await User.findById(req.body.staff);
if (!find_user) {
return res.status(400)
.json(vm.ApiResponse(false, 400, 'Invalid user details or unverified account'))
} else {
const leaverequestBody = _.extend(req.body, {staff: find_user._id, reason: req.body.reason})
const createLeaveRequest = await new LeaveModel(leaverequestBody);
await createLeaveRequest.save();
const find_manager = await User.findOne({_id: find_user.manager});
//notify staff manager about leave request
await sendMail('noreply@leavemanagement', find_manager.email, 'Leave Request',
`${find_user.fullname} is requesting for leave`);
return res.status(200)
.json(vm.ApiResponse(true, 200, "leave request sent"))
}
} catch (e) {
return next(e);
}
};
};
Leave.route.js
'use strict';
const {ManagerChecker} = require("../util/RoleChecker");
module.exports = router;
seeder.js file
const mongoose = require("mongoose");
const bcrypt = require("bcryptjs");
mongoose.Promise = require('bluebird');
const db = 'mongodb://localhost:27017/levemanagementdb';
mongoose.connect(db);
const User = require("../authentication/auth.model");
})
}
seedUser();
Screenshot:
Result
PROJECT MANAGEMENT SYSTEM
Ex. No.:
Date:
Develop a simple dashboard for project management where the statuses of various tasks are
available. New tasks can be added and the status of existing tasks can be changed among Pending,
InProgress or Completed.
Aim:
To develop a simple dashboard for project management where the status of various tasks are
available. New tasks can be added and the status of existing tasks can be changed among Pending,
InProgress or Completed.
Algorithm:
index.js
// Connect to mongoose
require('./db');
app.js
app.use(express.static(path.join(__dirname, './public')));
app.use(express.json());
app.use(cors());
app.use('/organizations', organizationRouter);
app.use('/employees', employeeRouter);
app.use('/projects', projectRouter);
app.use('/teams', teamRouter);
app.use('/tasks', taskRouter);
app.use(validationErrorHandler);
app.use(errorHandler);
module.exports = app;
config.js
if (missingEnvVariables.length) {
throw new Error(`⚠ Missing environment variables ${missingEnvVariables}`);
}
module.exports = {
jwtSecretKey: process.env.JWT_SECRET_KEY,
port: process.env.PORT || 3000,
mongoDBUrl: process.env.MONGODB_URL,
};
db.js
mongoose
.connect(mongoDBUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log('Connected To mongoose successfully!✨✨✨'))
.catch((err) => {
console.error(err);
process.exit(1);
});
employee.js
// Employee Login
router.post('/sign-in', signIn);
// Create Employee
router.post('/', authenticate, isBusinessOwner, createEmployee);
// Get Employees
router.get('/', authenticate, getEmployees);
// Get Employee
router.get('/:id', authenticate, getEmployee);
module.exports = router;
Screenshot
Result
ONLINE SURVEY SYSTEM
Ex. No.:
Date:
Develop an online survey application where a collection of questions is available and users are asked
to answer any random 5 questions.
Aim:
To develop an online survey application where a collection of questions is available and users are
asked to answer any random 5 questions.
Source code
index.html
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="theme-color" content="#000000"/>
<meta name="description" content="SurveyJS service demo application with React/Redux"/>
<link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/>
<title>
SurveyJS Service
</title>
<script defer="defer" src="/static/js/main.2d0c3ef8.js"></script><link
href="/static/css/main.c69fb218.css" rel="stylesheet">
</head><body>
<noscript>You need to enable JavaScript to run this app.</noscript><div id="root">
</div>
</body>
</html>
if (err || !surveyResponse) {
say('Terribly sorry, but an error has occurred. Goodbye.');
return respond();
}
Result: