@ -0,0 +1,217 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>E-Waste Marketplace</title> |
||||||
|
<style> |
||||||
|
/* General Styling */ |
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
background-color: #0ced0c; |
||||||
|
color: #04e64c; |
||||||
|
background-image: url('./images/alok.png'); /* Add background image */ |
||||||
|
background-size: cover; /* Ensures the image covers the entire background */ |
||||||
|
background-position: center; /* Center the background image */ |
||||||
|
background-attachment: fixed; /* Keeps the background fixed during scroll */ |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
box-sizing: border-box; |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
min-height: 100vh; |
||||||
|
} |
||||||
|
|
||||||
|
header { |
||||||
|
background-color: #333; |
||||||
|
color: #fff; |
||||||
|
padding: 20px 0; |
||||||
|
} |
||||||
|
|
||||||
|
footer { |
||||||
|
background-color: #333; |
||||||
|
color: #fff; |
||||||
|
text-align: center; |
||||||
|
padding: 10px; |
||||||
|
margin-top: auto; |
||||||
|
width: 100%; |
||||||
|
} |
||||||
|
|
||||||
|
/* Navigation Container */ |
||||||
|
.nav-container { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
align-items: center; |
||||||
|
padding: 0 20px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Logo */ |
||||||
|
#logo { |
||||||
|
width: 150px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Nav Items (Search Bar, Buttons, etc.) */ |
||||||
|
.nav-right { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
|
||||||
|
/* Back Button in Footer */ |
||||||
|
.back-btn { |
||||||
|
padding: 5px 15px; /* Smaller padding */ |
||||||
|
font-size: 0.9rem; /* Smaller font size */ |
||||||
|
background-color: #ccc; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
color: #333; |
||||||
|
text-decoration: none; |
||||||
|
} |
||||||
|
|
||||||
|
.back-btn:hover { |
||||||
|
background-color: #bbb; |
||||||
|
} |
||||||
|
|
||||||
|
/* Product List */ |
||||||
|
#product-list { |
||||||
|
display: flex; |
||||||
|
flex-wrap: wrap; |
||||||
|
justify-content: space-around; |
||||||
|
margin-top: 30px; |
||||||
|
padding: 0 20px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Individual Product */ |
||||||
|
.product { |
||||||
|
background-color: #fff; |
||||||
|
border-radius: 10px; |
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); |
||||||
|
margin: 10px; |
||||||
|
padding: 20px; |
||||||
|
width: 250px; |
||||||
|
text-align: center; |
||||||
|
transition: transform 0.3s; |
||||||
|
} |
||||||
|
|
||||||
|
.product:hover { |
||||||
|
transform: scale(1.05); |
||||||
|
} |
||||||
|
|
||||||
|
/* Product Image */ |
||||||
|
.product-image { |
||||||
|
width: 100%; |
||||||
|
height: auto; |
||||||
|
border-radius: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Product Title and Price */ |
||||||
|
.product h3 { |
||||||
|
font-size: 1.2rem; |
||||||
|
color: #333; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.price { |
||||||
|
font-size: 1.1rem; |
||||||
|
color: #4CAF50; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
|
||||||
|
/* View More Button */ |
||||||
|
.view-more-btn { |
||||||
|
padding: 10px 15px; |
||||||
|
background-color: #2196F3; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
text-decoration: none; |
||||||
|
} |
||||||
|
|
||||||
|
.view-more-btn:hover { |
||||||
|
background-color: #1976D2; |
||||||
|
} |
||||||
|
|
||||||
|
/* Responsive Styling */ |
||||||
|
@media (max-width: 768px) { |
||||||
|
.nav-container { |
||||||
|
flex-direction: column; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
|
||||||
|
.nav-right { |
||||||
|
margin-top: 15px; |
||||||
|
flex-direction: column; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
|
||||||
|
#search-bar { |
||||||
|
width: 100%; |
||||||
|
margin-bottom: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.product { |
||||||
|
width: 100%; |
||||||
|
max-width: 300px; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@media (max-width: 480px) { |
||||||
|
.product { |
||||||
|
width: 100%; |
||||||
|
max-width: 250px; |
||||||
|
} |
||||||
|
|
||||||
|
.auth-buttons button, #notification-btn, #cart-btn { |
||||||
|
width: 100%; |
||||||
|
margin: 5px 0; |
||||||
|
} |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
|
||||||
|
<header> |
||||||
|
<div class="nav-container"> |
||||||
|
<img src="logo.png" alt="E-Waste Marketplace" id="logo"> |
||||||
|
<div class="nav-right"> |
||||||
|
<!-- Add any additional navigation items here --> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</header> |
||||||
|
|
||||||
|
<main> |
||||||
|
<section id="product-list"> |
||||||
|
<div class="product"> |
||||||
|
<h3>Large Home Appliances</h3> |
||||||
|
<a href="large.html" class="view-more-btn">Click More</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="product"> |
||||||
|
<h3>Small Home Appliances</h3> |
||||||
|
<a href="small.html" class="view-more-btn">Click More</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="product"> |
||||||
|
<h3>Automobiles Appliances</h3> |
||||||
|
<a href="auto.html" class="view-more-btn">Click More</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="product"> |
||||||
|
<h3>Electric Shop Appliances</h3> |
||||||
|
<a href="electric.html" class="view-more-btn">Click More</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Add more products as needed --> |
||||||
|
</section> |
||||||
|
</main> |
||||||
|
|
||||||
|
<!-- Footer with Back Button --> |
||||||
|
<footer> |
||||||
|
<a href="index.html" class="back-btn">Back</a> |
||||||
|
<p>© 2025 GREENTECH. All rights reserved.</p> |
||||||
|
</footer> |
||||||
|
|
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,105 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>About Us</title> |
||||||
|
<style> |
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
background-color: #f4f4f4; |
||||||
|
color: #333; |
||||||
|
line-height: 1.6; |
||||||
|
} |
||||||
|
|
||||||
|
header { |
||||||
|
background-color: #333; |
||||||
|
color: #fff; |
||||||
|
padding: 20px 0; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
header h1 { |
||||||
|
margin: 0; |
||||||
|
font-size: 2.5rem; |
||||||
|
} |
||||||
|
|
||||||
|
.content { |
||||||
|
max-width: 800px; |
||||||
|
margin: 20px auto; |
||||||
|
padding: 20px; |
||||||
|
background: #fff; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); |
||||||
|
} |
||||||
|
|
||||||
|
h2 { |
||||||
|
color: #4CAF50; |
||||||
|
} |
||||||
|
|
||||||
|
p { |
||||||
|
margin: 15px 0; |
||||||
|
font-size: 1rem; |
||||||
|
} |
||||||
|
|
||||||
|
footer { |
||||||
|
background-color: #333; |
||||||
|
color: #fff; |
||||||
|
text-align: center; |
||||||
|
padding: 10px; |
||||||
|
position: absolute; |
||||||
|
bottom: under; |
||||||
|
width: 100%; |
||||||
|
} |
||||||
|
|
||||||
|
a { |
||||||
|
color: #4CAF50; |
||||||
|
text-decoration: none; |
||||||
|
} |
||||||
|
|
||||||
|
a:hover { |
||||||
|
text-decoration: underline; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<header> |
||||||
|
<h1>About Us</h1> |
||||||
|
</header> |
||||||
|
|
||||||
|
<div class="content"> |
||||||
|
<h2>Our Mission</h2> |
||||||
|
<p> |
||||||
|
At <strong>GREENTECH</strong>, we are committed to creating a sustainable future by promoting the responsible recycling, reuse, and resale of electronic waste. Our platform connects buyers and sellers of e-waste and refurbished electronics, providing an environmentally friendly solution for disposing of outdated or unused devices. |
||||||
|
</p> |
||||||
|
|
||||||
|
<h2>Who We Are</h2> |
||||||
|
<p> |
||||||
|
Founded in 2025, we are a team of passionate individuals dedicated to reducing the environmental impact of electronic waste. We believe that every electronic device has value, even at the end of its life cycle. By offering a marketplace for e-waste and second-hand electronics, we aim to reduce landfill waste, conserve resources, and empower individuals and businesses to make eco-conscious decisions. |
||||||
|
</p> |
||||||
|
|
||||||
|
<h2>What We Offer</h2> |
||||||
|
<p> |
||||||
|
Our platform provides a wide range of services, including: |
||||||
|
</p> |
||||||
|
<ul> |
||||||
|
<li>A marketplace to buy and sell electronic waste and refurbished electronics.</li> |
||||||
|
<li>Resources and tips on how to properly recycle and dispose of e-waste.</li> |
||||||
|
<li>Collaboration opportunities with recycling centers and refurbishing experts.</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<h2>Why Choose Us?</h2> |
||||||
|
<p> |
||||||
|
Choosing <strong>GREENTECH</strong> means supporting a cleaner, greener planet. Our user-friendly platform ensures that your e-waste finds a second life or is responsibly recycled. Together, we can make a difference. |
||||||
|
</p> |
||||||
|
|
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<footer> |
||||||
|
<p>© 2025 GREENTECH. All rights reserved.</p> |
||||||
|
</footer> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,75 @@ |
|||||||
|
// Import required modules
|
||||||
|
const express = require('express'); |
||||||
|
const bodyParser = require('body-parser'); |
||||||
|
const path = require('path'); |
||||||
|
const mysql = require('mysql'); |
||||||
|
|
||||||
|
// Initialize Express app
|
||||||
|
const app = express(); |
||||||
|
const port = 3000; |
||||||
|
|
||||||
|
// Configure middleware
|
||||||
|
app.use(bodyParser.urlencoded({ extended: true })); |
||||||
|
app.use(express.static(path.join(__dirname, 'public'))); |
||||||
|
|
||||||
|
// Configure MySQL database connection
|
||||||
|
const db = mysql.createConnection({ |
||||||
|
host: 'localhost', |
||||||
|
user: 'root', |
||||||
|
password: '', |
||||||
|
database: 'greentech' |
||||||
|
}); |
||||||
|
|
||||||
|
db.connect((err) => { |
||||||
|
if (err) { |
||||||
|
console.error('Database connection failed:', err); |
||||||
|
} else { |
||||||
|
console.log('Connected to database'); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
// Routes
|
||||||
|
// Home page (login page)
|
||||||
|
app.get('/', (req, res) => { |
||||||
|
res.sendFile(path.join(__dirname, 'public', 'login.html')); |
||||||
|
}); |
||||||
|
|
||||||
|
// Registration page
|
||||||
|
app.get('/register', (req, res) => { |
||||||
|
res.sendFile(path.join(__dirname, 'public', 'register.html')); |
||||||
|
}); |
||||||
|
|
||||||
|
// Handle user registration
|
||||||
|
app.post('/register', (req, res) => { |
||||||
|
const { username, email, password } = req.body; |
||||||
|
const query = 'INSERT INTO users (username, email, password) VALUES (?, ?, ?)'; |
||||||
|
db.query(query, [username, email, password], (err, result) => { |
||||||
|
if (err) { |
||||||
|
console.error('Error inserting user:', err); |
||||||
|
res.send('Error registering user.'); |
||||||
|
} else { |
||||||
|
res.send('User registered successfully!'); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// Handle user login
|
||||||
|
app.post('/login', (req, res) => { |
||||||
|
const { email, password } = req.body; |
||||||
|
const query = 'SELECT * FROM users WHERE email = ? AND password = ?'; |
||||||
|
db.query(query, [email, password], (err, results) => { |
||||||
|
if (err) { |
||||||
|
console.error('Error during login:', err); |
||||||
|
res.send('Error during login.'); |
||||||
|
} else if (results.length > 0) { |
||||||
|
res.send('Login successful!'); |
||||||
|
} else { |
||||||
|
res.send('Invalid email or password.'); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// Start the server
|
||||||
|
app.listen(port, () => { |
||||||
|
console.log(`Server running on http://localhost:${port}`); |
||||||
|
}); |
@ -0,0 +1,138 @@ |
|||||||
|
<section class="appliance-list"> |
||||||
|
<h2>Accepted Automobiles for Recycling</h2> |
||||||
|
<p>We accept the following automobiles for recycling. Click on an item to add it to your submission list!</p> |
||||||
|
|
||||||
|
<ul class="appliance-items"> |
||||||
|
<li class="appliance-item" style="background-image: url('images/lights-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=lights">Lights</a> |
||||||
|
<img src="./images/Lights.jpg" alt="Lights" class="product-image"> |
||||||
|
<p class="appliance-description">Automobile lighting systems such as headlights, taillights, and interior lights.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $100</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 10, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/cables-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=cables">Cables</a> |
||||||
|
<img src="./images/Cables.jpg" alt="Cables" class="product-image"> |
||||||
|
<p class="appliance-description">Automotive cables, such as wiring and connectors.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $50</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 9, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/batteries-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=batteries">Batteries</a> |
||||||
|
<img src="./images/Batteries.jpg" alt="Batteries" class="product-image"> |
||||||
|
<p class="appliance-description">Automobile batteries used for powering vehicles and electronic systems.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $120</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 8, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/speakers-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=speakers">Speakers</a> |
||||||
|
<img src="./images/Speakers.jpg" alt="Speakers" class="product-image"> |
||||||
|
<p class="appliance-description">Speakers and audio systems used in vehicles for entertainment.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $150</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 7, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/others-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=others">Others</a> |
||||||
|
<img src="./images/Other electric.jpg" alt="Other Automobiles" class="product-image"> |
||||||
|
<p class="appliance-description">Miscellaneous automobile components not listed above.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> Varies</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 6, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<p>Not sure if your vehicle is accepted? <a href="contact.html">Contact us</a> for more information!</p> |
||||||
|
</section> |
||||||
|
|
||||||
|
<!-- CSS for Background and Product Images --> |
||||||
|
<style> |
||||||
|
.appliance-list { |
||||||
|
text-align: center; |
||||||
|
padding: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-items { |
||||||
|
list-style-type: none; |
||||||
|
padding: 0; |
||||||
|
margin: 0; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item { |
||||||
|
position: relative; |
||||||
|
display: inline-block; |
||||||
|
margin: 20px; |
||||||
|
padding: 20px; |
||||||
|
width: 350px; |
||||||
|
height: 500px; |
||||||
|
background-size: cover; |
||||||
|
background-position: center; |
||||||
|
color: rgb(19, 1, 1); |
||||||
|
border-radius: 10px; |
||||||
|
overflow: hidden; |
||||||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); |
||||||
|
transition: all 0.3s ease-in-out; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item a { |
||||||
|
display: block; |
||||||
|
font-size: 20px; |
||||||
|
font-weight: bold; |
||||||
|
color: white; |
||||||
|
text-decoration: none; |
||||||
|
margin-bottom: 10px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.product-image { |
||||||
|
width: 80%; |
||||||
|
margin: 0 auto; |
||||||
|
display: block; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-description, .appliance-price, .appliance-upload-date { |
||||||
|
font-size: 14px; |
||||||
|
margin: 5px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item:hover { |
||||||
|
transform: scale(1.05); |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item a:hover { |
||||||
|
color: #ffcc00; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite { |
||||||
|
font-size: 20px; |
||||||
|
color: #fff; |
||||||
|
cursor: pointer; |
||||||
|
position: absolute; |
||||||
|
top: 10px; |
||||||
|
right: 10px; |
||||||
|
background-color: rgba(0, 0, 0, 0.5); |
||||||
|
padding: 5px; |
||||||
|
border-radius: 50%; |
||||||
|
transition: background-color 0.3s ease; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite:hover { |
||||||
|
background-color: rgba(0, 0, 0, 0.8); |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite i { |
||||||
|
color: #ff0000; |
||||||
|
} |
||||||
|
|
||||||
|
/* Font Awesome Icons */ |
||||||
|
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css'); |
||||||
|
</style> |
@ -0,0 +1,138 @@ |
|||||||
|
<section class="appliance-list"> |
||||||
|
<h2>Accepted Large Home Appliances for Recycling</h2> |
||||||
|
<p>We accept the following large home appliances for recycling. Click on an item to add it to your submission list!</p> |
||||||
|
|
||||||
|
<ul class="appliance-items"> |
||||||
|
<li class="appliance-item" style="background-image: url('images/refregerator-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=refrigerator">Refrigerators</a> |
||||||
|
<img src="./images/refregerator.jpg" alt="Refrigerator" class="product-image"> |
||||||
|
<p class="appliance-description">A large appliance used for cooling and preserving food.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $500</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 10, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/washing-machine-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=washing-machine">Washing Machines</a> |
||||||
|
<img src="./images/Washing-Machine.jpg" alt="Washing Machine" class="product-image"> |
||||||
|
<p class="appliance-description">A device used for cleaning clothes quickly and efficiently.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $350</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 9, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/dryer-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=dryer">Dryers</a> |
||||||
|
<img src="./images/dryer.jpg" alt="Dryer" class="product-image"> |
||||||
|
<p class="appliance-description">A machine designed to dry clothes after washing.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $400</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 8, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/dishwasher-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=dishwasher">Dishwashers</a> |
||||||
|
<img src="./images/Dishwasher.jpg" alt="Dishwasher" class="product-image"> |
||||||
|
<p class="appliance-description">An efficient appliance for cleaning dishes and utensils.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $300</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 7, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/others-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=others">Others</a> |
||||||
|
<img src="./images/Other large.jpg" alt="Other Appliances" class="product-image"> |
||||||
|
<p class="appliance-description">Miscellaneous appliances not listed above.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> Varies</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 6, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<p>Not sure if your appliance is accepted? <a href="contact.html">Contact us</a> for more information!</p> |
||||||
|
</section> |
||||||
|
|
||||||
|
<!-- CSS for Background and Product Images --> |
||||||
|
<style> |
||||||
|
.appliance-list { |
||||||
|
text-align: center; |
||||||
|
padding: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-items { |
||||||
|
list-style-type: none; |
||||||
|
padding: 0; |
||||||
|
margin: 0; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item { |
||||||
|
position: relative; |
||||||
|
display: inline-block; |
||||||
|
margin: 20px; |
||||||
|
padding: 20px; |
||||||
|
width: 250px; |
||||||
|
height: auto; |
||||||
|
background-size: cover; |
||||||
|
background-position: center; |
||||||
|
color: rgb(19, 1, 1); |
||||||
|
border-radius: 10px; |
||||||
|
overflow: hidden; |
||||||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); |
||||||
|
transition: all 0.3s ease-in-out; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item a { |
||||||
|
display: block; |
||||||
|
font-size: 20px; |
||||||
|
font-weight: bold; |
||||||
|
color: white; |
||||||
|
text-decoration: none; |
||||||
|
margin-bottom: 10px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.product-image { |
||||||
|
width: 80%; |
||||||
|
margin: 0 auto; |
||||||
|
display: block; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-description, .appliance-price, .appliance-upload-date { |
||||||
|
font-size: 14px; |
||||||
|
margin: 5px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item:hover { |
||||||
|
transform: scale(1.05); |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item a:hover { |
||||||
|
color: #ffcc00; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite { |
||||||
|
font-size: 20px; |
||||||
|
color: #fff; |
||||||
|
cursor: pointer; |
||||||
|
position: absolute; |
||||||
|
top: 10px; |
||||||
|
right: 10px; |
||||||
|
background-color: rgba(0, 0, 0, 0.5); |
||||||
|
padding: 5px; |
||||||
|
border-radius: 50%; |
||||||
|
transition: background-color 0.3s ease; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite:hover { |
||||||
|
background-color: rgba(0, 0, 0, 0.8); |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite i { |
||||||
|
color: #ff0000; |
||||||
|
} |
||||||
|
|
||||||
|
/* Font Awesome Icons */ |
||||||
|
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css'); |
||||||
|
</style> |
@ -0,0 +1,209 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>Buyer Signup</title> |
||||||
|
<style> |
||||||
|
/* General Styles */ |
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
background-color: #0ced0c; |
||||||
|
color: #04e64c; |
||||||
|
background-image: url('./images/alok.png'); /* Add background image */ |
||||||
|
background-size: cover; /* Ensures the image covers the entire background */ |
||||||
|
background-position: center; /* Center the background image */ |
||||||
|
background-attachment: fixed; /* Keeps the background fixed during scroll */ |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
display: flex; |
||||||
|
justify-content: center; |
||||||
|
align-items: center; |
||||||
|
height: 100vh; /* Full viewport height */ |
||||||
|
box-sizing: border-box; |
||||||
|
flex-direction: column; |
||||||
|
} |
||||||
|
|
||||||
|
/* Signup Container */ |
||||||
|
.signup-container { |
||||||
|
width: 100%; |
||||||
|
max-width: 400px; /* Maximum width of the form */ |
||||||
|
padding: 30px; |
||||||
|
background: #fff; |
||||||
|
border: 2px solid #ccc; /* Border for the container */ |
||||||
|
border-radius: 10px; |
||||||
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Subtle shadow */ |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
/* Form Heading */ |
||||||
|
.signup-container h1 { |
||||||
|
font-size: 1.8rem; |
||||||
|
margin-bottom: 20px; |
||||||
|
color: #333; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
/* Form Styles */ |
||||||
|
.signup-form { |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
gap: 15px; /* Space between form elements */ |
||||||
|
} |
||||||
|
|
||||||
|
/* Form Group */ |
||||||
|
.form-group { |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
align-items: flex-start; |
||||||
|
width: 100%; |
||||||
|
} |
||||||
|
|
||||||
|
/* Labels */ |
||||||
|
.form-group label { |
||||||
|
font-size: 1rem; |
||||||
|
font-weight: bold; |
||||||
|
margin-bottom: 5px; |
||||||
|
color: #555; |
||||||
|
} |
||||||
|
|
||||||
|
/* Input Fields */ |
||||||
|
input, |
||||||
|
textarea { |
||||||
|
width: 100%; /* Full width of the container */ |
||||||
|
padding: 10px; |
||||||
|
border: 1px solid #ccc; |
||||||
|
border-radius: 5px; |
||||||
|
font-size: 1rem; |
||||||
|
color: #333; |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
|
||||||
|
input:focus, |
||||||
|
textarea:focus { |
||||||
|
border-color: #007bff; /* Highlighted border on focus */ |
||||||
|
outline: none; |
||||||
|
} |
||||||
|
|
||||||
|
/* Textarea */ |
||||||
|
textarea { |
||||||
|
resize: none; |
||||||
|
height: 80px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Submit Button */ |
||||||
|
button { |
||||||
|
width: 100%; /* Full width of the container */ |
||||||
|
padding: 10px; |
||||||
|
font-size: 1rem; |
||||||
|
font-weight: bold; |
||||||
|
color: #fff; |
||||||
|
background-color: #007bff; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
transition: background-color 0.3s; |
||||||
|
} |
||||||
|
|
||||||
|
button:hover { |
||||||
|
background-color: #0056b3; |
||||||
|
} |
||||||
|
|
||||||
|
/* Back Button */ |
||||||
|
.back-btn { |
||||||
|
padding: 10px 20px; |
||||||
|
background-color: #ccc; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
font-size: 1rem; |
||||||
|
cursor: pointer; |
||||||
|
margin-top: 20px; |
||||||
|
text-decoration: none; |
||||||
|
color: #333; |
||||||
|
display: inline-block; |
||||||
|
} |
||||||
|
|
||||||
|
.back-btn:hover { |
||||||
|
background-color: #bbb; |
||||||
|
} |
||||||
|
|
||||||
|
/* Footer */ |
||||||
|
footer { |
||||||
|
background-color: #333; |
||||||
|
color: #fff; |
||||||
|
text-align: center; |
||||||
|
padding: 10px; |
||||||
|
width: 100%; |
||||||
|
margin-top: 50px; /* Add more space between the signup container and footer */ |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<div class="signup-container"> |
||||||
|
<h1>Buyer Signup</h1> |
||||||
|
<form class="signup-form"> |
||||||
|
<div class="form-group"> |
||||||
|
<label for="buyer-name">Full Name:</label> |
||||||
|
<input type="text" id="buyer-name" name="buyer-name" required> |
||||||
|
</div> |
||||||
|
<div class="form-group"> |
||||||
|
<label for="buyer-email">Email:</label> |
||||||
|
<input type="email" id="buyer-email" name="buyer-email" required> |
||||||
|
</div> |
||||||
|
<div class="form-group"> |
||||||
|
<label for="buyer-password">Password:</label> |
||||||
|
<input type="password" id="buyer-password" name="buyer-password" required> |
||||||
|
</div> |
||||||
|
<div class="form-group"> |
||||||
|
<label for="buyer-address">Address:</label> |
||||||
|
<textarea id="buyer-address" name="buyer-address" required></textarea> |
||||||
|
</div> |
||||||
|
<button type="submit">Register as Buyer</button> |
||||||
|
</form> |
||||||
|
|
||||||
|
<!-- Back Button --> |
||||||
|
<a href="index.html" class="back-btn">Back</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Footer --> |
||||||
|
<footer> |
||||||
|
<p>© 2025 GREENTECH. All rights reserved.</p> |
||||||
|
</footer> |
||||||
|
|
||||||
|
<script> |
||||||
|
// Get the buyer signup form |
||||||
|
const buyerSignupForm = document.querySelector('.signup-form'); |
||||||
|
|
||||||
|
// Handle buyer registration |
||||||
|
buyerSignupForm.addEventListener('submit', (event) => { |
||||||
|
event.preventDefault(); // Prevent form submission |
||||||
|
|
||||||
|
// Get form values |
||||||
|
const name = document.getElementById('buyer-name').value.trim(); |
||||||
|
const email = document.getElementById('buyer-email').value.trim(); |
||||||
|
const password = document.getElementById('buyer-password').value; |
||||||
|
const address = document.getElementById('buyer-address').value.trim(); |
||||||
|
|
||||||
|
// Check if the email is already registered |
||||||
|
const users = JSON.parse(localStorage.getItem('users')) || {}; |
||||||
|
if (users[email]) { |
||||||
|
alert('Email is already registered. Please use a different email.'); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// Save buyer details to localStorage |
||||||
|
users[email] = { |
||||||
|
name, |
||||||
|
password, |
||||||
|
address, |
||||||
|
userType: 'Buyer' // Set user type to Buyer |
||||||
|
}; |
||||||
|
localStorage.setItem('users', JSON.stringify(users)); |
||||||
|
|
||||||
|
// Redirect to the login page |
||||||
|
alert('Registration successful! Redirecting to the login page...'); |
||||||
|
window.location.href = 'login.html'; // Redirect to the login page |
||||||
|
}); |
||||||
|
</script> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,293 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>Daraz-style Cart</title> |
||||||
|
<style> |
||||||
|
/* Basic Reset */ |
||||||
|
* { |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
|
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
background-color: #f9f9f9; |
||||||
|
color: #333; |
||||||
|
} |
||||||
|
|
||||||
|
header { |
||||||
|
background-color: #ff6700; |
||||||
|
color: white; |
||||||
|
padding: 20px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
header h1 { |
||||||
|
font-size: 24px; |
||||||
|
} |
||||||
|
|
||||||
|
#product-list { |
||||||
|
display: flex; |
||||||
|
flex-wrap: wrap; |
||||||
|
justify-content: space-around; |
||||||
|
margin: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.product { |
||||||
|
background-color: white; |
||||||
|
padding: 15px; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); |
||||||
|
text-align: center; |
||||||
|
width: 250px; |
||||||
|
margin-bottom: 20px; |
||||||
|
transition: transform 0.3s; |
||||||
|
} |
||||||
|
|
||||||
|
.product:hover { |
||||||
|
transform: translateY(-5px); |
||||||
|
} |
||||||
|
|
||||||
|
.product img { |
||||||
|
width: 100%; |
||||||
|
height: auto; |
||||||
|
border-radius: 8px; |
||||||
|
} |
||||||
|
|
||||||
|
.product h4 { |
||||||
|
margin-top: 10px; |
||||||
|
font-size: 18px; |
||||||
|
} |
||||||
|
|
||||||
|
.product p { |
||||||
|
font-weight: bold; |
||||||
|
color: #ff6700; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-cart-btn { |
||||||
|
background-color: #ff6700; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
padding: 10px 15px; |
||||||
|
cursor: pointer; |
||||||
|
border-radius: 5px; |
||||||
|
margin-top: 10px; |
||||||
|
transition: background-color 0.3s; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-cart-btn:hover { |
||||||
|
background-color: #e65c00; |
||||||
|
} |
||||||
|
|
||||||
|
#cart { |
||||||
|
margin: 20px auto; |
||||||
|
padding: 20px; |
||||||
|
max-width: 800px; |
||||||
|
background-color: white; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); |
||||||
|
} |
||||||
|
|
||||||
|
#cart h2 { |
||||||
|
margin-bottom: 15px; |
||||||
|
font-size: 22px; |
||||||
|
} |
||||||
|
|
||||||
|
#cart-items { |
||||||
|
list-style: none; |
||||||
|
padding: 0; |
||||||
|
} |
||||||
|
|
||||||
|
#cart-items li { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
align-items: center; |
||||||
|
padding: 10px 0; |
||||||
|
border-bottom: 1px solid #ddd; |
||||||
|
} |
||||||
|
|
||||||
|
#cart-items li span { |
||||||
|
flex: 1; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.checkout-btn { |
||||||
|
background-color: #ff6700; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
padding: 10px 20px; |
||||||
|
cursor: pointer; |
||||||
|
border-radius: 5px; |
||||||
|
font-size: 16px; |
||||||
|
margin-top: 20px; |
||||||
|
transition: background-color 0.3s; |
||||||
|
display: block; |
||||||
|
width: 100%; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.checkout-btn:hover { |
||||||
|
background-color: #e65c00; |
||||||
|
} |
||||||
|
|
||||||
|
/* Invoice Styles */ |
||||||
|
#invoice { |
||||||
|
display: none; |
||||||
|
margin: 20px auto; |
||||||
|
max-width: 600px; |
||||||
|
background-color: white; |
||||||
|
padding: 20px; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); |
||||||
|
} |
||||||
|
|
||||||
|
#invoice h2 { |
||||||
|
text-align: center; |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice table { |
||||||
|
width: 100%; |
||||||
|
border-collapse: collapse; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice table th, #invoice table td { |
||||||
|
text-align: left; |
||||||
|
padding: 10px; |
||||||
|
border: 1px solid #ddd; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice .close-invoice { |
||||||
|
background-color: #ff6700; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
padding: 10px 20px; |
||||||
|
cursor: pointer; |
||||||
|
border-radius: 5px; |
||||||
|
margin-top: 20px; |
||||||
|
display: block; |
||||||
|
text-align: center; |
||||||
|
margin-left: auto; |
||||||
|
margin-right: auto; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice .close-invoice:hover { |
||||||
|
background-color: #e65c00; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
|
||||||
|
<header> |
||||||
|
<h1>Daraz-Style Shopping Cart</h1> |
||||||
|
</header> |
||||||
|
|
||||||
|
<section id="product-list"> |
||||||
|
<!-- Product 1 --> |
||||||
|
<div class="product"> |
||||||
|
<img src="https://via.placeholder.com/250" alt="Product"> |
||||||
|
<h4>Product 1</h4> |
||||||
|
<p>Price: $100</p> |
||||||
|
<button class="add-to-cart-btn" data-name="Product 1" data-price="100" data-discount="10">Add to Cart</button> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Product 2 --> |
||||||
|
<div class="product"> |
||||||
|
<img src="https://via.placeholder.com/250" alt="Product"> |
||||||
|
<h4>Product 2</h4> |
||||||
|
<p>Price: $200</p> |
||||||
|
<button class="add-to-cart-btn" data-name="Product 2" data-price="200" data-discount="15">Add to Cart</button> |
||||||
|
</div> |
||||||
|
</section> |
||||||
|
|
||||||
|
<section id="cart"> |
||||||
|
<h2>Your Cart</h2> |
||||||
|
<ul id="cart-items"></ul> |
||||||
|
<button class="checkout-btn">Checkout</button> |
||||||
|
</section> |
||||||
|
|
||||||
|
<section id="invoice"> |
||||||
|
<h2>Invoice</h2> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<th>Product</th> |
||||||
|
<td id="invoice-product"></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<th>Price</th> |
||||||
|
<td id="invoice-price"></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<th>Discount</th> |
||||||
|
<td id="invoice-discount"></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<th>Commission (10%)</th> |
||||||
|
<td id="invoice-commission"></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<th>Total</th> |
||||||
|
<td id="invoice-total"></td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
<button class="close-invoice">Close</button> |
||||||
|
</section> |
||||||
|
|
||||||
|
<script> |
||||||
|
const cart = []; |
||||||
|
const cartItemsElement = document.getElementById('cart-items'); |
||||||
|
const invoiceSection = document.getElementById('invoice'); |
||||||
|
|
||||||
|
function updateCart() { |
||||||
|
cartItemsElement.innerHTML = ''; |
||||||
|
cart.forEach((item) => { |
||||||
|
const li = document.createElement('li'); |
||||||
|
li.innerHTML = ` |
||||||
|
<span>${item.name}</span> |
||||||
|
<span>$${item.price}</span> |
||||||
|
<span>${item.discount}% Off</span> |
||||||
|
`; |
||||||
|
cartItemsElement.appendChild(li); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
document.querySelectorAll('.add-to-cart-btn').forEach((button) => { |
||||||
|
button.addEventListener('click', () => { |
||||||
|
const name = button.getAttribute('data-name'); |
||||||
|
const price = parseFloat(button.getAttribute('data-price')); |
||||||
|
const discount = parseFloat(button.getAttribute('data-discount')); |
||||||
|
cart.push({ name, price, discount }); |
||||||
|
updateCart(); |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
document.querySelector('.checkout-btn').addEventListener('click', () => { |
||||||
|
if (cart.length === 0) { |
||||||
|
alert('Your cart is empty!'); |
||||||
|
return; |
||||||
|
} |
||||||
|
const product = cart[0]; |
||||||
|
const discountedPrice = product.price - (product.price * (product.discount / 100)); |
||||||
|
const commission = discountedPrice * 0.1; |
||||||
|
const total = discountedPrice + commission; |
||||||
|
|
||||||
|
document.getElementById('invoice-product').textContent = product.name; |
||||||
|
document.getElementById('invoice-price').textContent = `$${product.price}`; |
||||||
|
document.getElementById('invoice-discount').textContent = `-$${(product.price * (product.discount / 100)).toFixed(2)}`; |
||||||
|
document.getElementById('invoice-commission').textContent = `$${commission.toFixed(2)}`; |
||||||
|
document.getElementById('invoice-total').textContent = `$${total.toFixed(2)}`; |
||||||
|
|
||||||
|
invoiceSection.style.display = 'block'; |
||||||
|
}); |
||||||
|
|
||||||
|
document.querySelector('.close-invoice').addEventListener('click', () => { |
||||||
|
invoiceSection.style.display = 'none'; |
||||||
|
}); |
||||||
|
</script> |
||||||
|
|
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,191 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>Cart with Invoice</title> |
||||||
|
<style> |
||||||
|
/* Basic Reset */ |
||||||
|
* { |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
|
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
background-color: #f3f3f3; |
||||||
|
color: #333; |
||||||
|
} |
||||||
|
|
||||||
|
header { |
||||||
|
background-color: #4CAF50; |
||||||
|
color: white; |
||||||
|
padding: 20px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
#product-list { |
||||||
|
display: flex; |
||||||
|
flex-wrap: wrap; |
||||||
|
justify-content: space-around; |
||||||
|
margin: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.product { |
||||||
|
background-color: white; |
||||||
|
padding: 15px; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); |
||||||
|
text-align: center; |
||||||
|
width: 250px; |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.product img { |
||||||
|
width: 100%; |
||||||
|
height: auto; |
||||||
|
border-radius: 8px; |
||||||
|
} |
||||||
|
|
||||||
|
.product h4 { |
||||||
|
margin-top: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.product p { |
||||||
|
font-weight: bold; |
||||||
|
color: #4CAF50; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-cart-btn { |
||||||
|
background-color: #4CAF50; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
padding: 10px; |
||||||
|
cursor: pointer; |
||||||
|
border-radius: 5px; |
||||||
|
margin-top: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-cart-btn:hover { |
||||||
|
background-color: #45a049; |
||||||
|
} |
||||||
|
|
||||||
|
#cart { |
||||||
|
margin: 20px; |
||||||
|
padding: 20px; |
||||||
|
background-color: #fff; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); |
||||||
|
} |
||||||
|
|
||||||
|
#cart-items { |
||||||
|
list-style: none; |
||||||
|
padding: 0; |
||||||
|
} |
||||||
|
|
||||||
|
#cart-items li { |
||||||
|
margin-bottom: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.checkout-btn { |
||||||
|
background-color: #4CAF50; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
padding: 10px; |
||||||
|
cursor: pointer; |
||||||
|
border-radius: 5px; |
||||||
|
margin-top: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.checkout-btn:hover { |
||||||
|
background-color: #45a049; |
||||||
|
} |
||||||
|
|
||||||
|
/* Invoice Popup Styles */ |
||||||
|
#invoice-popup { |
||||||
|
position: fixed; |
||||||
|
top: 50%; |
||||||
|
left: 50%; |
||||||
|
transform: translate(-50%, -50%); |
||||||
|
background-color: white; |
||||||
|
padding: 20px; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 0 15px rgba(0, 0, 0, 0.5); |
||||||
|
display: none; |
||||||
|
z-index: 1000; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice-popup h2 { |
||||||
|
text-align: center; |
||||||
|
margin-bottom: 15px; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice-popup table { |
||||||
|
width: 100%; |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice-popup table th, #invoice-popup table td { |
||||||
|
text-align: left; |
||||||
|
padding: 8px; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice-popup table th { |
||||||
|
background-color: #f4f4f4; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice-popup .close-btn { |
||||||
|
background-color: #ff4d4d; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
padding: 10px; |
||||||
|
cursor: pointer; |
||||||
|
border-radius: 5px; |
||||||
|
display: block; |
||||||
|
margin: 0 auto; |
||||||
|
} |
||||||
|
|
||||||
|
#invoice-popup .close-btn:hover { |
||||||
|
background-color: #e60000; |
||||||
|
} |
||||||
|
|
||||||
|
#overlay { |
||||||
|
position: fixed; |
||||||
|
top: 0; |
||||||
|
left: 0; |
||||||
|
width: 100%; |
||||||
|
height: 100%; |
||||||
|
background-color: rgba(0, 0, 0, 0.5); |
||||||
|
display: none; |
||||||
|
z-index: 999; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
|
||||||
|
<header> |
||||||
|
<h1>Shopping Cart with Invoice</h1> |
||||||
|
</header> |
||||||
|
|
||||||
|
<section id="product-list"> |
||||||
|
<div class="product"> |
||||||
|
<img src="./images/Phones.jpg" alt="Phone"> |
||||||
|
<h4>Non-fixable Mobile</h4> |
||||||
|
<p>Price: $50</p> |
||||||
|
<p>Discount: 10%</p> |
||||||
|
<button class="add-to-cart-btn" data-name="Non-fixable Mobile" data-price="50" data-discount="10">Add to Cart</button> |
||||||
|
</div> |
||||||
|
</section> |
||||||
|
|
||||||
|
<section id="cart"> |
||||||
|
<h2>Your Cart</h2> |
||||||
|
<ul id="cart-items"></ul> |
||||||
|
<button class="checkout-btn">Checkout</button> |
||||||
|
</section> |
||||||
|
|
||||||
|
<!-- Invoice Popup --> |
||||||
|
<div id="overlay"></div> |
||||||
|
<div id=" |
||||||
|
|
@ -0,0 +1,150 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>Contact Us</title> |
||||||
|
<!-- Font Awesome for Icons --> |
||||||
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet"> |
||||||
|
|
||||||
|
<style> |
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
background-color: #f4f4f4; |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
} |
||||||
|
|
||||||
|
header { |
||||||
|
background-color: #333; |
||||||
|
color: white; |
||||||
|
padding: 15px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.container { |
||||||
|
width: 80%; |
||||||
|
margin: 0 auto; |
||||||
|
padding: 30px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.contact-info, .contact-form, .map { |
||||||
|
margin-bottom: 30px; |
||||||
|
} |
||||||
|
|
||||||
|
h2 { |
||||||
|
text-align: center; |
||||||
|
color: #333; |
||||||
|
} |
||||||
|
|
||||||
|
.contact-info { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
flex-wrap: wrap; |
||||||
|
} |
||||||
|
|
||||||
|
.contact-info div { |
||||||
|
flex: 1; |
||||||
|
margin: 10px; |
||||||
|
padding: 20px; |
||||||
|
background-color: white; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); |
||||||
|
} |
||||||
|
|
||||||
|
.contact-info div i { |
||||||
|
font-size: 24px; |
||||||
|
margin-bottom: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.contact-info div p { |
||||||
|
margin: 5px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.contact-form { |
||||||
|
background-color: white; |
||||||
|
padding: 20px; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); |
||||||
|
} |
||||||
|
|
||||||
|
.contact-form input, .contact-form textarea { |
||||||
|
width: 100%; |
||||||
|
padding: 10px; |
||||||
|
margin: 10px 0; |
||||||
|
border-radius: 5px; |
||||||
|
border: 1px solid #ccc; |
||||||
|
} |
||||||
|
|
||||||
|
.contact-form button { |
||||||
|
padding: 10px 20px; |
||||||
|
background-color: #333; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
font-size: 16px; |
||||||
|
} |
||||||
|
|
||||||
|
.contact-form button:hover { |
||||||
|
background-color: #ffcc00; |
||||||
|
} |
||||||
|
|
||||||
|
.map { |
||||||
|
width: 100%; |
||||||
|
height: 400px; |
||||||
|
background-image: url('https://via.placeholder.com/800x400?text=Map+Placeholder'); |
||||||
|
background-size: cover; |
||||||
|
border-radius: 8px; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
|
||||||
|
<header> |
||||||
|
<h1>Contact Us</h1> |
||||||
|
</header> |
||||||
|
|
||||||
|
<div class="container"> |
||||||
|
<!-- Contact Info Section --> |
||||||
|
<div class="contact-info"> |
||||||
|
<div> |
||||||
|
<i class="fas fa-phone-alt"></i> |
||||||
|
<p><strong>Phone:</strong> +977 234 567 890</p> |
||||||
|
</div> |
||||||
|
<div> |
||||||
|
<i class="fas fa-envelope"></i> |
||||||
|
<p><strong>Email:</strong> greentech@domain.com</p> |
||||||
|
</div> |
||||||
|
<div> |
||||||
|
<i class="fas fa-map-marker-alt"></i> |
||||||
|
<p><strong>Address:</strong> Maitidevi, Kathmandu, Nepal</p> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Contact Form Section --> |
||||||
|
<div class="contact-form"> |
||||||
|
<h2>Get in Touch</h2> |
||||||
|
<form action="submit_contact_form.html" method="POST"> |
||||||
|
<label for="name">Your Name</label> |
||||||
|
<input type="text" id="name" name="name" required> |
||||||
|
|
||||||
|
<label for="email">Your Email</label> |
||||||
|
<input type="email" id="email" name="email" required> |
||||||
|
|
||||||
|
<label for="message">Your Message</label> |
||||||
|
<textarea id="message" name="message" rows="5" required></textarea> |
||||||
|
|
||||||
|
<button type="submit">Send Message</button> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Map Section --> |
||||||
|
<div class="map"> |
||||||
|
<!-- Placeholder image as a map --> |
||||||
|
<p style="color: white; text-align: center; padding-top: 180px;">Map Location (Placeholder)</p> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,138 @@ |
|||||||
|
<section class="appliance-list"> |
||||||
|
<h2>Accepted Electric Shops for Repairing and Recycling</h2> |
||||||
|
<p>We work with the following types of electric shops for mobile, PC, and other electronics repairs. Click on a shop type to add it to your submission list!</p> |
||||||
|
|
||||||
|
<ul class="appliance-items"> |
||||||
|
<li class="appliance-item" style="background-image: url('images/non-fixable-mobile-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=non-fixable mobile">Non-fixable Mobile</a> |
||||||
|
<img src="./images/Phones.jpg" alt="Non-fixable Mobile" class="product-image"> |
||||||
|
<p class="appliance-description">Electronics shops dealing with non-fixable mobile phones.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $120</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 12, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/non-fixable-pc-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=non-fixable pc-repair-shop">Non-fixable PC</a> |
||||||
|
<img src="./images/pc.jpg" alt="Non-fixable PC" class="product-image"> |
||||||
|
<p class="appliance-description">Repair shops for non-fixable PCs and laptops.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $150</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 11, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/motherboard-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=motherboard">Motherboards</a> |
||||||
|
<img src="./images/Motherboards.jpg" alt="Motherboards" class="product-image"> |
||||||
|
<p class="appliance-description">Shops specializing in motherboard repairs and recycling.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $180</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 10, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/damaged-printers-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=damaged printers">Damaged Printers</a> |
||||||
|
<img src="./images/Printers.jpg" alt="Damaged Printers" class="product-image"> |
||||||
|
<p class="appliance-description">Shops that accept damaged printers for recycling and repair.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $100</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 9, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/others-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=others">Others</a> |
||||||
|
<img src="./images/Other electric.jpg" alt="Other Electronics" class="product-image"> |
||||||
|
<p class="appliance-description">Miscellaneous electronics shops and repair types not listed above.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> Varies</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 8, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<p>Not sure if your electric shop is accepted? <a href="contact.html">Contact us</a> for more information!</p> |
||||||
|
</section> |
||||||
|
|
||||||
|
<!-- CSS for Background and Product Images --> |
||||||
|
<style> |
||||||
|
.appliance-list { |
||||||
|
text-align: center; |
||||||
|
padding: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-items { |
||||||
|
list-style-type: none; |
||||||
|
padding: 0; |
||||||
|
margin: 0; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item { |
||||||
|
position: relative; |
||||||
|
display: inline-block; |
||||||
|
margin: 20px; |
||||||
|
padding: 20px; |
||||||
|
width: 350px; |
||||||
|
height: 500px; |
||||||
|
background-size: cover; |
||||||
|
background-position: center; |
||||||
|
color: rgb(19, 1, 1); |
||||||
|
border-radius: 10px; |
||||||
|
overflow: hidden; |
||||||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); |
||||||
|
transition: all 0.3s ease-in-out; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item a { |
||||||
|
display: block; |
||||||
|
font-size: 20px; |
||||||
|
font-weight: bold; |
||||||
|
color: white; |
||||||
|
text-decoration: none; |
||||||
|
margin-bottom: 10px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.product-image { |
||||||
|
width: 80%; |
||||||
|
margin: 0 auto; |
||||||
|
display: block; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-description, .appliance-upload-date, .appliance-price { |
||||||
|
font-size: 14px; |
||||||
|
margin: 5px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item:hover { |
||||||
|
transform: scale(1.05); |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item a:hover { |
||||||
|
color: #ffcc00; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite { |
||||||
|
font-size: 20px; |
||||||
|
color: #fff; |
||||||
|
cursor: pointer; |
||||||
|
position: absolute; |
||||||
|
top: 10px; |
||||||
|
right: 10px; |
||||||
|
background-color: rgba(0, 0, 0, 0.5); |
||||||
|
padding: 5px; |
||||||
|
border-radius: 50%; |
||||||
|
transition: background-color 0.3s ease; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite:hover { |
||||||
|
background-color: rgba(0, 0, 0, 0.8); |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite i { |
||||||
|
color: #ff0000; |
||||||
|
} |
||||||
|
|
||||||
|
/* Font Awesome Icons */ |
||||||
|
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css'); |
||||||
|
</style> |
After Width: | Height: | Size: 334 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 251 KiB |
After Width: | Height: | Size: 2.0 MiB |
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 35 KiB |
@ -0,0 +1,322 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>GREENTECH</title> |
||||||
|
<style> |
||||||
|
/* General Styling */ |
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
background-color: #0ced0c; |
||||||
|
color: #04e64c; |
||||||
|
background-image: url('./images/alok.png'); /* Add background image */ |
||||||
|
background-size: cover; /* Ensures the image covers the entire background */ |
||||||
|
background-position: center; /* Center the background image */ |
||||||
|
background-attachment: fixed; /* Keeps the background fixed during scroll */ |
||||||
|
} |
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
|
||||||
|
header { |
||||||
|
background-color: #333; |
||||||
|
color: #fff; |
||||||
|
padding: 20px 0; |
||||||
|
} |
||||||
|
|
||||||
|
footer { |
||||||
|
background-color: #333; |
||||||
|
color: #fff; |
||||||
|
text-align: center; |
||||||
|
padding: 10px; |
||||||
|
position: absolute; |
||||||
|
bottom: 0%; |
||||||
|
width: 100%; |
||||||
|
} |
||||||
|
|
||||||
|
/* Navigation Container */ |
||||||
|
.nav-container { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
align-items: center; |
||||||
|
padding: 0 20px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Logo */ |
||||||
|
#logo { |
||||||
|
width: 150px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Nav Items (Search Bar, Buttons, etc.) */ |
||||||
|
.nav-right { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
|
||||||
|
/* Search Bar */ |
||||||
|
.search-container { |
||||||
|
margin-right: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
#search-bar { |
||||||
|
width: 200px; |
||||||
|
padding: 8px; |
||||||
|
font-size: 1rem; |
||||||
|
border-radius: 5px; |
||||||
|
border: 1px solid #ddd; |
||||||
|
transition: border 0.3s; |
||||||
|
} |
||||||
|
|
||||||
|
#search-bar:focus { |
||||||
|
border-color: #4CAF50; |
||||||
|
outline: none; |
||||||
|
} |
||||||
|
|
||||||
|
/* Authentication Buttons */ |
||||||
|
.auth-buttons button { |
||||||
|
margin: 0 10px; |
||||||
|
padding: 10px 15px; |
||||||
|
background-color: #4CAF50; |
||||||
|
color: #fff; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
transition: background-color 0.3s; |
||||||
|
} |
||||||
|
|
||||||
|
.auth-buttons button:hover { |
||||||
|
background-color: #45a049; |
||||||
|
} |
||||||
|
|
||||||
|
#logout-btn { |
||||||
|
display: none; |
||||||
|
} |
||||||
|
|
||||||
|
#notification-btn { |
||||||
|
padding: 10px; |
||||||
|
margin-left: 20px; |
||||||
|
background-color: #4CAF50; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
} |
||||||
|
|
||||||
|
#notification-btn:hover { |
||||||
|
background-color: #4CAF50; |
||||||
|
} |
||||||
|
|
||||||
|
#cart-btn { |
||||||
|
padding: 10px; |
||||||
|
background-color: #4CAF50; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
} |
||||||
|
|
||||||
|
#cart-btn:hover { |
||||||
|
background-color:#4CAF50; |
||||||
|
} |
||||||
|
|
||||||
|
/* Product List */ |
||||||
|
#product-list { |
||||||
|
display: flex; |
||||||
|
flex-wrap: wrap; |
||||||
|
justify-content: space-around; |
||||||
|
margin-top: 30px; |
||||||
|
padding: 0 20px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Individual Product */ |
||||||
|
.product { |
||||||
|
background-color: #fff; |
||||||
|
border-radius: 10px; |
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); |
||||||
|
margin: 10px; |
||||||
|
padding: 20px; |
||||||
|
width: 250px; |
||||||
|
text-align: center; |
||||||
|
transition: transform 0.3s; |
||||||
|
} |
||||||
|
|
||||||
|
.product:hover { |
||||||
|
transform: scale(1.05); |
||||||
|
} |
||||||
|
|
||||||
|
/* Product Image */ |
||||||
|
.product-image { |
||||||
|
width: 100%; |
||||||
|
height: auto; |
||||||
|
border-radius: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Product Title and Price */ |
||||||
|
.product h3 { |
||||||
|
font-size: 1.2rem; |
||||||
|
color: #333; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.price { |
||||||
|
font-size: 1.1rem; |
||||||
|
color: #4CAF50; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
|
||||||
|
/* View More Button */ |
||||||
|
.view-more-btn { |
||||||
|
padding: 10px 15px; |
||||||
|
background-color: #2196F3; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
text-decoration: none; |
||||||
|
} |
||||||
|
|
||||||
|
.view-more-btn:hover { |
||||||
|
background-color: #1976D2; |
||||||
|
} |
||||||
|
|
||||||
|
/* Responsive Styling */ |
||||||
|
@media (max-width: 768px) { |
||||||
|
.nav-container { |
||||||
|
flex-direction: column; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
|
||||||
|
.nav-right { |
||||||
|
margin-top: 15px; |
||||||
|
flex-direction: column; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
|
||||||
|
#search-bar { |
||||||
|
width: 100%; |
||||||
|
margin-bottom: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.product { |
||||||
|
width: 100%; |
||||||
|
max-width: 300px; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@media (max-width: 480px) { |
||||||
|
.product { |
||||||
|
width: 100%; |
||||||
|
max-width: 250px; |
||||||
|
} |
||||||
|
|
||||||
|
.auth-buttons button, #categories-btn, #cart-btn { |
||||||
|
width: 100%; |
||||||
|
margin: 5px 0; |
||||||
|
} |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
|
||||||
|
<!-- Header and Navigation --> |
||||||
|
<header> |
||||||
|
<div class="nav-container"> |
||||||
|
<!-- Logo --> |
||||||
|
<div class="logo"> |
||||||
|
<img src="logo.png" alt="E-Waste Marketplace Logo" id="logo"> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Search Bar and Nav Items --> |
||||||
|
<div class="nav-right"> |
||||||
|
<div class="search-container"> |
||||||
|
<input type="text" id="search-bar" placeholder="Search for Appliances..." onkeyup="searchProducts()"> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Navigation Buttons (Login/Register) --> |
||||||
|
<div class="auth-buttons"> |
||||||
|
<a href="login.html"><button id="login-btn">Login</button></a> |
||||||
|
<a href="seller.html"><button id="register-btn">Register for Seller</button></a> |
||||||
|
<a href="buyer.html"><button id="register-btn">Register for Buyer</button></a> |
||||||
|
<button id="logout-btn" style="display: none;">Logout</button> |
||||||
|
<a href="Categories.html"><button id="categories-btn">Categories</button></a> |
||||||
|
<button id="cart-btn">Cart</button> |
||||||
|
<a href="about.html"><button id="categories-btn">About Us</button></a> |
||||||
|
<a href="contact.html"><button id="categories-btn">Contact Us</button></a> |
||||||
|
</div> |
||||||
|
|
||||||
|
|
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</header> |
||||||
|
|
||||||
|
<!-- Main Content --> |
||||||
|
|
||||||
|
<!-- Footer --> |
||||||
|
<footer> |
||||||
|
<p>© 2025 GREENTECH. All rights reserved.</p> |
||||||
|
</footer> |
||||||
|
|
||||||
|
<script> |
||||||
|
// Search functionality: Filter products by title |
||||||
|
document.getElementById('search-bar').addEventListener('input', function() { |
||||||
|
const searchQuery = this.value.toLowerCase(); |
||||||
|
const products = document.querySelectorAll('.product'); |
||||||
|
|
||||||
|
products.forEach(product => { |
||||||
|
const productName = product.querySelector('h3').textContent.toLowerCase(); |
||||||
|
|
||||||
|
if (productName.includes(searchQuery)) { |
||||||
|
product.style.display = 'block'; |
||||||
|
} else { |
||||||
|
product.style.display = 'none'; |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// Login/Logout functionality |
||||||
|
let isLoggedIn = false; |
||||||
|
|
||||||
|
document.getElementById('login-btn').addEventListener('click', function() { |
||||||
|
isLoggedIn = true; |
||||||
|
updateLoginStatus(); |
||||||
|
}); |
||||||
|
|
||||||
|
document.getElementById('logout-btn').addEventListener('click', function() { |
||||||
|
isLoggedIn = false; |
||||||
|
updateLoginStatus(); |
||||||
|
}); |
||||||
|
|
||||||
|
// Function to update the UI based on login status |
||||||
|
function updateLoginStatus() { |
||||||
|
const loginBtn = document.getElementById('login-btn'); |
||||||
|
const logoutBtn = document.getElementById('logout-btn'); |
||||||
|
const userGreeting = document.getElementById('user-greeting'); |
||||||
|
|
||||||
|
if (isLoggedIn) { |
||||||
|
loginBtn.style.display = 'none'; |
||||||
|
logoutBtn.style.display = 'block'; |
||||||
|
userGreeting.style.display = 'block'; |
||||||
|
userGreeting.textContent = "Welcome back, User!"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Cart functionality (Basic for now) |
||||||
|
let cartItemCount = 0; |
||||||
|
|
||||||
|
document.getElementById('cart-btn').addEventListener('click', function() { |
||||||
|
cartItemCount++; |
||||||
|
updateCart(); |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
updateLoginStatus(); |
||||||
|
|
||||||
|
</script> |
||||||
|
|
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,237 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>Laptop Details - E-Waste Marketplace</title> |
||||||
|
<style> |
||||||
|
/* Basic Reset */ |
||||||
|
* { |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
|
||||||
|
body { |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
background-color: #f4f4f4; |
||||||
|
color: #333; |
||||||
|
} |
||||||
|
|
||||||
|
header { |
||||||
|
background-color: #4CAF50; |
||||||
|
color: white; |
||||||
|
padding: 20px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
header nav { |
||||||
|
margin-top: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
header nav a { |
||||||
|
color: white; |
||||||
|
text-decoration: none; |
||||||
|
padding: 5px 10px; |
||||||
|
margin: 0 10px; |
||||||
|
} |
||||||
|
|
||||||
|
header nav a:hover { |
||||||
|
background-color: #45a049; |
||||||
|
border-radius: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
main { |
||||||
|
padding: 20px; |
||||||
|
max-width: 1200px; |
||||||
|
margin: 0 auto; |
||||||
|
} |
||||||
|
|
||||||
|
.product-detail { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
margin-bottom: 40px; |
||||||
|
} |
||||||
|
|
||||||
|
.product-image img { |
||||||
|
max-width: 500px; |
||||||
|
width: 100%; |
||||||
|
height: auto; |
||||||
|
border-radius: 8px; |
||||||
|
} |
||||||
|
|
||||||
|
.product-info { |
||||||
|
width: 50%; |
||||||
|
padding-left: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.product-info h2 { |
||||||
|
font-size: 2em; |
||||||
|
margin-bottom: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.product-info .price { |
||||||
|
font-size: 1.5em; |
||||||
|
color: #4CAF50; |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.product-info p { |
||||||
|
margin-bottom: 10px; |
||||||
|
} |
||||||
|
|
||||||
|
.product-info ul { |
||||||
|
list-style-type: none; |
||||||
|
padding-left: 0; |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.product-info li { |
||||||
|
margin-bottom: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-cart-btn { |
||||||
|
background-color: #4CAF50; |
||||||
|
color: white; |
||||||
|
border: none; |
||||||
|
padding: 10px; |
||||||
|
cursor: pointer; |
||||||
|
border-radius: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-cart-btn:hover { |
||||||
|
background-color: #45a049; |
||||||
|
} |
||||||
|
|
||||||
|
.product-reviews { |
||||||
|
margin-top: 40px; |
||||||
|
} |
||||||
|
|
||||||
|
.product-reviews h3 { |
||||||
|
margin-bottom: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.review { |
||||||
|
background-color: #fff; |
||||||
|
padding: 10px; |
||||||
|
margin-bottom: 10px; |
||||||
|
border-radius: 5px; |
||||||
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); |
||||||
|
} |
||||||
|
|
||||||
|
.review p { |
||||||
|
margin-bottom: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
.review-form { |
||||||
|
margin-top: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.review-form textarea { |
||||||
|
width: 100%; |
||||||
|
padding: 10px; |
||||||
|
margin-bottom: 10px; |
||||||
|
border-radius: 5px; |
||||||
|
border: 1px solid #ddd; |
||||||
|
resize: none; |
||||||
|
} |
||||||
|
|
||||||
|
.review-form button { |
||||||
|
background-color: #4CAF50; |
||||||
|
color: white; |
||||||
|
padding: 10px 20px; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
} |
||||||
|
|
||||||
|
.review-form button:hover { |
||||||
|
background-color: #45a049; |
||||||
|
} |
||||||
|
|
||||||
|
footer { |
||||||
|
text-align: center; |
||||||
|
padding: 10px; |
||||||
|
background-color: #333; |
||||||
|
color: white; |
||||||
|
position: fixed; |
||||||
|
bottom: 0; |
||||||
|
width: 100%; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
|
||||||
|
<header> |
||||||
|
<h1>E-Waste Marketplace</h1> |
||||||
|
<nav> |
||||||
|
<a href="index.html">Home</a> | |
||||||
|
<a href="cart.html">Cart</a> |
||||||
|
</nav> |
||||||
|
</header> |
||||||
|
|
||||||
|
<main> |
||||||
|
<section class="product-detail"> |
||||||
|
<div class="product-image"> |
||||||
|
<img src="laptop1.jpg" alt="Laptop 1"> |
||||||
|
</div> |
||||||
|
<div class="product-info"> |
||||||
|
<h2>Laptop 1 - Intel i5, 8GB RAM</h2> |
||||||
|
<p class="price">$200.00</p> |
||||||
|
<p><strong>Description:</strong></p> |
||||||
|
<p>This is a refurbished laptop in excellent working condition. It comes with an Intel i5 processor, 8GB of RAM, and a 500GB HDD. Ideal for everyday tasks and light gaming.</p> |
||||||
|
|
||||||
|
<p><strong>Specifications:</strong></p> |
||||||
|
<ul> |
||||||
|
<li>Processor: Intel i5</li> |
||||||
|
<li>RAM: 8GB</li> |
||||||
|
<li>Storage: 500GB HDD</li> |
||||||
|
<li>Graphics: Integrated Intel HD</li> |
||||||
|
<li>Operating System: Windows 10</li> |
||||||
|
<li>Condition: Used (Refurbished)</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<button class="add-to-cart-btn">Add to Cart</button> |
||||||
|
</div> |
||||||
|
</section> |
||||||
|
|
||||||
|
<section class="product-reviews"> |
||||||
|
<h3>Customer Reviews</h3> |
||||||
|
<div class="review"> |
||||||
|
<p><strong>John Doe:</strong> Excellent laptop for the price. Works smoothly and looks brand new. Highly recommend!</p> |
||||||
|
</div> |
||||||
|
<div class="review"> |
||||||
|
<p><strong>Jane Smith:</strong> Good laptop for basic use, but not suitable for heavy gaming. Overall, satisfied with the purchase.</p> |
||||||
|
</div> |
||||||
|
<form class="review-form"> |
||||||
|
<label for="review">Write a review:</label> |
||||||
|
<textarea id="review" rows="4" placeholder="Write your review..."></textarea> |
||||||
|
<button type="submit">Submit Review</button> |
||||||
|
</form> |
||||||
|
</section> |
||||||
|
</main> |
||||||
|
|
||||||
|
<footer> |
||||||
|
<p>© 2025 E-Waste Marketplace. All rights reserved.</p> |
||||||
|
</footer> |
||||||
|
|
||||||
|
<script> |
||||||
|
document.querySelector('.add-to-cart-btn').addEventListener('click', function() { |
||||||
|
alert('Laptop added to your cart!'); |
||||||
|
}); |
||||||
|
|
||||||
|
// Optional: Form submission for the review |
||||||
|
document.querySelector('.review-form').addEventListener('submit', function(e) { |
||||||
|
e.preventDefault(); |
||||||
|
const reviewText = document.querySelector('#review').value; |
||||||
|
if (reviewText) { |
||||||
|
const review = document.createElement('div'); |
||||||
|
review.classList.add('review'); |
||||||
|
review.innerHTML = `<p><strong>You:</strong> ${reviewText}</p>`; |
||||||
|
document.querySelector('.product-reviews').appendChild(review); |
||||||
|
document.querySelector('#review').value = ''; // Clear the textarea |
||||||
|
} |
||||||
|
}); |
||||||
|
</script> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,138 @@ |
|||||||
|
<section class="appliance-list"> |
||||||
|
<h2>Accepted Large Home Appliances for Recycling</h2> |
||||||
|
<p>We accept the following large home appliances for recycling. Click on an item to add it to your submission list!</p> |
||||||
|
|
||||||
|
<ul class="appliance-items"> |
||||||
|
<li class="appliance-item" style="background-image: url('images/refrigerator-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=refrigerator">Refrigerators</a> |
||||||
|
<img src="images/refregerator.jpg" alt="Refrigerator" class="product-image"> |
||||||
|
<p class="appliance-description">A large appliance used for cooling and preserving food.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $500</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 10, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/washing-machine-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=washing-machine">Washing Machines</a> |
||||||
|
<img src="images/washing-machine.jpg" alt="Washing Machine" class="product-image"> |
||||||
|
<p class="appliance-description">A device used for cleaning clothes quickly and efficiently.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $350</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 9, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/dryer-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=dryer">Dryers</a> |
||||||
|
<img src="images/dryer.jpg" alt="Dryer" class="product-image"> |
||||||
|
<p class="appliance-description">A machine designed to dry clothes after washing.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $400</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 8, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/dishwasher-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=dishwasher">Dishwashers</a> |
||||||
|
<img src="images/dishwasher.jpg" alt="Dishwasher" class="product-image"> |
||||||
|
<p class="appliance-description">An efficient appliance for cleaning dishes and utensils.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> $300</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 7, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
|
||||||
|
<li class="appliance-item" style="background-image: url('images/others-bg.jpg');"> |
||||||
|
<a href="submit-ewaste.html?appliance=others">Others</a> |
||||||
|
<img src="./images/Other large.jpg" alt="Other Appliances" class="product-image"> |
||||||
|
<p class="appliance-description">Miscellaneous appliances not listed above.</p> |
||||||
|
<p class="appliance-price"><strong>Price:</strong> Varies</p> |
||||||
|
<p class="appliance-upload-date"><i class="fas fa-calendar-alt"></i> Uploaded: Jan 6, 2025</p> |
||||||
|
<span class="add-to-favorite" title="Add to Favorite"><i class="fas fa-heart"></i></span> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<p>Not sure if your appliance is accepted? <a href="contact.html">Contact us</a> for more information!</p> |
||||||
|
</section> |
||||||
|
|
||||||
|
<!-- CSS for Background and Product Images --> |
||||||
|
<style> |
||||||
|
.appliance-list { |
||||||
|
text-align: center; |
||||||
|
padding: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-items { |
||||||
|
list-style-type: none; |
||||||
|
padding: 0; |
||||||
|
margin: 0; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item { |
||||||
|
position: relative; |
||||||
|
display: inline-block; |
||||||
|
margin: 20px; |
||||||
|
padding: 20px; |
||||||
|
width: 350px; |
||||||
|
height: 500px; |
||||||
|
background-size: cover; |
||||||
|
background-position: center; |
||||||
|
color: rgb(19, 1, 1); |
||||||
|
border-radius: 10px; |
||||||
|
overflow: hidden; |
||||||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); |
||||||
|
transition: all 0.3s ease-in-out; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item a { |
||||||
|
display: block; |
||||||
|
font-size: 20px; |
||||||
|
font-weight: bold; |
||||||
|
color: white; |
||||||
|
text-decoration: none; |
||||||
|
margin-bottom: 10px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.product-image { |
||||||
|
width: 80%; |
||||||
|
margin: 0 auto; |
||||||
|
display: block; |
||||||
|
border-radius: 8px; |
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-description, .appliance-price, .appliance-upload-date { |
||||||
|
font-size: 14px; |
||||||
|
margin: 5px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item:hover { |
||||||
|
transform: scale(1.05); |
||||||
|
} |
||||||
|
|
||||||
|
.appliance-item a:hover { |
||||||
|
color: #ffcc00; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite { |
||||||
|
font-size: 20px; |
||||||
|
color: #fff; |
||||||
|
cursor: pointer; |
||||||
|
position: absolute; |
||||||
|
top: 10px; |
||||||
|
right: 10px; |
||||||
|
background-color: rgba(0, 0, 0, 0.5); |
||||||
|
padding: 5px; |
||||||
|
border-radius: 50%; |
||||||
|
transition: background-color 0.3s ease; |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite:hover { |
||||||
|
background-color: rgba(0, 0, 0, 0.8); |
||||||
|
} |
||||||
|
|
||||||
|
.add-to-favorite i { |
||||||
|
color: #ff0000; |
||||||
|
} |
||||||
|
|
||||||
|
/* Font Awesome Icons */ |
||||||
|
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css'); |
||||||
|
</style> |
@ -0,0 +1,185 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
|
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||||
|
<title>Login Page</title> |
||||||
|
<style> |
||||||
|
/* General Body Styling */ |
||||||
|
body { |
||||||
|
margin: 0; |
||||||
|
padding: 0; |
||||||
|
font-family: Arial, sans-serif; |
||||||
|
background-color: #f4f4f9; |
||||||
|
display: flex; |
||||||
|
flex-direction: column; /* Allows footer to be at the bottom */ |
||||||
|
justify-content: center; |
||||||
|
align-items: center; |
||||||
|
min-height: 100vh; |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
|
||||||
|
/* Login Container */ |
||||||
|
.login-container { |
||||||
|
width: 100%; |
||||||
|
max-width: 400px; /* Restrict maximum width */ |
||||||
|
padding: 30px; |
||||||
|
background: #ffffff; |
||||||
|
border: 2px solid #ccc; /* Subtle border */ |
||||||
|
border-radius: 10px; |
||||||
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Soft shadow */ |
||||||
|
text-align: center; |
||||||
|
animation: fadeIn 0.5s ease-in-out; /* Fade-in effect */ |
||||||
|
} |
||||||
|
|
||||||
|
/* Heading */ |
||||||
|
.login-container h2 { |
||||||
|
font-size: 1.8rem; |
||||||
|
margin-bottom: 20px; |
||||||
|
color: #333; |
||||||
|
} |
||||||
|
|
||||||
|
/* Form Group */ |
||||||
|
.form-group { |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
align-items: flex-start; |
||||||
|
margin-bottom: 15px; |
||||||
|
} |
||||||
|
|
||||||
|
/* Label Styling */ |
||||||
|
label { |
||||||
|
font-size: 1rem; |
||||||
|
font-weight: bold; |
||||||
|
margin-bottom: 5px; |
||||||
|
color: #555; |
||||||
|
} |
||||||
|
|
||||||
|
/* Input Fields */ |
||||||
|
input[type="email"], |
||||||
|
input[type="password"] { |
||||||
|
width: 100%; |
||||||
|
padding: 10px; |
||||||
|
border: 1px solid #ccc; |
||||||
|
border-radius: 5px; |
||||||
|
font-size: 1rem; |
||||||
|
color: #333; |
||||||
|
box-sizing: border-box; |
||||||
|
transition: border-color 0.3s ease-in-out; |
||||||
|
} |
||||||
|
|
||||||
|
input:focus { |
||||||
|
border-color: #007bff; |
||||||
|
outline: none; |
||||||
|
} |
||||||
|
|
||||||
|
/* Button Styling */ |
||||||
|
button { |
||||||
|
width: 100%; |
||||||
|
padding: 10px; |
||||||
|
font-size: 1rem; |
||||||
|
font-weight: bold; |
||||||
|
color: #fff; |
||||||
|
background-color: #007bff; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
transition: background-color 0.3s ease-in-out; |
||||||
|
} |
||||||
|
|
||||||
|
button:hover { |
||||||
|
background-color: #0056b3; |
||||||
|
} |
||||||
|
|
||||||
|
/* Back Button */ |
||||||
|
.back-button { |
||||||
|
margin-top: 10px; |
||||||
|
width: 100%; |
||||||
|
padding: 10px; |
||||||
|
font-size: 1rem; |
||||||
|
font-weight: bold; |
||||||
|
color: #fff; |
||||||
|
background-color: #6c757d; |
||||||
|
border: none; |
||||||
|
border-radius: 5px; |
||||||
|
cursor: pointer; |
||||||
|
transition: background-color 0.3s ease-in-out; |
||||||
|
} |
||||||
|
|
||||||
|
.back-button:hover { |
||||||
|
background-color: #5a6268; |
||||||
|
} |
||||||
|
|
||||||
|
/* Signup Link */ |
||||||
|
.signup-link { |
||||||
|
margin-top: 15px; |
||||||
|
font-size: 0.9rem; |
||||||
|
color: #555; |
||||||
|
} |
||||||
|
|
||||||
|
.signup-link a { |
||||||
|
color: #007bff; |
||||||
|
text-decoration: none; |
||||||
|
} |
||||||
|
|
||||||
|
.signup-link a:hover { |
||||||
|
text-decoration: underline; |
||||||
|
} |
||||||
|
|
||||||
|
/* Centering Animation */ |
||||||
|
@keyframes fadeIn { |
||||||
|
from { |
||||||
|
opacity: 0; |
||||||
|
transform: translateY(-10px); |
||||||
|
} |
||||||
|
to { |
||||||
|
opacity: 1; |
||||||
|
transform: translateY(0); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* Footer */ |
||||||
|
footer { |
||||||
|
background-color: #333; |
||||||
|
color: #fff; |
||||||
|
text-align: center; |
||||||
|
padding: 10px; |
||||||
|
position: absolute; |
||||||
|
bottom: 0; |
||||||
|
width: 100%; |
||||||
|
} |
||||||
|
|
||||||
|
</style> |
||||||
|
</head> |
||||||
|
|
||||||
|
<body> |
||||||
|
<div class="login-container"> |
||||||
|
<h2>Login</h2> |
||||||
|
<form id="login-form"> |
||||||
|
<div class="form-group"> |
||||||
|
<label for="email">Email</label> |
||||||
|
<input type="email" id="email" name="email" placeholder="Enter your email" required> |
||||||
|
</div> |
||||||
|
<div class="form-group"> |
||||||
|
<label for="password">Password</label> |
||||||
|
<input type="password" id="password" name="password" placeholder="Enter your password" required> |
||||||
|
</div> |
||||||
|
<button type="submit" class="animated-btn">Login</button> |
||||||
|
<button type="button" class="back-button" onclick="window.history.back()"> |
||||||
|
<i class="fas fa-arrow-left"></i> Back |
||||||
|
</button> |
||||||
|
<p class="signup-link"> |
||||||
|
Don't have an account? |
||||||
|
<a href="buyer.html">Register as a Buyer</a> | |
||||||
|
<a href="seller.html">Register as a Seller</a> |
||||||
|
</p> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
|
||||||
|
<footer> |
||||||
|
<p>© 2025 GREENTECH. All rights reserved.</p> |
||||||
|
</footer> |
||||||
|
</body> |
||||||
|
|
||||||
|
</html> |
@ -0,0 +1,16 @@ |
|||||||
|
#!/bin/sh |
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") |
||||||
|
|
||||||
|
case `uname` in |
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) |
||||||
|
if command -v cygpath > /dev/null 2>&1; then |
||||||
|
basedir=`cygpath -w "$basedir"` |
||||||
|
fi |
||||||
|
;; |
||||||
|
esac |
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then |
||||||
|
exec "$basedir/node" "$basedir/../mime/cli.js" "$@" |
||||||
|
else |
||||||
|
exec node "$basedir/../mime/cli.js" "$@" |
||||||
|
fi |
@ -0,0 +1,17 @@ |
|||||||
|
@ECHO off |
||||||
|
GOTO start |
||||||
|
:find_dp0 |
||||||
|
SET dp0=%~dp0 |
||||||
|
EXIT /b |
||||||
|
:start |
||||||
|
SETLOCAL |
||||||
|
CALL :find_dp0 |
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" ( |
||||||
|
SET "_prog=%dp0%\node.exe" |
||||||
|
) ELSE ( |
||||||
|
SET "_prog=node" |
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;% |
||||||
|
) |
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %* |
@ -0,0 +1,28 @@ |
|||||||
|
#!/usr/bin/env pwsh |
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent |
||||||
|
|
||||||
|
$exe="" |
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { |
||||||
|
# Fix case when both the Windows and Linux builds of Node |
||||||
|
# are installed in the same directory |
||||||
|
$exe=".exe" |
||||||
|
} |
||||||
|
$ret=0 |
||||||
|
if (Test-Path "$basedir/node$exe") { |
||||||
|
# Support pipeline input |
||||||
|
if ($MyInvocation.ExpectingInput) { |
||||||
|
$input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args |
||||||
|
} else { |
||||||
|
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args |
||||||
|
} |
||||||
|
$ret=$LASTEXITCODE |
||||||
|
} else { |
||||||
|
# Support pipeline input |
||||||
|
if ($MyInvocation.ExpectingInput) { |
||||||
|
$input | & "node$exe" "$basedir/../mime/cli.js" $args |
||||||
|
} else { |
||||||
|
& "node$exe" "$basedir/../mime/cli.js" $args |
||||||
|
} |
||||||
|
$ret=$LASTEXITCODE |
||||||
|
} |
||||||
|
exit $ret |
@ -0,0 +1,924 @@ |
|||||||
|
{ |
||||||
|
"name": "green-tech", |
||||||
|
"version": "1.0.0", |
||||||
|
"lockfileVersion": 3, |
||||||
|
"requires": true, |
||||||
|
"packages": { |
||||||
|
"node_modules/accepts": { |
||||||
|
"version": "1.3.8", |
||||||
|
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", |
||||||
|
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"mime-types": "~2.1.34", |
||||||
|
"negotiator": "0.6.3" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/array-flatten": { |
||||||
|
"version": "1.1.1", |
||||||
|
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", |
||||||
|
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/bignumber.js": { |
||||||
|
"version": "9.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz", |
||||||
|
"integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": "*" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/body-parser": { |
||||||
|
"version": "1.20.3", |
||||||
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", |
||||||
|
"integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"bytes": "3.1.2", |
||||||
|
"content-type": "~1.0.5", |
||||||
|
"debug": "2.6.9", |
||||||
|
"depd": "2.0.0", |
||||||
|
"destroy": "1.2.0", |
||||||
|
"http-errors": "2.0.0", |
||||||
|
"iconv-lite": "0.4.24", |
||||||
|
"on-finished": "2.4.1", |
||||||
|
"qs": "6.13.0", |
||||||
|
"raw-body": "2.5.2", |
||||||
|
"type-is": "~1.6.18", |
||||||
|
"unpipe": "1.0.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8", |
||||||
|
"npm": "1.2.8000 || >= 1.4.16" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/bytes": { |
||||||
|
"version": "3.1.2", |
||||||
|
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", |
||||||
|
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/call-bind-apply-helpers": { |
||||||
|
"version": "1.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz", |
||||||
|
"integrity": "sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"es-errors": "^1.3.0", |
||||||
|
"function-bind": "^1.1.2" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/call-bound": { |
||||||
|
"version": "1.0.3", |
||||||
|
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.3.tgz", |
||||||
|
"integrity": "sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"call-bind-apply-helpers": "^1.0.1", |
||||||
|
"get-intrinsic": "^1.2.6" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/content-disposition": { |
||||||
|
"version": "0.5.4", |
||||||
|
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", |
||||||
|
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"safe-buffer": "5.2.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/content-type": { |
||||||
|
"version": "1.0.5", |
||||||
|
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", |
||||||
|
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/cookie": { |
||||||
|
"version": "0.7.1", |
||||||
|
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", |
||||||
|
"integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/cookie-signature": { |
||||||
|
"version": "1.0.6", |
||||||
|
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", |
||||||
|
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/core-util-is": { |
||||||
|
"version": "1.0.3", |
||||||
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", |
||||||
|
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/debug": { |
||||||
|
"version": "2.6.9", |
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", |
||||||
|
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"ms": "2.0.0" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/depd": { |
||||||
|
"version": "2.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", |
||||||
|
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/destroy": { |
||||||
|
"version": "1.2.0", |
||||||
|
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", |
||||||
|
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8", |
||||||
|
"npm": "1.2.8000 || >= 1.4.16" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/dunder-proto": { |
||||||
|
"version": "1.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", |
||||||
|
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"call-bind-apply-helpers": "^1.0.1", |
||||||
|
"es-errors": "^1.3.0", |
||||||
|
"gopd": "^1.2.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/ee-first": { |
||||||
|
"version": "1.1.1", |
||||||
|
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", |
||||||
|
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/encodeurl": { |
||||||
|
"version": "2.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", |
||||||
|
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/es-define-property": { |
||||||
|
"version": "1.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", |
||||||
|
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/es-errors": { |
||||||
|
"version": "1.3.0", |
||||||
|
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", |
||||||
|
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/es-object-atoms": { |
||||||
|
"version": "1.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", |
||||||
|
"integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"es-errors": "^1.3.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/escape-html": { |
||||||
|
"version": "1.0.3", |
||||||
|
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", |
||||||
|
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/etag": { |
||||||
|
"version": "1.8.1", |
||||||
|
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", |
||||||
|
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/express": { |
||||||
|
"version": "4.21.2", |
||||||
|
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", |
||||||
|
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"accepts": "~1.3.8", |
||||||
|
"array-flatten": "1.1.1", |
||||||
|
"body-parser": "1.20.3", |
||||||
|
"content-disposition": "0.5.4", |
||||||
|
"content-type": "~1.0.4", |
||||||
|
"cookie": "0.7.1", |
||||||
|
"cookie-signature": "1.0.6", |
||||||
|
"debug": "2.6.9", |
||||||
|
"depd": "2.0.0", |
||||||
|
"encodeurl": "~2.0.0", |
||||||
|
"escape-html": "~1.0.3", |
||||||
|
"etag": "~1.8.1", |
||||||
|
"finalhandler": "1.3.1", |
||||||
|
"fresh": "0.5.2", |
||||||
|
"http-errors": "2.0.0", |
||||||
|
"merge-descriptors": "1.0.3", |
||||||
|
"methods": "~1.1.2", |
||||||
|
"on-finished": "2.4.1", |
||||||
|
"parseurl": "~1.3.3", |
||||||
|
"path-to-regexp": "0.1.12", |
||||||
|
"proxy-addr": "~2.0.7", |
||||||
|
"qs": "6.13.0", |
||||||
|
"range-parser": "~1.2.1", |
||||||
|
"safe-buffer": "5.2.1", |
||||||
|
"send": "0.19.0", |
||||||
|
"serve-static": "1.16.2", |
||||||
|
"setprototypeof": "1.2.0", |
||||||
|
"statuses": "2.0.1", |
||||||
|
"type-is": "~1.6.18", |
||||||
|
"utils-merge": "1.0.1", |
||||||
|
"vary": "~1.1.2" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.10.0" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"type": "opencollective", |
||||||
|
"url": "https://opencollective.com/express" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/finalhandler": { |
||||||
|
"version": "1.3.1", |
||||||
|
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", |
||||||
|
"integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"debug": "2.6.9", |
||||||
|
"encodeurl": "~2.0.0", |
||||||
|
"escape-html": "~1.0.3", |
||||||
|
"on-finished": "2.4.1", |
||||||
|
"parseurl": "~1.3.3", |
||||||
|
"statuses": "2.0.1", |
||||||
|
"unpipe": "~1.0.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/forwarded": { |
||||||
|
"version": "0.2.0", |
||||||
|
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", |
||||||
|
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/fresh": { |
||||||
|
"version": "0.5.2", |
||||||
|
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", |
||||||
|
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/function-bind": { |
||||||
|
"version": "1.1.2", |
||||||
|
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", |
||||||
|
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", |
||||||
|
"license": "MIT", |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/get-intrinsic": { |
||||||
|
"version": "1.2.7", |
||||||
|
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.7.tgz", |
||||||
|
"integrity": "sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"call-bind-apply-helpers": "^1.0.1", |
||||||
|
"es-define-property": "^1.0.1", |
||||||
|
"es-errors": "^1.3.0", |
||||||
|
"es-object-atoms": "^1.0.0", |
||||||
|
"function-bind": "^1.1.2", |
||||||
|
"get-proto": "^1.0.0", |
||||||
|
"gopd": "^1.2.0", |
||||||
|
"has-symbols": "^1.1.0", |
||||||
|
"hasown": "^2.0.2", |
||||||
|
"math-intrinsics": "^1.1.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/get-proto": { |
||||||
|
"version": "1.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", |
||||||
|
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"dunder-proto": "^1.0.1", |
||||||
|
"es-object-atoms": "^1.0.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/gopd": { |
||||||
|
"version": "1.2.0", |
||||||
|
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", |
||||||
|
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/has-symbols": { |
||||||
|
"version": "1.1.0", |
||||||
|
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", |
||||||
|
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/hasown": { |
||||||
|
"version": "2.0.2", |
||||||
|
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", |
||||||
|
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"function-bind": "^1.1.2" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/http-errors": { |
||||||
|
"version": "2.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", |
||||||
|
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"depd": "2.0.0", |
||||||
|
"inherits": "2.0.4", |
||||||
|
"setprototypeof": "1.2.0", |
||||||
|
"statuses": "2.0.1", |
||||||
|
"toidentifier": "1.0.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/iconv-lite": { |
||||||
|
"version": "0.4.24", |
||||||
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", |
||||||
|
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"safer-buffer": ">= 2.1.2 < 3" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">=0.10.0" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/inherits": { |
||||||
|
"version": "2.0.4", |
||||||
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", |
||||||
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", |
||||||
|
"license": "ISC" |
||||||
|
}, |
||||||
|
"node_modules/ipaddr.js": { |
||||||
|
"version": "1.9.1", |
||||||
|
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", |
||||||
|
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.10" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/isarray": { |
||||||
|
"version": "1.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", |
||||||
|
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/math-intrinsics": { |
||||||
|
"version": "1.1.0", |
||||||
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", |
||||||
|
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/media-typer": { |
||||||
|
"version": "0.3.0", |
||||||
|
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", |
||||||
|
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/merge-descriptors": { |
||||||
|
"version": "1.0.3", |
||||||
|
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", |
||||||
|
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", |
||||||
|
"license": "MIT", |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/sindresorhus" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/methods": { |
||||||
|
"version": "1.1.2", |
||||||
|
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", |
||||||
|
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/mime": { |
||||||
|
"version": "1.6.0", |
||||||
|
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", |
||||||
|
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", |
||||||
|
"license": "MIT", |
||||||
|
"bin": { |
||||||
|
"mime": "cli.js" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">=4" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/mime-db": { |
||||||
|
"version": "1.52.0", |
||||||
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", |
||||||
|
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/mime-types": { |
||||||
|
"version": "2.1.35", |
||||||
|
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", |
||||||
|
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"mime-db": "1.52.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/ms": { |
||||||
|
"version": "2.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", |
||||||
|
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/mysql": { |
||||||
|
"version": "2.18.1", |
||||||
|
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz", |
||||||
|
"integrity": "sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"bignumber.js": "9.0.0", |
||||||
|
"readable-stream": "2.3.7", |
||||||
|
"safe-buffer": "5.1.2", |
||||||
|
"sqlstring": "2.3.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/mysql/node_modules/safe-buffer": { |
||||||
|
"version": "5.1.2", |
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", |
||||||
|
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/negotiator": { |
||||||
|
"version": "0.6.3", |
||||||
|
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", |
||||||
|
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/object-inspect": { |
||||||
|
"version": "1.13.3", |
||||||
|
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", |
||||||
|
"integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/on-finished": { |
||||||
|
"version": "2.4.1", |
||||||
|
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", |
||||||
|
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"ee-first": "1.1.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/parseurl": { |
||||||
|
"version": "1.3.3", |
||||||
|
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", |
||||||
|
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/path-to-regexp": { |
||||||
|
"version": "0.1.12", |
||||||
|
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", |
||||||
|
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/process-nextick-args": { |
||||||
|
"version": "2.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", |
||||||
|
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/proxy-addr": { |
||||||
|
"version": "2.0.7", |
||||||
|
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", |
||||||
|
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"forwarded": "0.2.0", |
||||||
|
"ipaddr.js": "1.9.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.10" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/qs": { |
||||||
|
"version": "6.13.0", |
||||||
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", |
||||||
|
"integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", |
||||||
|
"license": "BSD-3-Clause", |
||||||
|
"dependencies": { |
||||||
|
"side-channel": "^1.0.6" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">=0.6" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/range-parser": { |
||||||
|
"version": "1.2.1", |
||||||
|
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", |
||||||
|
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/raw-body": { |
||||||
|
"version": "2.5.2", |
||||||
|
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", |
||||||
|
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"bytes": "3.1.2", |
||||||
|
"http-errors": "2.0.0", |
||||||
|
"iconv-lite": "0.4.24", |
||||||
|
"unpipe": "1.0.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/readable-stream": { |
||||||
|
"version": "2.3.7", |
||||||
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", |
||||||
|
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"core-util-is": "~1.0.0", |
||||||
|
"inherits": "~2.0.3", |
||||||
|
"isarray": "~1.0.0", |
||||||
|
"process-nextick-args": "~2.0.0", |
||||||
|
"safe-buffer": "~5.1.1", |
||||||
|
"string_decoder": "~1.1.1", |
||||||
|
"util-deprecate": "~1.0.1" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/readable-stream/node_modules/safe-buffer": { |
||||||
|
"version": "5.1.2", |
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", |
||||||
|
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/safe-buffer": { |
||||||
|
"version": "5.2.1", |
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", |
||||||
|
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", |
||||||
|
"funding": [ |
||||||
|
{ |
||||||
|
"type": "github", |
||||||
|
"url": "https://github.com/sponsors/feross" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "patreon", |
||||||
|
"url": "https://www.patreon.com/feross" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "consulting", |
||||||
|
"url": "https://feross.org/support" |
||||||
|
} |
||||||
|
], |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/safer-buffer": { |
||||||
|
"version": "2.1.2", |
||||||
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", |
||||||
|
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/send": { |
||||||
|
"version": "0.19.0", |
||||||
|
"resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", |
||||||
|
"integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"debug": "2.6.9", |
||||||
|
"depd": "2.0.0", |
||||||
|
"destroy": "1.2.0", |
||||||
|
"encodeurl": "~1.0.2", |
||||||
|
"escape-html": "~1.0.3", |
||||||
|
"etag": "~1.8.1", |
||||||
|
"fresh": "0.5.2", |
||||||
|
"http-errors": "2.0.0", |
||||||
|
"mime": "1.6.0", |
||||||
|
"ms": "2.1.3", |
||||||
|
"on-finished": "2.4.1", |
||||||
|
"range-parser": "~1.2.1", |
||||||
|
"statuses": "2.0.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8.0" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/send/node_modules/encodeurl": { |
||||||
|
"version": "1.0.2", |
||||||
|
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", |
||||||
|
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/send/node_modules/ms": { |
||||||
|
"version": "2.1.3", |
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", |
||||||
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/serve-static": { |
||||||
|
"version": "1.16.2", |
||||||
|
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", |
||||||
|
"integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"encodeurl": "~2.0.0", |
||||||
|
"escape-html": "~1.0.3", |
||||||
|
"parseurl": "~1.3.3", |
||||||
|
"send": "0.19.0" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8.0" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/setprototypeof": { |
||||||
|
"version": "1.2.0", |
||||||
|
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", |
||||||
|
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", |
||||||
|
"license": "ISC" |
||||||
|
}, |
||||||
|
"node_modules/side-channel": { |
||||||
|
"version": "1.1.0", |
||||||
|
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", |
||||||
|
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"es-errors": "^1.3.0", |
||||||
|
"object-inspect": "^1.13.3", |
||||||
|
"side-channel-list": "^1.0.0", |
||||||
|
"side-channel-map": "^1.0.1", |
||||||
|
"side-channel-weakmap": "^1.0.2" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/side-channel-list": { |
||||||
|
"version": "1.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", |
||||||
|
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"es-errors": "^1.3.0", |
||||||
|
"object-inspect": "^1.13.3" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/side-channel-map": { |
||||||
|
"version": "1.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", |
||||||
|
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"call-bound": "^1.0.2", |
||||||
|
"es-errors": "^1.3.0", |
||||||
|
"get-intrinsic": "^1.2.5", |
||||||
|
"object-inspect": "^1.13.3" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/side-channel-weakmap": { |
||||||
|
"version": "1.0.2", |
||||||
|
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", |
||||||
|
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"call-bound": "^1.0.2", |
||||||
|
"es-errors": "^1.3.0", |
||||||
|
"get-intrinsic": "^1.2.5", |
||||||
|
"object-inspect": "^1.13.3", |
||||||
|
"side-channel-map": "^1.0.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
}, |
||||||
|
"funding": { |
||||||
|
"url": "https://github.com/sponsors/ljharb" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/sqlstring": { |
||||||
|
"version": "2.3.1", |
||||||
|
"resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", |
||||||
|
"integrity": "sha512-ooAzh/7dxIG5+uDik1z/Rd1vli0+38izZhGzSa34FwR7IbelPWCCKSNIl8jlL/F7ERvy8CB2jNeM1E9i9mXMAQ==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/statuses": { |
||||||
|
"version": "2.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", |
||||||
|
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/string_decoder": { |
||||||
|
"version": "1.1.1", |
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", |
||||||
|
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"safe-buffer": "~5.1.0" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/string_decoder/node_modules/safe-buffer": { |
||||||
|
"version": "5.1.2", |
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", |
||||||
|
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/toidentifier": { |
||||||
|
"version": "1.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", |
||||||
|
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">=0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/type-is": { |
||||||
|
"version": "1.6.18", |
||||||
|
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", |
||||||
|
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", |
||||||
|
"license": "MIT", |
||||||
|
"dependencies": { |
||||||
|
"media-typer": "0.3.0", |
||||||
|
"mime-types": "~2.1.24" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/unpipe": { |
||||||
|
"version": "1.0.0", |
||||||
|
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", |
||||||
|
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/util-deprecate": { |
||||||
|
"version": "1.0.2", |
||||||
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", |
||||||
|
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", |
||||||
|
"license": "MIT" |
||||||
|
}, |
||||||
|
"node_modules/utils-merge": { |
||||||
|
"version": "1.0.1", |
||||||
|
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", |
||||||
|
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4.0" |
||||||
|
} |
||||||
|
}, |
||||||
|
"node_modules/vary": { |
||||||
|
"version": "1.1.2", |
||||||
|
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", |
||||||
|
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", |
||||||
|
"license": "MIT", |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,243 @@ |
|||||||
|
1.3.8 / 2022-02-02 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.34 |
||||||
|
- deps: mime-db@~1.51.0 |
||||||
|
* deps: negotiator@0.6.3 |
||||||
|
|
||||||
|
1.3.7 / 2019-04-29 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.6.2 |
||||||
|
- Fix sorting charset, encoding, and language with extra parameters |
||||||
|
|
||||||
|
1.3.6 / 2019-04-28 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.24 |
||||||
|
- deps: mime-db@~1.40.0 |
||||||
|
|
||||||
|
1.3.5 / 2018-02-28 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.18 |
||||||
|
- deps: mime-db@~1.33.0 |
||||||
|
|
||||||
|
1.3.4 / 2017-08-22 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.16 |
||||||
|
- deps: mime-db@~1.29.0 |
||||||
|
|
||||||
|
1.3.3 / 2016-05-02 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.11 |
||||||
|
- deps: mime-db@~1.23.0 |
||||||
|
* deps: negotiator@0.6.1 |
||||||
|
- perf: improve `Accept` parsing speed |
||||||
|
- perf: improve `Accept-Charset` parsing speed |
||||||
|
- perf: improve `Accept-Encoding` parsing speed |
||||||
|
- perf: improve `Accept-Language` parsing speed |
||||||
|
|
||||||
|
1.3.2 / 2016-03-08 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.10 |
||||||
|
- Fix extension of `application/dash+xml` |
||||||
|
- Update primary extension for `audio/mp4` |
||||||
|
- deps: mime-db@~1.22.0 |
||||||
|
|
||||||
|
1.3.1 / 2016-01-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.9 |
||||||
|
- deps: mime-db@~1.21.0 |
||||||
|
|
||||||
|
1.3.0 / 2015-09-29 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.7 |
||||||
|
- deps: mime-db@~1.19.0 |
||||||
|
* deps: negotiator@0.6.0 |
||||||
|
- Fix including type extensions in parameters in `Accept` parsing |
||||||
|
- Fix parsing `Accept` parameters with quoted equals |
||||||
|
- Fix parsing `Accept` parameters with quoted semicolons |
||||||
|
- Lazy-load modules from main entry point |
||||||
|
- perf: delay type concatenation until needed |
||||||
|
- perf: enable strict mode |
||||||
|
- perf: hoist regular expressions |
||||||
|
- perf: remove closures getting spec properties |
||||||
|
- perf: remove a closure from media type parsing |
||||||
|
- perf: remove property delete from media type parsing |
||||||
|
|
||||||
|
1.2.13 / 2015-09-06 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.6 |
||||||
|
- deps: mime-db@~1.18.0 |
||||||
|
|
||||||
|
1.2.12 / 2015-07-30 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.4 |
||||||
|
- deps: mime-db@~1.16.0 |
||||||
|
|
||||||
|
1.2.11 / 2015-07-16 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.3 |
||||||
|
- deps: mime-db@~1.15.0 |
||||||
|
|
||||||
|
1.2.10 / 2015-07-01 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.2 |
||||||
|
- deps: mime-db@~1.14.0 |
||||||
|
|
||||||
|
1.2.9 / 2015-06-08 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.1 |
||||||
|
- perf: fix deopt during mapping |
||||||
|
|
||||||
|
1.2.8 / 2015-06-07 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.0 |
||||||
|
- deps: mime-db@~1.13.0 |
||||||
|
* perf: avoid argument reassignment & argument slice |
||||||
|
* perf: avoid negotiator recursive construction |
||||||
|
* perf: enable strict mode |
||||||
|
* perf: remove unnecessary bitwise operator |
||||||
|
|
||||||
|
1.2.7 / 2015-05-10 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.5.3 |
||||||
|
- Fix media type parameter matching to be case-insensitive |
||||||
|
|
||||||
|
1.2.6 / 2015-05-07 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.11 |
||||||
|
- deps: mime-db@~1.9.1 |
||||||
|
* deps: negotiator@0.5.2 |
||||||
|
- Fix comparing media types with quoted values |
||||||
|
- Fix splitting media types with quoted commas |
||||||
|
|
||||||
|
1.2.5 / 2015-03-13 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.10 |
||||||
|
- deps: mime-db@~1.8.0 |
||||||
|
|
||||||
|
1.2.4 / 2015-02-14 |
||||||
|
================== |
||||||
|
|
||||||
|
* Support Node.js 0.6 |
||||||
|
* deps: mime-types@~2.0.9 |
||||||
|
- deps: mime-db@~1.7.0 |
||||||
|
* deps: negotiator@0.5.1 |
||||||
|
- Fix preference sorting to be stable for long acceptable lists |
||||||
|
|
||||||
|
1.2.3 / 2015-01-31 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.8 |
||||||
|
- deps: mime-db@~1.6.0 |
||||||
|
|
||||||
|
1.2.2 / 2014-12-30 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.7 |
||||||
|
- deps: mime-db@~1.5.0 |
||||||
|
|
||||||
|
1.2.1 / 2014-12-30 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.5 |
||||||
|
- deps: mime-db@~1.3.1 |
||||||
|
|
||||||
|
1.2.0 / 2014-12-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.5.0 |
||||||
|
- Fix list return order when large accepted list |
||||||
|
- Fix missing identity encoding when q=0 exists |
||||||
|
- Remove dynamic building of Negotiator class |
||||||
|
|
||||||
|
1.1.4 / 2014-12-10 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.4 |
||||||
|
- deps: mime-db@~1.3.0 |
||||||
|
|
||||||
|
1.1.3 / 2014-11-09 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.3 |
||||||
|
- deps: mime-db@~1.2.0 |
||||||
|
|
||||||
|
1.1.2 / 2014-10-14 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.4.9 |
||||||
|
- Fix error when media type has invalid parameter |
||||||
|
|
||||||
|
1.1.1 / 2014-09-28 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.2 |
||||||
|
- deps: mime-db@~1.1.0 |
||||||
|
* deps: negotiator@0.4.8 |
||||||
|
- Fix all negotiations to be case-insensitive |
||||||
|
- Stable sort preferences of same quality according to client order |
||||||
|
|
||||||
|
1.1.0 / 2014-09-02 |
||||||
|
================== |
||||||
|
|
||||||
|
* update `mime-types` |
||||||
|
|
||||||
|
1.0.7 / 2014-07-04 |
||||||
|
================== |
||||||
|
|
||||||
|
* Fix wrong type returned from `type` when match after unknown extension |
||||||
|
|
||||||
|
1.0.6 / 2014-06-24 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.4.7 |
||||||
|
|
||||||
|
1.0.5 / 2014-06-20 |
||||||
|
================== |
||||||
|
|
||||||
|
* fix crash when unknown extension given |
||||||
|
|
||||||
|
1.0.4 / 2014-06-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* use `mime-types` |
||||||
|
|
||||||
|
1.0.3 / 2014-06-11 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.4.6 |
||||||
|
- Order by specificity when quality is the same |
||||||
|
|
||||||
|
1.0.2 / 2014-05-29 |
||||||
|
================== |
||||||
|
|
||||||
|
* Fix interpretation when header not in request |
||||||
|
* deps: pin negotiator@0.4.5 |
||||||
|
|
||||||
|
1.0.1 / 2014-01-18 |
||||||
|
================== |
||||||
|
|
||||||
|
* Identity encoding isn't always acceptable |
||||||
|
* deps: negotiator@~0.4.0 |
||||||
|
|
||||||
|
1.0.0 / 2013-12-27 |
||||||
|
================== |
||||||
|
|
||||||
|
* Genesis |
@ -0,0 +1,23 @@ |
|||||||
|
(The MIT License) |
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> |
||||||
|
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com> |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining |
||||||
|
a copy of this software and associated documentation files (the |
||||||
|
'Software'), to deal in the Software without restriction, including |
||||||
|
without limitation the rights to use, copy, modify, merge, publish, |
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to |
||||||
|
permit persons to whom the Software is furnished to do so, subject to |
||||||
|
the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be |
||||||
|
included in all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,140 @@ |
|||||||
|
# accepts |
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url] |
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url] |
||||||
|
[![Node.js Version][node-version-image]][node-version-url] |
||||||
|
[![Build Status][github-actions-ci-image]][github-actions-ci-url] |
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url] |
||||||
|
|
||||||
|
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator). |
||||||
|
Extracted from [koa](https://www.npmjs.com/package/koa) for general use. |
||||||
|
|
||||||
|
In addition to negotiator, it allows: |
||||||
|
|
||||||
|
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` |
||||||
|
as well as `('text/html', 'application/json')`. |
||||||
|
- Allows type shorthands such as `json`. |
||||||
|
- Returns `false` when no types match |
||||||
|
- Treats non-existent headers as `*` |
||||||
|
|
||||||
|
## Installation |
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the |
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the |
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): |
||||||
|
|
||||||
|
```sh |
||||||
|
$ npm install accepts |
||||||
|
``` |
||||||
|
|
||||||
|
## API |
||||||
|
|
||||||
|
```js |
||||||
|
var accepts = require('accepts') |
||||||
|
``` |
||||||
|
|
||||||
|
### accepts(req) |
||||||
|
|
||||||
|
Create a new `Accepts` object for the given `req`. |
||||||
|
|
||||||
|
#### .charset(charsets) |
||||||
|
|
||||||
|
Return the first accepted charset. If nothing in `charsets` is accepted, |
||||||
|
then `false` is returned. |
||||||
|
|
||||||
|
#### .charsets() |
||||||
|
|
||||||
|
Return the charsets that the request accepts, in the order of the client's |
||||||
|
preference (most preferred first). |
||||||
|
|
||||||
|
#### .encoding(encodings) |
||||||
|
|
||||||
|
Return the first accepted encoding. If nothing in `encodings` is accepted, |
||||||
|
then `false` is returned. |
||||||
|
|
||||||
|
#### .encodings() |
||||||
|
|
||||||
|
Return the encodings that the request accepts, in the order of the client's |
||||||
|
preference (most preferred first). |
||||||
|
|
||||||
|
#### .language(languages) |
||||||
|
|
||||||
|
Return the first accepted language. If nothing in `languages` is accepted, |
||||||
|
then `false` is returned. |
||||||
|
|
||||||
|
#### .languages() |
||||||
|
|
||||||
|
Return the languages that the request accepts, in the order of the client's |
||||||
|
preference (most preferred first). |
||||||
|
|
||||||
|
#### .type(types) |
||||||
|
|
||||||
|
Return the first accepted type (and it is returned as the same text as what |
||||||
|
appears in the `types` array). If nothing in `types` is accepted, then `false` |
||||||
|
is returned. |
||||||
|
|
||||||
|
The `types` array can contain full MIME types or file extensions. Any value |
||||||
|
that is not a full MIME types is passed to `require('mime-types').lookup`. |
||||||
|
|
||||||
|
#### .types() |
||||||
|
|
||||||
|
Return the types that the request accepts, in the order of the client's |
||||||
|
preference (most preferred first). |
||||||
|
|
||||||
|
## Examples |
||||||
|
|
||||||
|
### Simple type negotiation |
||||||
|
|
||||||
|
This simple example shows how to use `accepts` to return a different typed |
||||||
|
respond body based on what the client wants to accept. The server lists it's |
||||||
|
preferences in order and will get back the best match between the client and |
||||||
|
server. |
||||||
|
|
||||||
|
```js |
||||||
|
var accepts = require('accepts') |
||||||
|
var http = require('http') |
||||||
|
|
||||||
|
function app (req, res) { |
||||||
|
var accept = accepts(req) |
||||||
|
|
||||||
|
// the order of this list is significant; should be server preferred order |
||||||
|
switch (accept.type(['json', 'html'])) { |
||||||
|
case 'json': |
||||||
|
res.setHeader('Content-Type', 'application/json') |
||||||
|
res.write('{"hello":"world!"}') |
||||||
|
break |
||||||
|
case 'html': |
||||||
|
res.setHeader('Content-Type', 'text/html') |
||||||
|
res.write('<b>hello, world!</b>') |
||||||
|
break |
||||||
|
default: |
||||||
|
// the fallback is text/plain, so no need to specify it above |
||||||
|
res.setHeader('Content-Type', 'text/plain') |
||||||
|
res.write('hello, world!') |
||||||
|
break |
||||||
|
} |
||||||
|
|
||||||
|
res.end() |
||||||
|
} |
||||||
|
|
||||||
|
http.createServer(app).listen(3000) |
||||||
|
``` |
||||||
|
|
||||||
|
You can test this out with the cURL program: |
||||||
|
```sh |
||||||
|
curl -I -H'Accept: text/html' http://localhost:3000/ |
||||||
|
``` |
||||||
|
|
||||||
|
## License |
||||||
|
|
||||||
|
[MIT](LICENSE) |
||||||
|
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master |
||||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master |
||||||
|
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci |
||||||
|
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml |
||||||
|
[node-version-image]: https://badgen.net/npm/node/accepts |
||||||
|
[node-version-url]: https://nodejs.org/en/download |
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/accepts |
||||||
|
[npm-url]: https://npmjs.org/package/accepts |
||||||
|
[npm-version-image]: https://badgen.net/npm/v/accepts |
@ -0,0 +1,238 @@ |
|||||||
|
/*! |
||||||
|
* accepts |
||||||
|
* Copyright(c) 2014 Jonathan Ong |
||||||
|
* Copyright(c) 2015 Douglas Christopher Wilson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Module dependencies. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
var Negotiator = require('negotiator') |
||||||
|
var mime = require('mime-types') |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
module.exports = Accepts |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new Accepts object for the given req. |
||||||
|
* |
||||||
|
* @param {object} req |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
function Accepts (req) { |
||||||
|
if (!(this instanceof Accepts)) { |
||||||
|
return new Accepts(req) |
||||||
|
} |
||||||
|
|
||||||
|
this.headers = req.headers |
||||||
|
this.negotiator = new Negotiator(req) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Check if the given `type(s)` is acceptable, returning |
||||||
|
* the best match when true, otherwise `undefined`, in which |
||||||
|
* case you should respond with 406 "Not Acceptable". |
||||||
|
* |
||||||
|
* The `type` value may be a single mime type string |
||||||
|
* such as "application/json", the extension name |
||||||
|
* such as "json" or an array `["json", "html", "text/plain"]`. When a list |
||||||
|
* or array is given the _best_ match, if any is returned. |
||||||
|
* |
||||||
|
* Examples: |
||||||
|
* |
||||||
|
* // Accept: text/html
|
||||||
|
* this.types('html'); |
||||||
|
* // => "html"
|
||||||
|
* |
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('html'); |
||||||
|
* // => "html"
|
||||||
|
* this.types('text/html'); |
||||||
|
* // => "text/html"
|
||||||
|
* this.types('json', 'text'); |
||||||
|
* // => "json"
|
||||||
|
* this.types('application/json'); |
||||||
|
* // => "application/json"
|
||||||
|
* |
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('image/png'); |
||||||
|
* this.types('png'); |
||||||
|
* // => undefined
|
||||||
|
* |
||||||
|
* // Accept: text/*;q=.5, application/json
|
||||||
|
* this.types(['html', 'json']); |
||||||
|
* this.types('html', 'json'); |
||||||
|
* // => "json"
|
||||||
|
* |
||||||
|
* @param {String|Array} types... |
||||||
|
* @return {String|Array|Boolean} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Accepts.prototype.type = |
||||||
|
Accepts.prototype.types = function (types_) { |
||||||
|
var types = types_ |
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (types && !Array.isArray(types)) { |
||||||
|
types = new Array(arguments.length) |
||||||
|
for (var i = 0; i < types.length; i++) { |
||||||
|
types[i] = arguments[i] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// no types, return all requested types
|
||||||
|
if (!types || types.length === 0) { |
||||||
|
return this.negotiator.mediaTypes() |
||||||
|
} |
||||||
|
|
||||||
|
// no accept header, return first given type
|
||||||
|
if (!this.headers.accept) { |
||||||
|
return types[0] |
||||||
|
} |
||||||
|
|
||||||
|
var mimes = types.map(extToMime) |
||||||
|
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime)) |
||||||
|
var first = accepts[0] |
||||||
|
|
||||||
|
return first |
||||||
|
? types[mimes.indexOf(first)] |
||||||
|
: false |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Return accepted encodings or best fit based on `encodings`. |
||||||
|
* |
||||||
|
* Given `Accept-Encoding: gzip, deflate` |
||||||
|
* an array sorted by quality is returned: |
||||||
|
* |
||||||
|
* ['gzip', 'deflate'] |
||||||
|
* |
||||||
|
* @param {String|Array} encodings... |
||||||
|
* @return {String|Array} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Accepts.prototype.encoding = |
||||||
|
Accepts.prototype.encodings = function (encodings_) { |
||||||
|
var encodings = encodings_ |
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (encodings && !Array.isArray(encodings)) { |
||||||
|
encodings = new Array(arguments.length) |
||||||
|
for (var i = 0; i < encodings.length; i++) { |
||||||
|
encodings[i] = arguments[i] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// no encodings, return all requested encodings
|
||||||
|
if (!encodings || encodings.length === 0) { |
||||||
|
return this.negotiator.encodings() |
||||||
|
} |
||||||
|
|
||||||
|
return this.negotiator.encodings(encodings)[0] || false |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Return accepted charsets or best fit based on `charsets`. |
||||||
|
* |
||||||
|
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5` |
||||||
|
* an array sorted by quality is returned: |
||||||
|
* |
||||||
|
* ['utf-8', 'utf-7', 'iso-8859-1'] |
||||||
|
* |
||||||
|
* @param {String|Array} charsets... |
||||||
|
* @return {String|Array} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Accepts.prototype.charset = |
||||||
|
Accepts.prototype.charsets = function (charsets_) { |
||||||
|
var charsets = charsets_ |
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (charsets && !Array.isArray(charsets)) { |
||||||
|
charsets = new Array(arguments.length) |
||||||
|
for (var i = 0; i < charsets.length; i++) { |
||||||
|
charsets[i] = arguments[i] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// no charsets, return all requested charsets
|
||||||
|
if (!charsets || charsets.length === 0) { |
||||||
|
return this.negotiator.charsets() |
||||||
|
} |
||||||
|
|
||||||
|
return this.negotiator.charsets(charsets)[0] || false |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Return accepted languages or best fit based on `langs`. |
||||||
|
* |
||||||
|
* Given `Accept-Language: en;q=0.8, es, pt` |
||||||
|
* an array sorted by quality is returned: |
||||||
|
* |
||||||
|
* ['es', 'pt', 'en'] |
||||||
|
* |
||||||
|
* @param {String|Array} langs... |
||||||
|
* @return {Array|String} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Accepts.prototype.lang = |
||||||
|
Accepts.prototype.langs = |
||||||
|
Accepts.prototype.language = |
||||||
|
Accepts.prototype.languages = function (languages_) { |
||||||
|
var languages = languages_ |
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (languages && !Array.isArray(languages)) { |
||||||
|
languages = new Array(arguments.length) |
||||||
|
for (var i = 0; i < languages.length; i++) { |
||||||
|
languages[i] = arguments[i] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// no languages, return all requested languages
|
||||||
|
if (!languages || languages.length === 0) { |
||||||
|
return this.negotiator.languages() |
||||||
|
} |
||||||
|
|
||||||
|
return this.negotiator.languages(languages)[0] || false |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Convert extnames to mime. |
||||||
|
* |
||||||
|
* @param {String} type |
||||||
|
* @return {String} |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function extToMime (type) { |
||||||
|
return type.indexOf('/') === -1 |
||||||
|
? mime.lookup(type) |
||||||
|
: type |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Check if mime is valid. |
||||||
|
* |
||||||
|
* @param {String} type |
||||||
|
* @return {String} |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function validMime (type) { |
||||||
|
return typeof type === 'string' |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
{ |
||||||
|
"name": "accepts", |
||||||
|
"description": "Higher-level content negotiation", |
||||||
|
"version": "1.3.8", |
||||||
|
"contributors": [ |
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>", |
||||||
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)" |
||||||
|
], |
||||||
|
"license": "MIT", |
||||||
|
"repository": "jshttp/accepts", |
||||||
|
"dependencies": { |
||||||
|
"mime-types": "~2.1.34", |
||||||
|
"negotiator": "0.6.3" |
||||||
|
}, |
||||||
|
"devDependencies": { |
||||||
|
"deep-equal": "1.0.1", |
||||||
|
"eslint": "7.32.0", |
||||||
|
"eslint-config-standard": "14.1.1", |
||||||
|
"eslint-plugin-import": "2.25.4", |
||||||
|
"eslint-plugin-markdown": "2.2.1", |
||||||
|
"eslint-plugin-node": "11.1.0", |
||||||
|
"eslint-plugin-promise": "4.3.1", |
||||||
|
"eslint-plugin-standard": "4.1.0", |
||||||
|
"mocha": "9.2.0", |
||||||
|
"nyc": "15.1.0" |
||||||
|
}, |
||||||
|
"files": [ |
||||||
|
"LICENSE", |
||||||
|
"HISTORY.md", |
||||||
|
"index.js" |
||||||
|
], |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"lint": "eslint .", |
||||||
|
"test": "mocha --reporter spec --check-leaks --bail test/", |
||||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test", |
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test" |
||||||
|
}, |
||||||
|
"keywords": [ |
||||||
|
"content", |
||||||
|
"negotiation", |
||||||
|
"accept", |
||||||
|
"accepts" |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
The MIT License (MIT) |
||||||
|
|
||||||
|
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in |
||||||
|
all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||||
|
THE SOFTWARE. |
@ -0,0 +1,43 @@ |
|||||||
|
# Array Flatten |
||||||
|
|
||||||
|
[![NPM version][npm-image]][npm-url] |
||||||
|
[![NPM downloads][downloads-image]][downloads-url] |
||||||
|
[![Build status][travis-image]][travis-url] |
||||||
|
[![Test coverage][coveralls-image]][coveralls-url] |
||||||
|
|
||||||
|
> Flatten an array of nested arrays into a single flat array. Accepts an optional depth. |
||||||
|
|
||||||
|
## Installation |
||||||
|
|
||||||
|
``` |
||||||
|
npm install array-flatten --save |
||||||
|
``` |
||||||
|
|
||||||
|
## Usage |
||||||
|
|
||||||
|
```javascript |
||||||
|
var flatten = require('array-flatten') |
||||||
|
|
||||||
|
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9]) |
||||||
|
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9] |
||||||
|
|
||||||
|
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2) |
||||||
|
//=> [1, 2, 3, [4, [5], 6], 7, 8, 9] |
||||||
|
|
||||||
|
(function () { |
||||||
|
flatten(arguments) //=> [1, 2, 3] |
||||||
|
})(1, [2, 3]) |
||||||
|
``` |
||||||
|
|
||||||
|
## License |
||||||
|
|
||||||
|
MIT |
||||||
|
|
||||||
|
[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat |
||||||
|
[npm-url]: https://npmjs.org/package/array-flatten |
||||||
|
[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat |
||||||
|
[downloads-url]: https://npmjs.org/package/array-flatten |
||||||
|
[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat |
||||||
|
[travis-url]: https://travis-ci.org/blakeembrey/array-flatten |
||||||
|
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat |
||||||
|
[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master |
@ -0,0 +1,64 @@ |
|||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Expose `arrayFlatten`. |
||||||
|
*/ |
||||||
|
module.exports = arrayFlatten |
||||||
|
|
||||||
|
/** |
||||||
|
* Recursive flatten function with depth. |
||||||
|
* |
||||||
|
* @param {Array} array |
||||||
|
* @param {Array} result |
||||||
|
* @param {Number} depth |
||||||
|
* @return {Array} |
||||||
|
*/ |
||||||
|
function flattenWithDepth (array, result, depth) { |
||||||
|
for (var i = 0; i < array.length; i++) { |
||||||
|
var value = array[i] |
||||||
|
|
||||||
|
if (depth > 0 && Array.isArray(value)) { |
||||||
|
flattenWithDepth(value, result, depth - 1) |
||||||
|
} else { |
||||||
|
result.push(value) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return result |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Recursive flatten function. Omitting depth is slightly faster. |
||||||
|
* |
||||||
|
* @param {Array} array |
||||||
|
* @param {Array} result |
||||||
|
* @return {Array} |
||||||
|
*/ |
||||||
|
function flattenForever (array, result) { |
||||||
|
for (var i = 0; i < array.length; i++) { |
||||||
|
var value = array[i] |
||||||
|
|
||||||
|
if (Array.isArray(value)) { |
||||||
|
flattenForever(value, result) |
||||||
|
} else { |
||||||
|
result.push(value) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return result |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Flatten an array, with the ability to define a depth. |
||||||
|
* |
||||||
|
* @param {Array} array |
||||||
|
* @param {Number} depth |
||||||
|
* @return {Array} |
||||||
|
*/ |
||||||
|
function arrayFlatten (array, depth) { |
||||||
|
if (depth == null) { |
||||||
|
return flattenForever(array, []) |
||||||
|
} |
||||||
|
|
||||||
|
return flattenWithDepth(array, [], depth) |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
{ |
||||||
|
"name": "array-flatten", |
||||||
|
"version": "1.1.1", |
||||||
|
"description": "Flatten an array of nested arrays into a single flat array", |
||||||
|
"main": "array-flatten.js", |
||||||
|
"files": [ |
||||||
|
"array-flatten.js", |
||||||
|
"LICENSE" |
||||||
|
], |
||||||
|
"scripts": { |
||||||
|
"test": "istanbul cover _mocha -- -R spec" |
||||||
|
}, |
||||||
|
"repository": { |
||||||
|
"type": "git", |
||||||
|
"url": "git://github.com/blakeembrey/array-flatten.git" |
||||||
|
}, |
||||||
|
"keywords": [ |
||||||
|
"array", |
||||||
|
"flatten", |
||||||
|
"arguments", |
||||||
|
"depth" |
||||||
|
], |
||||||
|
"author": { |
||||||
|
"name": "Blake Embrey", |
||||||
|
"email": "hello@blakeembrey.com", |
||||||
|
"url": "http://blakeembrey.me" |
||||||
|
}, |
||||||
|
"license": "MIT", |
||||||
|
"bugs": { |
||||||
|
"url": "https://github.com/blakeembrey/array-flatten/issues" |
||||||
|
}, |
||||||
|
"homepage": "https://github.com/blakeembrey/array-flatten", |
||||||
|
"devDependencies": { |
||||||
|
"istanbul": "^0.3.13", |
||||||
|
"mocha": "^2.2.4", |
||||||
|
"pre-commit": "^1.0.7", |
||||||
|
"standard": "^3.7.3" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,266 @@ |
|||||||
|
#### 9.0.0 |
||||||
|
* 27/05/2019 |
||||||
|
* For compatibility with legacy browsers, remove `Symbol` references. |
||||||
|
|
||||||
|
#### 8.1.1 |
||||||
|
* 24/02/2019 |
||||||
|
* [BUGFIX] #222 Restore missing `var` to `export BigNumber`. |
||||||
|
* Allow any key in BigNumber.Instance in *bignumber.d.ts*. |
||||||
|
|
||||||
|
#### 8.1.0 |
||||||
|
* 23/02/2019 |
||||||
|
* [NEW FEATURE] #220 Create a BigNumber using `{s, e, c}`. |
||||||
|
* [NEW FEATURE] `isBigNumber`: if `BigNumber.DEBUG` is `true`, also check that the BigNumber instance is well-formed. |
||||||
|
* Remove `instanceof` checks; just use `_isBigNumber` to identify a BigNumber instance. |
||||||
|
* Add `_isBigNumber` to prototype in *bignumber.mjs*. |
||||||
|
* Add tests for BigNumber creation from object. |
||||||
|
* Update *API.html*. |
||||||
|
|
||||||
|
#### 8.0.2 |
||||||
|
* 13/01/2019 |
||||||
|
* #209 `toPrecision` without argument should follow `toString`. |
||||||
|
* Improve *Use* section of *README*. |
||||||
|
* Optimise `toString(10)`. |
||||||
|
* Add verson number to API doc. |
||||||
|
|
||||||
|
#### 8.0.1 |
||||||
|
* 01/11/2018 |
||||||
|
* Rest parameter must be array type in *bignumber.d.ts*. |
||||||
|
|
||||||
|
#### 8.0.0 |
||||||
|
* 01/11/2018 |
||||||
|
* [NEW FEATURE] Add `BigNumber.sum` method. |
||||||
|
* [NEW FEATURE]`toFormat`: add `prefix` and `suffix` options. |
||||||
|
* [NEW FEATURE] #178 Pass custom formatting to `toFormat`. |
||||||
|
* [BREAKING CHANGE] #184 `toFraction`: return array of BigNumbers not strings. |
||||||
|
* [NEW FEATURE] #185 Enable overwrite of `valueOf` to prevent accidental addition to string. |
||||||
|
* #183 Add Node.js `crypto` requirement to documentation. |
||||||
|
* [BREAKING CHANGE] #198 Disallow signs and whitespace in custom alphabet. |
||||||
|
* [NEW FEATURE] #188 Implement `util.inspect.custom` for Node.js REPL. |
||||||
|
* #170 Make `isBigNumber` a type guard in *bignumber.d.ts*. |
||||||
|
* [BREAKING CHANGE] `BigNumber.min` and `BigNumber.max`: don't accept an array. |
||||||
|
* Update *.travis.yml*. |
||||||
|
* Remove *bower.json*. |
||||||
|
|
||||||
|
#### 7.2.1 |
||||||
|
* 24/05/2018 |
||||||
|
* Add `browser` field to *package.json*. |
||||||
|
|
||||||
|
#### 7.2.0 |
||||||
|
* 22/05/2018 |
||||||
|
* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*. |
||||||
|
|
||||||
|
#### 7.1.0 |
||||||
|
* 18/05/2018 |
||||||
|
* Add `module` field to *package.json* for *bignumber.mjs*. |
||||||
|
|
||||||
|
#### 7.0.2 |
||||||
|
* 17/05/2018 |
||||||
|
* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet. |
||||||
|
* Add note to *README* regarding creating BigNumbers from Number values. |
||||||
|
|
||||||
|
#### 7.0.1 |
||||||
|
* 26/04/2018 |
||||||
|
* #158 Fix global object variable name typo. |
||||||
|
|
||||||
|
#### 7.0.0 |
||||||
|
* 26/04/2018 |
||||||
|
* #143 Remove global BigNumber from typings. |
||||||
|
* #144 Enable compatibility with `Object.freeze(Object.prototype)`. |
||||||
|
* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`. |
||||||
|
* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead. |
||||||
|
* #154 `exponentiatedBy`: allow BigNumber exponent. |
||||||
|
* #156 Prevent Content Security Policy *unsafe-eval* issue. |
||||||
|
* `toFraction`: allow `Infinity` maximum denominator. |
||||||
|
* Comment-out some excess tests to reduce test time. |
||||||
|
* Amend indentation and other spacing. |
||||||
|
|
||||||
|
#### 6.0.0 |
||||||
|
* 26/01/2018 |
||||||
|
* #137 Implement `APLHABET` configuration option. |
||||||
|
* Remove `ERRORS` configuration option. |
||||||
|
* Remove `toDigits` method; extend `precision` method accordingly. |
||||||
|
* Remove s`round` method; extend `decimalPlaces` method accordingly. |
||||||
|
* Remove methods: `ceil`, `floor`, and `truncated`. |
||||||
|
* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`. |
||||||
|
* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`. |
||||||
|
* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`. |
||||||
|
* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`. |
||||||
|
* Refactor test suite. |
||||||
|
* Add *CHANGELOG.md*. |
||||||
|
* Rewrite *bignumber.d.ts*. |
||||||
|
* Redo API image. |
||||||
|
|
||||||
|
#### 5.0.0 |
||||||
|
* 27/11/2017 |
||||||
|
* #81 Don't throw on constructor call without `new`. |
||||||
|
|
||||||
|
#### 4.1.0 |
||||||
|
* 26/09/2017 |
||||||
|
* Remove node 0.6 from *.travis.yml*. |
||||||
|
* Add *bignumber.mjs*. |
||||||
|
|
||||||
|
#### 4.0.4 |
||||||
|
* 03/09/2017 |
||||||
|
* Add missing aliases to *bignumber.d.ts*. |
||||||
|
|
||||||
|
#### 4.0.3 |
||||||
|
* 30/08/2017 |
||||||
|
* Add types: *bignumber.d.ts*. |
||||||
|
|
||||||
|
#### 4.0.2 |
||||||
|
* 03/05/2017 |
||||||
|
* #120 Workaround Safari/Webkit bug. |
||||||
|
|
||||||
|
#### 4.0.1 |
||||||
|
* 05/04/2017 |
||||||
|
* #121 BigNumber.default to BigNumber['default']. |
||||||
|
|
||||||
|
#### 4.0.0 |
||||||
|
* 09/01/2017 |
||||||
|
* Replace BigNumber.isBigNumber method with isBigNumber prototype property. |
||||||
|
|
||||||
|
#### 3.1.2 |
||||||
|
* 08/01/2017 |
||||||
|
* Minor documentation edit. |
||||||
|
|
||||||
|
#### 3.1.1 |
||||||
|
* 08/01/2017 |
||||||
|
* Uncomment `isBigNumber` tests. |
||||||
|
* Ignore dot files. |
||||||
|
|
||||||
|
#### 3.1.0 |
||||||
|
* 08/01/2017 |
||||||
|
* Add `isBigNumber` method. |
||||||
|
|
||||||
|
#### 3.0.2 |
||||||
|
* 08/01/2017 |
||||||
|
* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope). |
||||||
|
|
||||||
|
#### 3.0.1 |
||||||
|
* 23/11/2016 |
||||||
|
* Apply fix for old ipads with `%` issue, see #57 and #102. |
||||||
|
* Correct error message. |
||||||
|
|
||||||
|
#### 3.0.0 |
||||||
|
* 09/11/2016 |
||||||
|
* Remove `require('crypto')` - leave it to the user. |
||||||
|
* Add `BigNumber.set` as `BigNumber.config` alias. |
||||||
|
* Default `POW_PRECISION` to `0`. |
||||||
|
|
||||||
|
#### 2.4.0 |
||||||
|
* 14/07/2016 |
||||||
|
* #97 Add exports to support ES6 imports. |
||||||
|
|
||||||
|
#### 2.3.0 |
||||||
|
* 07/03/2016 |
||||||
|
* #86 Add modulus parameter to `toPower`. |
||||||
|
|
||||||
|
#### 2.2.0 |
||||||
|
* 03/03/2016 |
||||||
|
* #91 Permit larger JS integers. |
||||||
|
|
||||||
|
#### 2.1.4 |
||||||
|
* 15/12/2015 |
||||||
|
* Correct UMD. |
||||||
|
|
||||||
|
#### 2.1.3 |
||||||
|
* 13/12/2015 |
||||||
|
* Refactor re global object and crypto availability when bundling. |
||||||
|
|
||||||
|
#### 2.1.2 |
||||||
|
* 10/12/2015 |
||||||
|
* Bugfix: `window.crypto` not assigned to `crypto`. |
||||||
|
|
||||||
|
#### 2.1.1 |
||||||
|
* 09/12/2015 |
||||||
|
* Prevent code bundler from adding `crypto` shim. |
||||||
|
|
||||||
|
#### 2.1.0 |
||||||
|
* 26/10/2015 |
||||||
|
* For `valueOf` and `toJSON`, include the minus sign with negative zero. |
||||||
|
|
||||||
|
#### 2.0.8 |
||||||
|
* 2/10/2015 |
||||||
|
* Internal round function bugfix. |
||||||
|
|
||||||
|
#### 2.0.6 |
||||||
|
* 31/03/2015 |
||||||
|
* Add bower.json. Tweak division after in-depth review. |
||||||
|
|
||||||
|
#### 2.0.5 |
||||||
|
* 25/03/2015 |
||||||
|
* Amend README. Remove bitcoin address. |
||||||
|
|
||||||
|
#### 2.0.4 |
||||||
|
* 25/03/2015 |
||||||
|
* Critical bugfix #58: division. |
||||||
|
|
||||||
|
#### 2.0.3 |
||||||
|
* 18/02/2015 |
||||||
|
* Amend README. Add source map. |
||||||
|
|
||||||
|
#### 2.0.2 |
||||||
|
* 18/02/2015 |
||||||
|
* Correct links. |
||||||
|
|
||||||
|
#### 2.0.1 |
||||||
|
* 18/02/2015 |
||||||
|
* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods. |
||||||
|
* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`. |
||||||
|
* Add an `another` method to enable multiple independent constructors to be created. |
||||||
|
* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`. |
||||||
|
* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`. |
||||||
|
* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified. |
||||||
|
* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified. |
||||||
|
* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited. |
||||||
|
* Improve code quality. |
||||||
|
* Improve documentation. |
||||||
|
|
||||||
|
#### 2.0.0 |
||||||
|
* 29/12/2014 |
||||||
|
* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods. |
||||||
|
* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`. |
||||||
|
* Store a BigNumber's coefficient in base 1e14, rather than base 10. |
||||||
|
* Add fast path for integers to BigNumber constructor. |
||||||
|
* Incorporate the library into the online documentation. |
||||||
|
|
||||||
|
#### 1.5.0 |
||||||
|
* 13/11/2014 |
||||||
|
* Add `toJSON` and `decimalPlaces` methods. |
||||||
|
|
||||||
|
#### 1.4.1 |
||||||
|
* 08/06/2014 |
||||||
|
* Amend README. |
||||||
|
|
||||||
|
#### 1.4.0 |
||||||
|
* 08/05/2014 |
||||||
|
* Add `toNumber`. |
||||||
|
|
||||||
|
#### 1.3.0 |
||||||
|
* 08/11/2013 |
||||||
|
* Ensure correct rounding of `sqrt` in all, rather than almost all, cases. |
||||||
|
* Maximum radix to 64. |
||||||
|
|
||||||
|
#### 1.2.1 |
||||||
|
* 17/10/2013 |
||||||
|
* Sign of zero when x < 0 and x + (-x) = 0. |
||||||
|
|
||||||
|
#### 1.2.0 |
||||||
|
* 19/9/2013 |
||||||
|
* Throw Error objects for stack. |
||||||
|
|
||||||
|
#### 1.1.1 |
||||||
|
* 22/8/2013 |
||||||
|
* Show original value in constructor error message. |
||||||
|
|
||||||
|
#### 1.1.0 |
||||||
|
* 1/8/2013 |
||||||
|
* Allow numbers with trailing radix point. |
||||||
|
|
||||||
|
#### 1.0.1 |
||||||
|
* Bugfix: error messages with incorrect method name |
||||||
|
|
||||||
|
#### 1.0.0 |
||||||
|
* 8/11/2012 |
||||||
|
* Initial release |
@ -0,0 +1,23 @@ |
|||||||
|
The MIT Licence. |
||||||
|
|
||||||
|
Copyright (c) 2019 Michael Mclaughlin |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining |
||||||
|
a copy of this software and associated documentation files (the |
||||||
|
'Software'), to deal in the Software without restriction, including |
||||||
|
without limitation the rights to use, copy, modify, merge, publish, |
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to |
||||||
|
permit persons to whom the Software is furnished to do so, subject to |
||||||
|
the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be |
||||||
|
included in all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||||
|
|
@ -0,0 +1,268 @@ |
|||||||
|
 |
||||||
|
|
||||||
|
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic. |
||||||
|
|
||||||
|
[](https://travis-ci.org/MikeMcl/bignumber.js) |
||||||
|
|
||||||
|
<br /> |
||||||
|
|
||||||
|
## Features |
||||||
|
|
||||||
|
- Integers and decimals |
||||||
|
- Simple API but full-featured |
||||||
|
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal |
||||||
|
- 8 KB minified and gzipped |
||||||
|
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type |
||||||
|
- Includes a `toFraction` and a correctly-rounded `squareRoot` method |
||||||
|
- Supports cryptographically-secure pseudo-random number generation |
||||||
|
- No dependencies |
||||||
|
- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only |
||||||
|
- Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set |
||||||
|
|
||||||
|
 |
||||||
|
|
||||||
|
If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/). |
||||||
|
It's less than half the size but only works with decimal numbers and only has half the methods. |
||||||
|
It also does not allow `NaN` or `Infinity`, or have the configuration options of this library. |
||||||
|
|
||||||
|
See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits. |
||||||
|
|
||||||
|
## Load |
||||||
|
|
||||||
|
The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*). |
||||||
|
|
||||||
|
Browser: |
||||||
|
|
||||||
|
```html |
||||||
|
<script src='path/to/bignumber.js'></script> |
||||||
|
``` |
||||||
|
|
||||||
|
[Node.js](http://nodejs.org): |
||||||
|
|
||||||
|
```bash |
||||||
|
$ npm install bignumber.js |
||||||
|
``` |
||||||
|
|
||||||
|
```javascript |
||||||
|
const BigNumber = require('bignumber.js'); |
||||||
|
``` |
||||||
|
|
||||||
|
ES6 module: |
||||||
|
|
||||||
|
```javascript |
||||||
|
import BigNumber from "./bignumber.mjs" |
||||||
|
``` |
||||||
|
|
||||||
|
AMD loader libraries such as [requireJS](http://requirejs.org/): |
||||||
|
|
||||||
|
```javascript |
||||||
|
require(['bignumber'], function(BigNumber) { |
||||||
|
// Use BigNumber here in local scope. No global BigNumber. |
||||||
|
}); |
||||||
|
``` |
||||||
|
|
||||||
|
## Use |
||||||
|
|
||||||
|
The library exports a single constructor function, [`BigNumber`](http://mikemcl.github.io/bignumber.js/#bignumber), which accepts a value of type Number, String or BigNumber, |
||||||
|
|
||||||
|
```javascript |
||||||
|
let x = new BigNumber(123.4567); |
||||||
|
let y = BigNumber('123456.7e-3'); |
||||||
|
let z = new BigNumber(x); |
||||||
|
x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z); // true |
||||||
|
``` |
||||||
|
|
||||||
|
To get the string value of a BigNumber use [`toString()`](http://mikemcl.github.io/bignumber.js/#toS) or [`toFixed()`](http://mikemcl.github.io/bignumber.js/#toFix). Using `toFixed()` prevents exponential notation being returned, no matter how large or small the value. |
||||||
|
|
||||||
|
```javascript |
||||||
|
let x = new BigNumber('1111222233334444555566'); |
||||||
|
x.toString(); // "1.111222233334444555566e+21" |
||||||
|
x.toFixed(); // "1111222233334444555566" |
||||||
|
``` |
||||||
|
|
||||||
|
If the limited precision of Number values is not well understood, it is recommended to create BigNumbers from String values rather than Number values to avoid a potential loss of precision. |
||||||
|
|
||||||
|
*In all further examples below, `let`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.* |
||||||
|
|
||||||
|
```javascript |
||||||
|
// Precision loss from using numeric literals with more than 15 significant digits. |
||||||
|
new BigNumber(1.0000000000000001) // '1' |
||||||
|
new BigNumber(88259496234518.57) // '88259496234518.56' |
||||||
|
new BigNumber(99999999999999999999) // '100000000000000000000' |
||||||
|
|
||||||
|
// Precision loss from using numeric literals outside the range of Number values. |
||||||
|
new BigNumber(2e+308) // 'Infinity' |
||||||
|
new BigNumber(1e-324) // '0' |
||||||
|
|
||||||
|
// Precision loss from the unexpected result of arithmetic with Number values. |
||||||
|
new BigNumber(0.7 + 0.1) // '0.7999999999999999' |
||||||
|
``` |
||||||
|
|
||||||
|
When creating a BigNumber from a Number, note that a BigNumber is created from a Number's decimal `toString()` value not from its underlying binary value. If the latter is required, then pass the Number's `toString(2)` value and specify base 2. |
||||||
|
|
||||||
|
```javascript |
||||||
|
new BigNumber(Number.MAX_VALUE.toString(2), 2) |
||||||
|
``` |
||||||
|
|
||||||
|
BigNumbers can be created from values in bases from 2 to 36. See [`ALPHABET`](http://mikemcl.github.io/bignumber.js/#alphabet) to extend this range. |
||||||
|
|
||||||
|
```javascript |
||||||
|
a = new BigNumber(1011, 2) // "11" |
||||||
|
b = new BigNumber('zz.9', 36) // "1295.25" |
||||||
|
c = a.plus(b) // "1306.25" |
||||||
|
``` |
||||||
|
|
||||||
|
Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when it is desired that the number of decimal places of the input value be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting. |
||||||
|
|
||||||
|
A BigNumber is immutable in the sense that it is not changed by its methods. |
||||||
|
|
||||||
|
```javascript |
||||||
|
0.3 - 0.1 // 0.19999999999999998 |
||||||
|
x = new BigNumber(0.3) |
||||||
|
x.minus(0.1) // "0.2" |
||||||
|
x // "0.3" |
||||||
|
``` |
||||||
|
|
||||||
|
The methods that return a BigNumber can be chained. |
||||||
|
|
||||||
|
```javascript |
||||||
|
x.dividedBy(y).plus(z).times(9) |
||||||
|
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').integerValue() |
||||||
|
``` |
||||||
|
|
||||||
|
Some of the longer method names have a shorter alias. |
||||||
|
|
||||||
|
```javascript |
||||||
|
x.squareRoot().dividedBy(y).exponentiatedBy(3).isEqualTo(x.sqrt().div(y).pow(3)) // true |
||||||
|
x.modulo(y).multipliedBy(z).eq(x.mod(y).times(z)) // true |
||||||
|
``` |
||||||
|
|
||||||
|
As with JavaScript's Number type, there are [`toExponential`](http://mikemcl.github.io/bignumber.js/#toE), [`toFixed`](http://mikemcl.github.io/bignumber.js/#toFix) and [`toPrecision`](http://mikemcl.github.io/bignumber.js/#toP) methods. |
||||||
|
|
||||||
|
```javascript |
||||||
|
x = new BigNumber(255.5) |
||||||
|
x.toExponential(5) // "2.55500e+2" |
||||||
|
x.toFixed(5) // "255.50000" |
||||||
|
x.toPrecision(5) // "255.50" |
||||||
|
x.toNumber() // 255.5 |
||||||
|
``` |
||||||
|
|
||||||
|
A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when it is desired that the number of decimal places be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting. |
||||||
|
|
||||||
|
```javascript |
||||||
|
x.toString(16) // "ff.8" |
||||||
|
``` |
||||||
|
|
||||||
|
There is a [`toFormat`](http://mikemcl.github.io/bignumber.js/#toFor) method which may be useful for internationalisation. |
||||||
|
|
||||||
|
```javascript |
||||||
|
y = new BigNumber('1234567.898765') |
||||||
|
y.toFormat(2) // "1,234,567.90" |
||||||
|
``` |
||||||
|
|
||||||
|
The maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `set` or `config` method of the `BigNumber` constructor. |
||||||
|
|
||||||
|
The other arithmetic operations always give the exact result. |
||||||
|
|
||||||
|
```javascript |
||||||
|
BigNumber.set({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 }) |
||||||
|
|
||||||
|
x = new BigNumber(2) |
||||||
|
y = new BigNumber(3) |
||||||
|
z = x.dividedBy(y) // "0.6666666667" |
||||||
|
z.squareRoot() // "0.8164965809" |
||||||
|
z.exponentiatedBy(-3) // "3.3749999995" |
||||||
|
z.toString(2) // "0.1010101011" |
||||||
|
z.multipliedBy(z) // "0.44444444448888888889" |
||||||
|
z.multipliedBy(z).decimalPlaces(10) // "0.4444444445" |
||||||
|
``` |
||||||
|
|
||||||
|
There is a [`toFraction`](http://mikemcl.github.io/bignumber.js/#toFr) method with an optional *maximum denominator* argument |
||||||
|
|
||||||
|
```javascript |
||||||
|
y = new BigNumber(355) |
||||||
|
pi = y.dividedBy(113) // "3.1415929204" |
||||||
|
pi.toFraction() // [ "7853982301", "2500000000" ] |
||||||
|
pi.toFraction(1000) // [ "355", "113" ] |
||||||
|
``` |
||||||
|
|
||||||
|
and [`isNaN`](http://mikemcl.github.io/bignumber.js/#isNaN) and [`isFinite`](http://mikemcl.github.io/bignumber.js/#isF) methods, as `NaN` and `Infinity` are valid `BigNumber` values. |
||||||
|
|
||||||
|
```javascript |
||||||
|
x = new BigNumber(NaN) // "NaN" |
||||||
|
y = new BigNumber(Infinity) // "Infinity" |
||||||
|
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true |
||||||
|
``` |
||||||
|
|
||||||
|
The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign. |
||||||
|
|
||||||
|
```javascript |
||||||
|
x = new BigNumber(-123.456); |
||||||
|
x.c // [ 123, 45600000000000 ] coefficient (i.e. significand) |
||||||
|
x.e // 2 exponent |
||||||
|
x.s // -1 sign |
||||||
|
``` |
||||||
|
|
||||||
|
For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration. |
||||||
|
|
||||||
|
```javascript |
||||||
|
// Set DECIMAL_PLACES for the original BigNumber constructor |
||||||
|
BigNumber.set({ DECIMAL_PLACES: 10 }) |
||||||
|
|
||||||
|
// Create another BigNumber constructor, optionally passing in a configuration object |
||||||
|
BN = BigNumber.clone({ DECIMAL_PLACES: 5 }) |
||||||
|
|
||||||
|
x = new BigNumber(1) |
||||||
|
y = new BN(1) |
||||||
|
|
||||||
|
x.div(3) // '0.3333333333' |
||||||
|
y.div(3) // '0.33333' |
||||||
|
``` |
||||||
|
|
||||||
|
For further information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory. |
||||||
|
|
||||||
|
## Test |
||||||
|
|
||||||
|
The *test/modules* directory contains the test scripts for each method. |
||||||
|
|
||||||
|
The tests can be run with Node.js or a browser. For Node.js use |
||||||
|
|
||||||
|
$ npm test |
||||||
|
|
||||||
|
or |
||||||
|
|
||||||
|
$ node test/test |
||||||
|
|
||||||
|
To test a single method, use, for example |
||||||
|
|
||||||
|
$ node test/methods/toFraction |
||||||
|
|
||||||
|
For the browser, open *test/test.html*. |
||||||
|
|
||||||
|
## Build |
||||||
|
|
||||||
|
For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed |
||||||
|
|
||||||
|
npm install uglify-js -g |
||||||
|
|
||||||
|
then |
||||||
|
|
||||||
|
npm run build |
||||||
|
|
||||||
|
will create *bignumber.min.js*. |
||||||
|
|
||||||
|
A source map will also be created in the root directory. |
||||||
|
|
||||||
|
## Feedback |
||||||
|
|
||||||
|
Open an issue, or email |
||||||
|
|
||||||
|
Michael |
||||||
|
|
||||||
|
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a> |
||||||
|
|
||||||
|
## Licence |
||||||
|
|
||||||
|
The MIT Licence. |
||||||
|
|
||||||
|
See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE). |
@ -0,0 +1,40 @@ |
|||||||
|
{ |
||||||
|
"name": "bignumber.js", |
||||||
|
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic", |
||||||
|
"version": "9.0.0", |
||||||
|
"keywords": [ |
||||||
|
"arbitrary", |
||||||
|
"precision", |
||||||
|
"arithmetic", |
||||||
|
"big", |
||||||
|
"number", |
||||||
|
"decimal", |
||||||
|
"float", |
||||||
|
"biginteger", |
||||||
|
"bigdecimal", |
||||||
|
"bignumber", |
||||||
|
"bigint", |
||||||
|
"bignum" |
||||||
|
], |
||||||
|
"repository": { |
||||||
|
"type": "git", |
||||||
|
"url": "https://github.com/MikeMcl/bignumber.js.git" |
||||||
|
}, |
||||||
|
"main": "bignumber", |
||||||
|
"module": "bignumber.mjs", |
||||||
|
"browser": "bignumber.js", |
||||||
|
"types": "bignumber.d.ts", |
||||||
|
"author": { |
||||||
|
"name": "Michael Mclaughlin", |
||||||
|
"email": "M8ch88l@gmail.com" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": "*" |
||||||
|
}, |
||||||
|
"license": "MIT", |
||||||
|
"scripts": { |
||||||
|
"test": "node test/test", |
||||||
|
"build": "uglifyjs bignumber.js --source-map -c -m -o bignumber.min.js" |
||||||
|
}, |
||||||
|
"dependencies": {} |
||||||
|
} |
@ -0,0 +1,672 @@ |
|||||||
|
1.20.3 / 2024-09-10 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: qs@6.13.0 |
||||||
|
* add `depth` option to customize the depth level in the parser |
||||||
|
* IMPORTANT: The default `depth` level for parsing URL-encoded data is now `32` (previously was `Infinity`) |
||||||
|
|
||||||
|
1.20.2 / 2023-02-21 |
||||||
|
=================== |
||||||
|
|
||||||
|
* Fix strict json error message on Node.js 19+ |
||||||
|
* deps: content-type@~1.0.5 |
||||||
|
- perf: skip value escaping when unnecessary |
||||||
|
* deps: raw-body@2.5.2 |
||||||
|
|
||||||
|
1.20.1 / 2022-10-06 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: qs@6.11.0 |
||||||
|
* perf: remove unnecessary object clone |
||||||
|
|
||||||
|
1.20.0 / 2022-04-02 |
||||||
|
=================== |
||||||
|
|
||||||
|
* Fix error message for json parse whitespace in `strict` |
||||||
|
* Fix internal error when inflated body exceeds limit |
||||||
|
* Prevent loss of async hooks context |
||||||
|
* Prevent hanging when request already read |
||||||
|
* deps: depd@2.0.0 |
||||||
|
- Replace internal `eval` usage with `Function` constructor |
||||||
|
- Use instance methods on `process` to check for listeners |
||||||
|
* deps: http-errors@2.0.0 |
||||||
|
- deps: depd@2.0.0 |
||||||
|
- deps: statuses@2.0.1 |
||||||
|
* deps: on-finished@2.4.1 |
||||||
|
* deps: qs@6.10.3 |
||||||
|
* deps: raw-body@2.5.1 |
||||||
|
- deps: http-errors@2.0.0 |
||||||
|
|
||||||
|
1.19.2 / 2022-02-15 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: bytes@3.1.2 |
||||||
|
* deps: qs@6.9.7 |
||||||
|
* Fix handling of `__proto__` keys |
||||||
|
* deps: raw-body@2.4.3 |
||||||
|
- deps: bytes@3.1.2 |
||||||
|
|
||||||
|
1.19.1 / 2021-12-10 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: bytes@3.1.1 |
||||||
|
* deps: http-errors@1.8.1 |
||||||
|
- deps: inherits@2.0.4 |
||||||
|
- deps: toidentifier@1.0.1 |
||||||
|
- deps: setprototypeof@1.2.0 |
||||||
|
* deps: qs@6.9.6 |
||||||
|
* deps: raw-body@2.4.2 |
||||||
|
- deps: bytes@3.1.1 |
||||||
|
- deps: http-errors@1.8.1 |
||||||
|
* deps: safe-buffer@5.2.1 |
||||||
|
* deps: type-is@~1.6.18 |
||||||
|
|
||||||
|
1.19.0 / 2019-04-25 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: bytes@3.1.0 |
||||||
|
- Add petabyte (`pb`) support |
||||||
|
* deps: http-errors@1.7.2 |
||||||
|
- Set constructor name when possible |
||||||
|
- deps: setprototypeof@1.1.1 |
||||||
|
- deps: statuses@'>= 1.5.0 < 2' |
||||||
|
* deps: iconv-lite@0.4.24 |
||||||
|
- Added encoding MIK |
||||||
|
* deps: qs@6.7.0 |
||||||
|
- Fix parsing array brackets after index |
||||||
|
* deps: raw-body@2.4.0 |
||||||
|
- deps: bytes@3.1.0 |
||||||
|
- deps: http-errors@1.7.2 |
||||||
|
- deps: iconv-lite@0.4.24 |
||||||
|
* deps: type-is@~1.6.17 |
||||||
|
- deps: mime-types@~2.1.24 |
||||||
|
- perf: prevent internal `throw` on invalid type |
||||||
|
|
||||||
|
1.18.3 / 2018-05-14 |
||||||
|
=================== |
||||||
|
|
||||||
|
* Fix stack trace for strict json parse error |
||||||
|
* deps: depd@~1.1.2 |
||||||
|
- perf: remove argument reassignment |
||||||
|
* deps: http-errors@~1.6.3 |
||||||
|
- deps: depd@~1.1.2 |
||||||
|
- deps: setprototypeof@1.1.0 |
||||||
|
- deps: statuses@'>= 1.3.1 < 2' |
||||||
|
* deps: iconv-lite@0.4.23 |
||||||
|
- Fix loading encoding with year appended |
||||||
|
- Fix deprecation warnings on Node.js 10+ |
||||||
|
* deps: qs@6.5.2 |
||||||
|
* deps: raw-body@2.3.3 |
||||||
|
- deps: http-errors@1.6.3 |
||||||
|
- deps: iconv-lite@0.4.23 |
||||||
|
* deps: type-is@~1.6.16 |
||||||
|
- deps: mime-types@~2.1.18 |
||||||
|
|
||||||
|
1.18.2 / 2017-09-22 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: debug@2.6.9 |
||||||
|
* perf: remove argument reassignment |
||||||
|
|
||||||
|
1.18.1 / 2017-09-12 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: content-type@~1.0.4 |
||||||
|
- perf: remove argument reassignment |
||||||
|
- perf: skip parameter parsing when no parameters |
||||||
|
* deps: iconv-lite@0.4.19 |
||||||
|
- Fix ISO-8859-1 regression |
||||||
|
- Update Windows-1255 |
||||||
|
* deps: qs@6.5.1 |
||||||
|
- Fix parsing & compacting very deep objects |
||||||
|
* deps: raw-body@2.3.2 |
||||||
|
- deps: iconv-lite@0.4.19 |
||||||
|
|
||||||
|
1.18.0 / 2017-09-08 |
||||||
|
=================== |
||||||
|
|
||||||
|
* Fix JSON strict violation error to match native parse error |
||||||
|
* Include the `body` property on verify errors |
||||||
|
* Include the `type` property on all generated errors |
||||||
|
* Use `http-errors` to set status code on errors |
||||||
|
* deps: bytes@3.0.0 |
||||||
|
* deps: debug@2.6.8 |
||||||
|
* deps: depd@~1.1.1 |
||||||
|
- Remove unnecessary `Buffer` loading |
||||||
|
* deps: http-errors@~1.6.2 |
||||||
|
- deps: depd@1.1.1 |
||||||
|
* deps: iconv-lite@0.4.18 |
||||||
|
- Add support for React Native |
||||||
|
- Add a warning if not loaded as utf-8 |
||||||
|
- Fix CESU-8 decoding in Node.js 8 |
||||||
|
- Improve speed of ISO-8859-1 encoding |
||||||
|
* deps: qs@6.5.0 |
||||||
|
* deps: raw-body@2.3.1 |
||||||
|
- Use `http-errors` for standard emitted errors |
||||||
|
- deps: bytes@3.0.0 |
||||||
|
- deps: iconv-lite@0.4.18 |
||||||
|
- perf: skip buffer decoding on overage chunk |
||||||
|
* perf: prevent internal `throw` when missing charset |
||||||
|
|
||||||
|
1.17.2 / 2017-05-17 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: debug@2.6.7 |
||||||
|
- Fix `DEBUG_MAX_ARRAY_LENGTH` |
||||||
|
- deps: ms@2.0.0 |
||||||
|
* deps: type-is@~1.6.15 |
||||||
|
- deps: mime-types@~2.1.15 |
||||||
|
|
||||||
|
1.17.1 / 2017-03-06 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: qs@6.4.0 |
||||||
|
- Fix regression parsing keys starting with `[` |
||||||
|
|
||||||
|
1.17.0 / 2017-03-01 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: http-errors@~1.6.1 |
||||||
|
- Make `message` property enumerable for `HttpError`s |
||||||
|
- deps: setprototypeof@1.0.3 |
||||||
|
* deps: qs@6.3.1 |
||||||
|
- Fix compacting nested arrays |
||||||
|
|
||||||
|
1.16.1 / 2017-02-10 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: debug@2.6.1 |
||||||
|
- Fix deprecation messages in WebStorm and other editors |
||||||
|
- Undeprecate `DEBUG_FD` set to `1` or `2` |
||||||
|
|
||||||
|
1.16.0 / 2017-01-17 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: debug@2.6.0 |
||||||
|
- Allow colors in workers |
||||||
|
- Deprecated `DEBUG_FD` environment variable |
||||||
|
- Fix error when running under React Native |
||||||
|
- Use same color for same namespace |
||||||
|
- deps: ms@0.7.2 |
||||||
|
* deps: http-errors@~1.5.1 |
||||||
|
- deps: inherits@2.0.3 |
||||||
|
- deps: setprototypeof@1.0.2 |
||||||
|
- deps: statuses@'>= 1.3.1 < 2' |
||||||
|
* deps: iconv-lite@0.4.15 |
||||||
|
- Added encoding MS-31J |
||||||
|
- Added encoding MS-932 |
||||||
|
- Added encoding MS-936 |
||||||
|
- Added encoding MS-949 |
||||||
|
- Added encoding MS-950 |
||||||
|
- Fix GBK/GB18030 handling of Euro character |
||||||
|
* deps: qs@6.2.1 |
||||||
|
- Fix array parsing from skipping empty values |
||||||
|
* deps: raw-body@~2.2.0 |
||||||
|
- deps: iconv-lite@0.4.15 |
||||||
|
* deps: type-is@~1.6.14 |
||||||
|
- deps: mime-types@~2.1.13 |
||||||
|
|
||||||
|
1.15.2 / 2016-06-19 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: bytes@2.4.0 |
||||||
|
* deps: content-type@~1.0.2 |
||||||
|
- perf: enable strict mode |
||||||
|
* deps: http-errors@~1.5.0 |
||||||
|
- Use `setprototypeof` module to replace `__proto__` setting |
||||||
|
- deps: statuses@'>= 1.3.0 < 2' |
||||||
|
- perf: enable strict mode |
||||||
|
* deps: qs@6.2.0 |
||||||
|
* deps: raw-body@~2.1.7 |
||||||
|
- deps: bytes@2.4.0 |
||||||
|
- perf: remove double-cleanup on happy path |
||||||
|
* deps: type-is@~1.6.13 |
||||||
|
- deps: mime-types@~2.1.11 |
||||||
|
|
||||||
|
1.15.1 / 2016-05-05 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: bytes@2.3.0 |
||||||
|
- Drop partial bytes on all parsed units |
||||||
|
- Fix parsing byte string that looks like hex |
||||||
|
* deps: raw-body@~2.1.6 |
||||||
|
- deps: bytes@2.3.0 |
||||||
|
* deps: type-is@~1.6.12 |
||||||
|
- deps: mime-types@~2.1.10 |
||||||
|
|
||||||
|
1.15.0 / 2016-02-10 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: http-errors@~1.4.0 |
||||||
|
- Add `HttpError` export, for `err instanceof createError.HttpError` |
||||||
|
- deps: inherits@2.0.1 |
||||||
|
- deps: statuses@'>= 1.2.1 < 2' |
||||||
|
* deps: qs@6.1.0 |
||||||
|
* deps: type-is@~1.6.11 |
||||||
|
- deps: mime-types@~2.1.9 |
||||||
|
|
||||||
|
1.14.2 / 2015-12-16 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: bytes@2.2.0 |
||||||
|
* deps: iconv-lite@0.4.13 |
||||||
|
* deps: qs@5.2.0 |
||||||
|
* deps: raw-body@~2.1.5 |
||||||
|
- deps: bytes@2.2.0 |
||||||
|
- deps: iconv-lite@0.4.13 |
||||||
|
* deps: type-is@~1.6.10 |
||||||
|
- deps: mime-types@~2.1.8 |
||||||
|
|
||||||
|
1.14.1 / 2015-09-27 |
||||||
|
=================== |
||||||
|
|
||||||
|
* Fix issue where invalid charset results in 400 when `verify` used |
||||||
|
* deps: iconv-lite@0.4.12 |
||||||
|
- Fix CESU-8 decoding in Node.js 4.x |
||||||
|
* deps: raw-body@~2.1.4 |
||||||
|
- Fix masking critical errors from `iconv-lite` |
||||||
|
- deps: iconv-lite@0.4.12 |
||||||
|
* deps: type-is@~1.6.9 |
||||||
|
- deps: mime-types@~2.1.7 |
||||||
|
|
||||||
|
1.14.0 / 2015-09-16 |
||||||
|
=================== |
||||||
|
|
||||||
|
* Fix JSON strict parse error to match syntax errors |
||||||
|
* Provide static `require` analysis in `urlencoded` parser |
||||||
|
* deps: depd@~1.1.0 |
||||||
|
- Support web browser loading |
||||||
|
* deps: qs@5.1.0 |
||||||
|
* deps: raw-body@~2.1.3 |
||||||
|
- Fix sync callback when attaching data listener causes sync read |
||||||
|
* deps: type-is@~1.6.8 |
||||||
|
- Fix type error when given invalid type to match against |
||||||
|
- deps: mime-types@~2.1.6 |
||||||
|
|
||||||
|
1.13.3 / 2015-07-31 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: type-is@~1.6.6 |
||||||
|
- deps: mime-types@~2.1.4 |
||||||
|
|
||||||
|
1.13.2 / 2015-07-05 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.11 |
||||||
|
* deps: qs@4.0.0 |
||||||
|
- Fix dropping parameters like `hasOwnProperty` |
||||||
|
- Fix user-visible incompatibilities from 3.1.0 |
||||||
|
- Fix various parsing edge cases |
||||||
|
* deps: raw-body@~2.1.2 |
||||||
|
- Fix error stack traces to skip `makeError` |
||||||
|
- deps: iconv-lite@0.4.11 |
||||||
|
* deps: type-is@~1.6.4 |
||||||
|
- deps: mime-types@~2.1.2 |
||||||
|
- perf: enable strict mode |
||||||
|
- perf: remove argument reassignment |
||||||
|
|
||||||
|
1.13.1 / 2015-06-16 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: qs@2.4.2 |
||||||
|
- Downgraded from 3.1.0 because of user-visible incompatibilities |
||||||
|
|
||||||
|
1.13.0 / 2015-06-14 |
||||||
|
=================== |
||||||
|
|
||||||
|
* Add `statusCode` property on `Error`s, in addition to `status` |
||||||
|
* Change `type` default to `application/json` for JSON parser |
||||||
|
* Change `type` default to `application/x-www-form-urlencoded` for urlencoded parser |
||||||
|
* Provide static `require` analysis |
||||||
|
* Use the `http-errors` module to generate errors |
||||||
|
* deps: bytes@2.1.0 |
||||||
|
- Slight optimizations |
||||||
|
* deps: iconv-lite@0.4.10 |
||||||
|
- The encoding UTF-16 without BOM now defaults to UTF-16LE when detection fails |
||||||
|
- Leading BOM is now removed when decoding |
||||||
|
* deps: on-finished@~2.3.0 |
||||||
|
- Add defined behavior for HTTP `CONNECT` requests |
||||||
|
- Add defined behavior for HTTP `Upgrade` requests |
||||||
|
- deps: ee-first@1.1.1 |
||||||
|
* deps: qs@3.1.0 |
||||||
|
- Fix dropping parameters like `hasOwnProperty` |
||||||
|
- Fix various parsing edge cases |
||||||
|
- Parsed object now has `null` prototype |
||||||
|
* deps: raw-body@~2.1.1 |
||||||
|
- Use `unpipe` module for unpiping requests |
||||||
|
- deps: iconv-lite@0.4.10 |
||||||
|
* deps: type-is@~1.6.3 |
||||||
|
- deps: mime-types@~2.1.1 |
||||||
|
- perf: reduce try block size |
||||||
|
- perf: remove bitwise operations |
||||||
|
* perf: enable strict mode |
||||||
|
* perf: remove argument reassignment |
||||||
|
* perf: remove delete call |
||||||
|
|
||||||
|
1.12.4 / 2015-05-10 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: debug@~2.2.0 |
||||||
|
* deps: qs@2.4.2 |
||||||
|
- Fix allowing parameters like `constructor` |
||||||
|
* deps: on-finished@~2.2.1 |
||||||
|
* deps: raw-body@~2.0.1 |
||||||
|
- Fix a false-positive when unpiping in Node.js 0.8 |
||||||
|
- deps: bytes@2.0.1 |
||||||
|
* deps: type-is@~1.6.2 |
||||||
|
- deps: mime-types@~2.0.11 |
||||||
|
|
||||||
|
1.12.3 / 2015-04-15 |
||||||
|
=================== |
||||||
|
|
||||||
|
* Slight efficiency improvement when not debugging |
||||||
|
* deps: depd@~1.0.1 |
||||||
|
* deps: iconv-lite@0.4.8 |
||||||
|
- Add encoding alias UNICODE-1-1-UTF-7 |
||||||
|
* deps: raw-body@1.3.4 |
||||||
|
- Fix hanging callback if request aborts during read |
||||||
|
- deps: iconv-lite@0.4.8 |
||||||
|
|
||||||
|
1.12.2 / 2015-03-16 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: qs@2.4.1 |
||||||
|
- Fix error when parameter `hasOwnProperty` is present |
||||||
|
|
||||||
|
1.12.1 / 2015-03-15 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: debug@~2.1.3 |
||||||
|
- Fix high intensity foreground color for bold |
||||||
|
- deps: ms@0.7.0 |
||||||
|
* deps: type-is@~1.6.1 |
||||||
|
- deps: mime-types@~2.0.10 |
||||||
|
|
||||||
|
1.12.0 / 2015-02-13 |
||||||
|
=================== |
||||||
|
|
||||||
|
* add `debug` messages |
||||||
|
* accept a function for the `type` option |
||||||
|
* use `content-type` to parse `Content-Type` headers |
||||||
|
* deps: iconv-lite@0.4.7 |
||||||
|
- Gracefully support enumerables on `Object.prototype` |
||||||
|
* deps: raw-body@1.3.3 |
||||||
|
- deps: iconv-lite@0.4.7 |
||||||
|
* deps: type-is@~1.6.0 |
||||||
|
- fix argument reassignment |
||||||
|
- fix false-positives in `hasBody` `Transfer-Encoding` check |
||||||
|
- support wildcard for both type and subtype (`*/*`) |
||||||
|
- deps: mime-types@~2.0.9 |
||||||
|
|
||||||
|
1.11.0 / 2015-01-30 |
||||||
|
=================== |
||||||
|
|
||||||
|
* make internal `extended: true` depth limit infinity |
||||||
|
* deps: type-is@~1.5.6 |
||||||
|
- deps: mime-types@~2.0.8 |
||||||
|
|
||||||
|
1.10.2 / 2015-01-20 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.6 |
||||||
|
- Fix rare aliases of single-byte encodings |
||||||
|
* deps: raw-body@1.3.2 |
||||||
|
- deps: iconv-lite@0.4.6 |
||||||
|
|
||||||
|
1.10.1 / 2015-01-01 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: on-finished@~2.2.0 |
||||||
|
* deps: type-is@~1.5.5 |
||||||
|
- deps: mime-types@~2.0.7 |
||||||
|
|
||||||
|
1.10.0 / 2014-12-02 |
||||||
|
=================== |
||||||
|
|
||||||
|
* make internal `extended: true` array limit dynamic |
||||||
|
|
||||||
|
1.9.3 / 2014-11-21 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.5 |
||||||
|
- Fix Windows-31J and X-SJIS encoding support |
||||||
|
* deps: qs@2.3.3 |
||||||
|
- Fix `arrayLimit` behavior |
||||||
|
* deps: raw-body@1.3.1 |
||||||
|
- deps: iconv-lite@0.4.5 |
||||||
|
* deps: type-is@~1.5.3 |
||||||
|
- deps: mime-types@~2.0.3 |
||||||
|
|
||||||
|
1.9.2 / 2014-10-27 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@2.3.2 |
||||||
|
- Fix parsing of mixed objects and values |
||||||
|
|
||||||
|
1.9.1 / 2014-10-22 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: on-finished@~2.1.1 |
||||||
|
- Fix handling of pipelined requests |
||||||
|
* deps: qs@2.3.0 |
||||||
|
- Fix parsing of mixed implicit and explicit arrays |
||||||
|
* deps: type-is@~1.5.2 |
||||||
|
- deps: mime-types@~2.0.2 |
||||||
|
|
||||||
|
1.9.0 / 2014-09-24 |
||||||
|
================== |
||||||
|
|
||||||
|
* include the charset in "unsupported charset" error message |
||||||
|
* include the encoding in "unsupported content encoding" error message |
||||||
|
* deps: depd@~1.0.0 |
||||||
|
|
||||||
|
1.8.4 / 2014-09-23 |
||||||
|
================== |
||||||
|
|
||||||
|
* fix content encoding to be case-insensitive |
||||||
|
|
||||||
|
1.8.3 / 2014-09-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@2.2.4 |
||||||
|
- Fix issue with object keys starting with numbers truncated |
||||||
|
|
||||||
|
1.8.2 / 2014-09-15 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: depd@0.4.5 |
||||||
|
|
||||||
|
1.8.1 / 2014-09-07 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: media-typer@0.3.0 |
||||||
|
* deps: type-is@~1.5.1 |
||||||
|
|
||||||
|
1.8.0 / 2014-09-05 |
||||||
|
================== |
||||||
|
|
||||||
|
* make empty-body-handling consistent between chunked requests |
||||||
|
- empty `json` produces `{}` |
||||||
|
- empty `raw` produces `new Buffer(0)` |
||||||
|
- empty `text` produces `''` |
||||||
|
- empty `urlencoded` produces `{}` |
||||||
|
* deps: qs@2.2.3 |
||||||
|
- Fix issue where first empty value in array is discarded |
||||||
|
* deps: type-is@~1.5.0 |
||||||
|
- fix `hasbody` to be true for `content-length: 0` |
||||||
|
|
||||||
|
1.7.0 / 2014-09-01 |
||||||
|
================== |
||||||
|
|
||||||
|
* add `parameterLimit` option to `urlencoded` parser |
||||||
|
* change `urlencoded` extended array limit to 100 |
||||||
|
* respond with 413 when over `parameterLimit` in `urlencoded` |
||||||
|
|
||||||
|
1.6.7 / 2014-08-29 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@2.2.2 |
||||||
|
- Remove unnecessary cloning |
||||||
|
|
||||||
|
1.6.6 / 2014-08-27 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@2.2.0 |
||||||
|
- Array parsing fix |
||||||
|
- Performance improvements |
||||||
|
|
||||||
|
1.6.5 / 2014-08-16 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: on-finished@2.1.0 |
||||||
|
|
||||||
|
1.6.4 / 2014-08-14 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@1.2.2 |
||||||
|
|
||||||
|
1.6.3 / 2014-08-10 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@1.2.1 |
||||||
|
|
||||||
|
1.6.2 / 2014-08-07 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@1.2.0 |
||||||
|
- Fix parsing array of objects |
||||||
|
|
||||||
|
1.6.1 / 2014-08-06 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@1.1.0 |
||||||
|
- Accept urlencoded square brackets |
||||||
|
- Accept empty values in implicit array notation |
||||||
|
|
||||||
|
1.6.0 / 2014-08-05 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: qs@1.0.2 |
||||||
|
- Complete rewrite |
||||||
|
- Limits array length to 20 |
||||||
|
- Limits object depth to 5 |
||||||
|
- Limits parameters to 1,000 |
||||||
|
|
||||||
|
1.5.2 / 2014-07-27 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: depd@0.4.4 |
||||||
|
- Work-around v8 generating empty stack traces |
||||||
|
|
||||||
|
1.5.1 / 2014-07-26 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: depd@0.4.3 |
||||||
|
- Fix exception when global `Error.stackTraceLimit` is too low |
||||||
|
|
||||||
|
1.5.0 / 2014-07-20 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: depd@0.4.2 |
||||||
|
- Add `TRACE_DEPRECATION` environment variable |
||||||
|
- Remove non-standard grey color from color output |
||||||
|
- Support `--no-deprecation` argument |
||||||
|
- Support `--trace-deprecation` argument |
||||||
|
* deps: iconv-lite@0.4.4 |
||||||
|
- Added encoding UTF-7 |
||||||
|
* deps: raw-body@1.3.0 |
||||||
|
- deps: iconv-lite@0.4.4 |
||||||
|
- Added encoding UTF-7 |
||||||
|
- Fix `Cannot switch to old mode now` error on Node.js 0.10+ |
||||||
|
* deps: type-is@~1.3.2 |
||||||
|
|
||||||
|
1.4.3 / 2014-06-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: type-is@1.3.1 |
||||||
|
- fix global variable leak |
||||||
|
|
||||||
|
1.4.2 / 2014-06-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: type-is@1.3.0 |
||||||
|
- improve type parsing |
||||||
|
|
||||||
|
1.4.1 / 2014-06-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* fix urlencoded extended deprecation message |
||||||
|
|
||||||
|
1.4.0 / 2014-06-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* add `text` parser |
||||||
|
* add `raw` parser |
||||||
|
* check accepted charset in content-type (accepts utf-8) |
||||||
|
* check accepted encoding in content-encoding (accepts identity) |
||||||
|
* deprecate `bodyParser()` middleware; use `.json()` and `.urlencoded()` as needed |
||||||
|
* deprecate `urlencoded()` without provided `extended` option |
||||||
|
* lazy-load urlencoded parsers |
||||||
|
* parsers split into files for reduced mem usage |
||||||
|
* support gzip and deflate bodies |
||||||
|
- set `inflate: false` to turn off |
||||||
|
* deps: raw-body@1.2.2 |
||||||
|
- Support all encodings from `iconv-lite` |
||||||
|
|
||||||
|
1.3.1 / 2014-06-11 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: type-is@1.2.1 |
||||||
|
- Switch dependency from mime to mime-types@1.0.0 |
||||||
|
|
||||||
|
1.3.0 / 2014-05-31 |
||||||
|
================== |
||||||
|
|
||||||
|
* add `extended` option to urlencoded parser |
||||||
|
|
||||||
|
1.2.2 / 2014-05-27 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: raw-body@1.1.6 |
||||||
|
- assert stream encoding on node.js 0.8 |
||||||
|
- assert stream encoding on node.js < 0.10.6 |
||||||
|
- deps: bytes@1 |
||||||
|
|
||||||
|
1.2.1 / 2014-05-26 |
||||||
|
================== |
||||||
|
|
||||||
|
* invoke `next(err)` after request fully read |
||||||
|
- prevents hung responses and socket hang ups |
||||||
|
|
||||||
|
1.2.0 / 2014-05-11 |
||||||
|
================== |
||||||
|
|
||||||
|
* add `verify` option |
||||||
|
* deps: type-is@1.2.0 |
||||||
|
- support suffix matching |
||||||
|
|
||||||
|
1.1.2 / 2014-05-11 |
||||||
|
================== |
||||||
|
|
||||||
|
* improve json parser speed |
||||||
|
|
||||||
|
1.1.1 / 2014-05-11 |
||||||
|
================== |
||||||
|
|
||||||
|
* fix repeated limit parsing with every request |
||||||
|
|
||||||
|
1.1.0 / 2014-05-10 |
||||||
|
================== |
||||||
|
|
||||||
|
* add `type` option |
||||||
|
* deps: pin for safety and consistency |
||||||
|
|
||||||
|
1.0.2 / 2014-04-14 |
||||||
|
================== |
||||||
|
|
||||||
|
* use `type-is` module |
||||||
|
|
||||||
|
1.0.1 / 2014-03-20 |
||||||
|
================== |
||||||
|
|
||||||
|
* lower default limits to 100kb |
@ -0,0 +1,23 @@ |
|||||||
|
(The MIT License) |
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> |
||||||
|
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com> |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining |
||||||
|
a copy of this software and associated documentation files (the |
||||||
|
'Software'), to deal in the Software without restriction, including |
||||||
|
without limitation the rights to use, copy, modify, merge, publish, |
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to |
||||||
|
permit persons to whom the Software is furnished to do so, subject to |
||||||
|
the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be |
||||||
|
included in all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,476 @@ |
|||||||
|
# body-parser |
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url] |
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url] |
||||||
|
[![Build Status][ci-image]][ci-url] |
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url] |
||||||
|
[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer] |
||||||
|
|
||||||
|
Node.js body parsing middleware. |
||||||
|
|
||||||
|
Parse incoming request bodies in a middleware before your handlers, available |
||||||
|
under the `req.body` property. |
||||||
|
|
||||||
|
**Note** As `req.body`'s shape is based on user-controlled input, all |
||||||
|
properties and values in this object are untrusted and should be validated |
||||||
|
before trusting. For example, `req.body.foo.toString()` may fail in multiple |
||||||
|
ways, for example the `foo` property may not be there or may not be a string, |
||||||
|
and `toString` may not be a function and instead a string or other user input. |
||||||
|
|
||||||
|
[Learn about the anatomy of an HTTP transaction in Node.js](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/). |
||||||
|
|
||||||
|
_This does not handle multipart bodies_, due to their complex and typically |
||||||
|
large nature. For multipart bodies, you may be interested in the following |
||||||
|
modules: |
||||||
|
|
||||||
|
* [busboy](https://www.npmjs.org/package/busboy#readme) and |
||||||
|
[connect-busboy](https://www.npmjs.org/package/connect-busboy#readme) |
||||||
|
* [multiparty](https://www.npmjs.org/package/multiparty#readme) and |
||||||
|
[connect-multiparty](https://www.npmjs.org/package/connect-multiparty#readme) |
||||||
|
* [formidable](https://www.npmjs.org/package/formidable#readme) |
||||||
|
* [multer](https://www.npmjs.org/package/multer#readme) |
||||||
|
|
||||||
|
This module provides the following parsers: |
||||||
|
|
||||||
|
* [JSON body parser](#bodyparserjsonoptions) |
||||||
|
* [Raw body parser](#bodyparserrawoptions) |
||||||
|
* [Text body parser](#bodyparsertextoptions) |
||||||
|
* [URL-encoded form body parser](#bodyparserurlencodedoptions) |
||||||
|
|
||||||
|
Other body parsers you might be interested in: |
||||||
|
|
||||||
|
- [body](https://www.npmjs.org/package/body#readme) |
||||||
|
- [co-body](https://www.npmjs.org/package/co-body#readme) |
||||||
|
|
||||||
|
## Installation |
||||||
|
|
||||||
|
```sh |
||||||
|
$ npm install body-parser |
||||||
|
``` |
||||||
|
|
||||||
|
## API |
||||||
|
|
||||||
|
```js |
||||||
|
var bodyParser = require('body-parser') |
||||||
|
``` |
||||||
|
|
||||||
|
The `bodyParser` object exposes various factories to create middlewares. All |
||||||
|
middlewares will populate the `req.body` property with the parsed body when |
||||||
|
the `Content-Type` request header matches the `type` option, or an empty |
||||||
|
object (`{}`) if there was no body to parse, the `Content-Type` was not matched, |
||||||
|
or an error occurred. |
||||||
|
|
||||||
|
The various errors returned by this module are described in the |
||||||
|
[errors section](#errors). |
||||||
|
|
||||||
|
### bodyParser.json([options]) |
||||||
|
|
||||||
|
Returns middleware that only parses `json` and only looks at requests where |
||||||
|
the `Content-Type` header matches the `type` option. This parser accepts any |
||||||
|
Unicode encoding of the body and supports automatic inflation of `gzip` and |
||||||
|
`deflate` encodings. |
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request` |
||||||
|
object after the middleware (i.e. `req.body`). |
||||||
|
|
||||||
|
#### Options |
||||||
|
|
||||||
|
The `json` function takes an optional `options` object that may contain any of |
||||||
|
the following keys: |
||||||
|
|
||||||
|
##### inflate |
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when |
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`. |
||||||
|
|
||||||
|
##### limit |
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value |
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the |
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults |
||||||
|
to `'100kb'`. |
||||||
|
|
||||||
|
##### reviver |
||||||
|
|
||||||
|
The `reviver` option is passed directly to `JSON.parse` as the second |
||||||
|
argument. You can find more information on this argument |
||||||
|
[in the MDN documentation about JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter). |
||||||
|
|
||||||
|
##### strict |
||||||
|
|
||||||
|
When set to `true`, will only accept arrays and objects; when `false` will |
||||||
|
accept anything `JSON.parse` accepts. Defaults to `true`. |
||||||
|
|
||||||
|
##### type |
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will |
||||||
|
parse. This option can be a string, array of strings, or a function. If not a |
||||||
|
function, `type` option is passed directly to the |
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can |
||||||
|
be an extension name (like `json`), a mime type (like `application/json`), or |
||||||
|
a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type` |
||||||
|
option is called as `fn(req)` and the request is parsed if it returns a truthy |
||||||
|
value. Defaults to `application/json`. |
||||||
|
|
||||||
|
##### verify |
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`, |
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the |
||||||
|
encoding of the request. The parsing can be aborted by throwing an error. |
||||||
|
|
||||||
|
### bodyParser.raw([options]) |
||||||
|
|
||||||
|
Returns middleware that parses all bodies as a `Buffer` and only looks at |
||||||
|
requests where the `Content-Type` header matches the `type` option. This |
||||||
|
parser supports automatic inflation of `gzip` and `deflate` encodings. |
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request` |
||||||
|
object after the middleware (i.e. `req.body`). This will be a `Buffer` object |
||||||
|
of the body. |
||||||
|
|
||||||
|
#### Options |
||||||
|
|
||||||
|
The `raw` function takes an optional `options` object that may contain any of |
||||||
|
the following keys: |
||||||
|
|
||||||
|
##### inflate |
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when |
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`. |
||||||
|
|
||||||
|
##### limit |
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value |
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the |
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults |
||||||
|
to `'100kb'`. |
||||||
|
|
||||||
|
##### type |
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will |
||||||
|
parse. This option can be a string, array of strings, or a function. |
||||||
|
If not a function, `type` option is passed directly to the |
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this |
||||||
|
can be an extension name (like `bin`), a mime type (like |
||||||
|
`application/octet-stream`), or a mime type with a wildcard (like `*/*` or |
||||||
|
`application/*`). If a function, the `type` option is called as `fn(req)` |
||||||
|
and the request is parsed if it returns a truthy value. Defaults to |
||||||
|
`application/octet-stream`. |
||||||
|
|
||||||
|
##### verify |
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`, |
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the |
||||||
|
encoding of the request. The parsing can be aborted by throwing an error. |
||||||
|
|
||||||
|
### bodyParser.text([options]) |
||||||
|
|
||||||
|
Returns middleware that parses all bodies as a string and only looks at |
||||||
|
requests where the `Content-Type` header matches the `type` option. This |
||||||
|
parser supports automatic inflation of `gzip` and `deflate` encodings. |
||||||
|
|
||||||
|
A new `body` string containing the parsed data is populated on the `request` |
||||||
|
object after the middleware (i.e. `req.body`). This will be a string of the |
||||||
|
body. |
||||||
|
|
||||||
|
#### Options |
||||||
|
|
||||||
|
The `text` function takes an optional `options` object that may contain any of |
||||||
|
the following keys: |
||||||
|
|
||||||
|
##### defaultCharset |
||||||
|
|
||||||
|
Specify the default character set for the text content if the charset is not |
||||||
|
specified in the `Content-Type` header of the request. Defaults to `utf-8`. |
||||||
|
|
||||||
|
##### inflate |
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when |
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`. |
||||||
|
|
||||||
|
##### limit |
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value |
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the |
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults |
||||||
|
to `'100kb'`. |
||||||
|
|
||||||
|
##### type |
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will |
||||||
|
parse. This option can be a string, array of strings, or a function. If not |
||||||
|
a function, `type` option is passed directly to the |
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can |
||||||
|
be an extension name (like `txt`), a mime type (like `text/plain`), or a mime |
||||||
|
type with a wildcard (like `*/*` or `text/*`). If a function, the `type` |
||||||
|
option is called as `fn(req)` and the request is parsed if it returns a |
||||||
|
truthy value. Defaults to `text/plain`. |
||||||
|
|
||||||
|
##### verify |
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`, |
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the |
||||||
|
encoding of the request. The parsing can be aborted by throwing an error. |
||||||
|
|
||||||
|
### bodyParser.urlencoded([options]) |
||||||
|
|
||||||
|
Returns middleware that only parses `urlencoded` bodies and only looks at |
||||||
|
requests where the `Content-Type` header matches the `type` option. This |
||||||
|
parser accepts only UTF-8 encoding of the body and supports automatic |
||||||
|
inflation of `gzip` and `deflate` encodings. |
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request` |
||||||
|
object after the middleware (i.e. `req.body`). This object will contain |
||||||
|
key-value pairs, where the value can be a string or array (when `extended` is |
||||||
|
`false`), or any type (when `extended` is `true`). |
||||||
|
|
||||||
|
#### Options |
||||||
|
|
||||||
|
The `urlencoded` function takes an optional `options` object that may contain |
||||||
|
any of the following keys: |
||||||
|
|
||||||
|
##### extended |
||||||
|
|
||||||
|
The `extended` option allows to choose between parsing the URL-encoded data |
||||||
|
with the `querystring` library (when `false`) or the `qs` library (when |
||||||
|
`true`). The "extended" syntax allows for rich objects and arrays to be |
||||||
|
encoded into the URL-encoded format, allowing for a JSON-like experience |
||||||
|
with URL-encoded. For more information, please |
||||||
|
[see the qs library](https://www.npmjs.org/package/qs#readme). |
||||||
|
|
||||||
|
Defaults to `true`, but using the default has been deprecated. Please |
||||||
|
research into the difference between `qs` and `querystring` and choose the |
||||||
|
appropriate setting. |
||||||
|
|
||||||
|
##### inflate |
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when |
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`. |
||||||
|
|
||||||
|
##### limit |
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value |
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the |
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults |
||||||
|
to `'100kb'`. |
||||||
|
|
||||||
|
##### parameterLimit |
||||||
|
|
||||||
|
The `parameterLimit` option controls the maximum number of parameters that |
||||||
|
are allowed in the URL-encoded data. If a request contains more parameters |
||||||
|
than this value, a 413 will be returned to the client. Defaults to `1000`. |
||||||
|
|
||||||
|
##### type |
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will |
||||||
|
parse. This option can be a string, array of strings, or a function. If not |
||||||
|
a function, `type` option is passed directly to the |
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can |
||||||
|
be an extension name (like `urlencoded`), a mime type (like |
||||||
|
`application/x-www-form-urlencoded`), or a mime type with a wildcard (like |
||||||
|
`*/x-www-form-urlencoded`). If a function, the `type` option is called as |
||||||
|
`fn(req)` and the request is parsed if it returns a truthy value. Defaults |
||||||
|
to `application/x-www-form-urlencoded`. |
||||||
|
|
||||||
|
##### verify |
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`, |
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the |
||||||
|
encoding of the request. The parsing can be aborted by throwing an error. |
||||||
|
|
||||||
|
#### depth |
||||||
|
|
||||||
|
The `depth` option is used to configure the maximum depth of the `qs` library when `extended` is `true`. This allows you to limit the amount of keys that are parsed and can be useful to prevent certain types of abuse. Defaults to `32`. It is recommended to keep this value as low as possible. |
||||||
|
|
||||||
|
## Errors |
||||||
|
|
||||||
|
The middlewares provided by this module create errors using the |
||||||
|
[`http-errors` module](https://www.npmjs.com/package/http-errors). The errors |
||||||
|
will typically have a `status`/`statusCode` property that contains the suggested |
||||||
|
HTTP response code, an `expose` property to determine if the `message` property |
||||||
|
should be displayed to the client, a `type` property to determine the type of |
||||||
|
error without matching against the `message`, and a `body` property containing |
||||||
|
the read body, if available. |
||||||
|
|
||||||
|
The following are the common errors created, though any error can come through |
||||||
|
for various reasons. |
||||||
|
|
||||||
|
### content encoding unsupported |
||||||
|
|
||||||
|
This error will occur when the request had a `Content-Encoding` header that |
||||||
|
contained an encoding but the "inflation" option was set to `false`. The |
||||||
|
`status` property is set to `415`, the `type` property is set to |
||||||
|
`'encoding.unsupported'`, and the `charset` property will be set to the |
||||||
|
encoding that is unsupported. |
||||||
|
|
||||||
|
### entity parse failed |
||||||
|
|
||||||
|
This error will occur when the request contained an entity that could not be |
||||||
|
parsed by the middleware. The `status` property is set to `400`, the `type` |
||||||
|
property is set to `'entity.parse.failed'`, and the `body` property is set to |
||||||
|
the entity value that failed parsing. |
||||||
|
|
||||||
|
### entity verify failed |
||||||
|
|
||||||
|
This error will occur when the request contained an entity that could not be |
||||||
|
failed verification by the defined `verify` option. The `status` property is |
||||||
|
set to `403`, the `type` property is set to `'entity.verify.failed'`, and the |
||||||
|
`body` property is set to the entity value that failed verification. |
||||||
|
|
||||||
|
### request aborted |
||||||
|
|
||||||
|
This error will occur when the request is aborted by the client before reading |
||||||
|
the body has finished. The `received` property will be set to the number of |
||||||
|
bytes received before the request was aborted and the `expected` property is |
||||||
|
set to the number of expected bytes. The `status` property is set to `400` |
||||||
|
and `type` property is set to `'request.aborted'`. |
||||||
|
|
||||||
|
### request entity too large |
||||||
|
|
||||||
|
This error will occur when the request body's size is larger than the "limit" |
||||||
|
option. The `limit` property will be set to the byte limit and the `length` |
||||||
|
property will be set to the request body's length. The `status` property is |
||||||
|
set to `413` and the `type` property is set to `'entity.too.large'`. |
||||||
|
|
||||||
|
### request size did not match content length |
||||||
|
|
||||||
|
This error will occur when the request's length did not match the length from |
||||||
|
the `Content-Length` header. This typically occurs when the request is malformed, |
||||||
|
typically when the `Content-Length` header was calculated based on characters |
||||||
|
instead of bytes. The `status` property is set to `400` and the `type` property |
||||||
|
is set to `'request.size.invalid'`. |
||||||
|
|
||||||
|
### stream encoding should not be set |
||||||
|
|
||||||
|
This error will occur when something called the `req.setEncoding` method prior |
||||||
|
to this middleware. This module operates directly on bytes only and you cannot |
||||||
|
call `req.setEncoding` when using this module. The `status` property is set to |
||||||
|
`500` and the `type` property is set to `'stream.encoding.set'`. |
||||||
|
|
||||||
|
### stream is not readable |
||||||
|
|
||||||
|
This error will occur when the request is no longer readable when this middleware |
||||||
|
attempts to read it. This typically means something other than a middleware from |
||||||
|
this module read the request body already and the middleware was also configured to |
||||||
|
read the same request. The `status` property is set to `500` and the `type` |
||||||
|
property is set to `'stream.not.readable'`. |
||||||
|
|
||||||
|
### too many parameters |
||||||
|
|
||||||
|
This error will occur when the content of the request exceeds the configured |
||||||
|
`parameterLimit` for the `urlencoded` parser. The `status` property is set to |
||||||
|
`413` and the `type` property is set to `'parameters.too.many'`. |
||||||
|
|
||||||
|
### unsupported charset "BOGUS" |
||||||
|
|
||||||
|
This error will occur when the request had a charset parameter in the |
||||||
|
`Content-Type` header, but the `iconv-lite` module does not support it OR the |
||||||
|
parser does not support it. The charset is contained in the message as well |
||||||
|
as in the `charset` property. The `status` property is set to `415`, the |
||||||
|
`type` property is set to `'charset.unsupported'`, and the `charset` property |
||||||
|
is set to the charset that is unsupported. |
||||||
|
|
||||||
|
### unsupported content encoding "bogus" |
||||||
|
|
||||||
|
This error will occur when the request had a `Content-Encoding` header that |
||||||
|
contained an unsupported encoding. The encoding is contained in the message |
||||||
|
as well as in the `encoding` property. The `status` property is set to `415`, |
||||||
|
the `type` property is set to `'encoding.unsupported'`, and the `encoding` |
||||||
|
property is set to the encoding that is unsupported. |
||||||
|
|
||||||
|
### The input exceeded the depth |
||||||
|
|
||||||
|
This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value. When the `depth` option is set to `32` (default value), the error will not be thrown. |
||||||
|
|
||||||
|
## Examples |
||||||
|
|
||||||
|
### Express/Connect top-level generic |
||||||
|
|
||||||
|
This example demonstrates adding a generic JSON and URL-encoded parser as a |
||||||
|
top-level middleware, which will parse the bodies of all incoming requests. |
||||||
|
This is the simplest setup. |
||||||
|
|
||||||
|
```js |
||||||
|
var express = require('express') |
||||||
|
var bodyParser = require('body-parser') |
||||||
|
|
||||||
|
var app = express() |
||||||
|
|
||||||
|
// parse application/x-www-form-urlencoded |
||||||
|
app.use(bodyParser.urlencoded({ extended: false })) |
||||||
|
|
||||||
|
// parse application/json |
||||||
|
app.use(bodyParser.json()) |
||||||
|
|
||||||
|
app.use(function (req, res) { |
||||||
|
res.setHeader('Content-Type', 'text/plain') |
||||||
|
res.write('you posted:\n') |
||||||
|
res.end(JSON.stringify(req.body, null, 2)) |
||||||
|
}) |
||||||
|
``` |
||||||
|
|
||||||
|
### Express route-specific |
||||||
|
|
||||||
|
This example demonstrates adding body parsers specifically to the routes that |
||||||
|
need them. In general, this is the most recommended way to use body-parser with |
||||||
|
Express. |
||||||
|
|
||||||
|
```js |
||||||
|
var express = require('express') |
||||||
|
var bodyParser = require('body-parser') |
||||||
|
|
||||||
|
var app = express() |
||||||
|
|
||||||
|
// create application/json parser |
||||||
|
var jsonParser = bodyParser.json() |
||||||
|
|
||||||
|
// create application/x-www-form-urlencoded parser |
||||||
|
var urlencodedParser = bodyParser.urlencoded({ extended: false }) |
||||||
|
|
||||||
|
// POST /login gets urlencoded bodies |
||||||
|
app.post('/login', urlencodedParser, function (req, res) { |
||||||
|
res.send('welcome, ' + req.body.username) |
||||||
|
}) |
||||||
|
|
||||||
|
// POST /api/users gets JSON bodies |
||||||
|
app.post('/api/users', jsonParser, function (req, res) { |
||||||
|
// create user in req.body |
||||||
|
}) |
||||||
|
``` |
||||||
|
|
||||||
|
### Change accepted type for parsers |
||||||
|
|
||||||
|
All the parsers accept a `type` option which allows you to change the |
||||||
|
`Content-Type` that the middleware will parse. |
||||||
|
|
||||||
|
```js |
||||||
|
var express = require('express') |
||||||
|
var bodyParser = require('body-parser') |
||||||
|
|
||||||
|
var app = express() |
||||||
|
|
||||||
|
// parse various different custom JSON types as JSON |
||||||
|
app.use(bodyParser.json({ type: 'application/*+json' })) |
||||||
|
|
||||||
|
// parse some custom thing into a Buffer |
||||||
|
app.use(bodyParser.raw({ type: 'application/vnd.custom-type' })) |
||||||
|
|
||||||
|
// parse an HTML body into a string |
||||||
|
app.use(bodyParser.text({ type: 'text/html' })) |
||||||
|
``` |
||||||
|
|
||||||
|
## License |
||||||
|
|
||||||
|
[MIT](LICENSE) |
||||||
|
|
||||||
|
[ci-image]: https://badgen.net/github/checks/expressjs/body-parser/master?label=ci |
||||||
|
[ci-url]: https://github.com/expressjs/body-parser/actions/workflows/ci.yml |
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/body-parser/master |
||||||
|
[coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master |
||||||
|
[node-version-image]: https://badgen.net/npm/node/body-parser |
||||||
|
[node-version-url]: https://nodejs.org/en/download |
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/body-parser |
||||||
|
[npm-url]: https://npmjs.org/package/body-parser |
||||||
|
[npm-version-image]: https://badgen.net/npm/v/body-parser |
||||||
|
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/body-parser/badge |
||||||
|
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/body-parser |
@ -0,0 +1,25 @@ |
|||||||
|
# Security Policies and Procedures |
||||||
|
|
||||||
|
## Reporting a Bug |
||||||
|
|
||||||
|
The Express team and community take all security bugs seriously. Thank you |
||||||
|
for improving the security of Express. We appreciate your efforts and |
||||||
|
responsible disclosure and will make every effort to acknowledge your |
||||||
|
contributions. |
||||||
|
|
||||||
|
Report security bugs by emailing the current owner(s) of `body-parser`. This |
||||||
|
information can be found in the npm registry using the command |
||||||
|
`npm owner ls body-parser`. |
||||||
|
If unsure or unable to get the information from the above, open an issue |
||||||
|
in the [project issue tracker](https://github.com/expressjs/body-parser/issues) |
||||||
|
asking for the current contact information. |
||||||
|
|
||||||
|
To ensure the timely response to your report, please ensure that the entirety |
||||||
|
of the report is contained within the email body and not solely behind a web |
||||||
|
link or an attachment. |
||||||
|
|
||||||
|
At least one owner will acknowledge your email within 48 hours, and will send a |
||||||
|
more detailed response within 48 hours indicating the next steps in handling |
||||||
|
your report. After the initial reply to your report, the owners will |
||||||
|
endeavor to keep you informed of the progress towards a fix and full |
||||||
|
announcement, and may ask for additional information or guidance. |
@ -0,0 +1,156 @@ |
|||||||
|
/*! |
||||||
|
* body-parser |
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Module dependencies. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
var deprecate = require('depd')('body-parser') |
||||||
|
|
||||||
|
/** |
||||||
|
* Cache of loaded parsers. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
var parsers = Object.create(null) |
||||||
|
|
||||||
|
/** |
||||||
|
* @typedef Parsers |
||||||
|
* @type {function} |
||||||
|
* @property {function} json |
||||||
|
* @property {function} raw |
||||||
|
* @property {function} text |
||||||
|
* @property {function} urlencoded |
||||||
|
*/ |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
* @type {Parsers} |
||||||
|
*/ |
||||||
|
|
||||||
|
exports = module.exports = deprecate.function(bodyParser, |
||||||
|
'bodyParser: use individual json/urlencoded middlewares') |
||||||
|
|
||||||
|
/** |
||||||
|
* JSON parser. |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Object.defineProperty(exports, 'json', { |
||||||
|
configurable: true, |
||||||
|
enumerable: true, |
||||||
|
get: createParserGetter('json') |
||||||
|
}) |
||||||
|
|
||||||
|
/** |
||||||
|
* Raw parser. |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Object.defineProperty(exports, 'raw', { |
||||||
|
configurable: true, |
||||||
|
enumerable: true, |
||||||
|
get: createParserGetter('raw') |
||||||
|
}) |
||||||
|
|
||||||
|
/** |
||||||
|
* Text parser. |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Object.defineProperty(exports, 'text', { |
||||||
|
configurable: true, |
||||||
|
enumerable: true, |
||||||
|
get: createParserGetter('text') |
||||||
|
}) |
||||||
|
|
||||||
|
/** |
||||||
|
* URL-encoded parser. |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Object.defineProperty(exports, 'urlencoded', { |
||||||
|
configurable: true, |
||||||
|
enumerable: true, |
||||||
|
get: createParserGetter('urlencoded') |
||||||
|
}) |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a middleware to parse json and urlencoded bodies. |
||||||
|
* |
||||||
|
* @param {object} [options] |
||||||
|
* @return {function} |
||||||
|
* @deprecated |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
function bodyParser (options) { |
||||||
|
// use default type for parsers
|
||||||
|
var opts = Object.create(options || null, { |
||||||
|
type: { |
||||||
|
configurable: true, |
||||||
|
enumerable: true, |
||||||
|
value: undefined, |
||||||
|
writable: true |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
var _urlencoded = exports.urlencoded(opts) |
||||||
|
var _json = exports.json(opts) |
||||||
|
|
||||||
|
return function bodyParser (req, res, next) { |
||||||
|
_json(req, res, function (err) { |
||||||
|
if (err) return next(err) |
||||||
|
_urlencoded(req, res, next) |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a getter for loading a parser. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function createParserGetter (name) { |
||||||
|
return function get () { |
||||||
|
return loadParser(name) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Load a parser module. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function loadParser (parserName) { |
||||||
|
var parser = parsers[parserName] |
||||||
|
|
||||||
|
if (parser !== undefined) { |
||||||
|
return parser |
||||||
|
} |
||||||
|
|
||||||
|
// this uses a switch for static require analysis
|
||||||
|
switch (parserName) { |
||||||
|
case 'json': |
||||||
|
parser = require('./lib/types/json') |
||||||
|
break |
||||||
|
case 'raw': |
||||||
|
parser = require('./lib/types/raw') |
||||||
|
break |
||||||
|
case 'text': |
||||||
|
parser = require('./lib/types/text') |
||||||
|
break |
||||||
|
case 'urlencoded': |
||||||
|
parser = require('./lib/types/urlencoded') |
||||||
|
break |
||||||
|
} |
||||||
|
|
||||||
|
// store to prevent invoking require()
|
||||||
|
return (parsers[parserName] = parser) |
||||||
|
} |
@ -0,0 +1,205 @@ |
|||||||
|
/*! |
||||||
|
* body-parser |
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Module dependencies. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
var createError = require('http-errors') |
||||||
|
var destroy = require('destroy') |
||||||
|
var getBody = require('raw-body') |
||||||
|
var iconv = require('iconv-lite') |
||||||
|
var onFinished = require('on-finished') |
||||||
|
var unpipe = require('unpipe') |
||||||
|
var zlib = require('zlib') |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
*/ |
||||||
|
|
||||||
|
module.exports = read |
||||||
|
|
||||||
|
/** |
||||||
|
* Read a request into a buffer and parse. |
||||||
|
* |
||||||
|
* @param {object} req |
||||||
|
* @param {object} res |
||||||
|
* @param {function} next |
||||||
|
* @param {function} parse |
||||||
|
* @param {function} debug |
||||||
|
* @param {object} options |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function read (req, res, next, parse, debug, options) { |
||||||
|
var length |
||||||
|
var opts = options |
||||||
|
var stream |
||||||
|
|
||||||
|
// flag as parsed
|
||||||
|
req._body = true |
||||||
|
|
||||||
|
// read options
|
||||||
|
var encoding = opts.encoding !== null |
||||||
|
? opts.encoding |
||||||
|
: null |
||||||
|
var verify = opts.verify |
||||||
|
|
||||||
|
try { |
||||||
|
// get the content stream
|
||||||
|
stream = contentstream(req, debug, opts.inflate) |
||||||
|
length = stream.length |
||||||
|
stream.length = undefined |
||||||
|
} catch (err) { |
||||||
|
return next(err) |
||||||
|
} |
||||||
|
|
||||||
|
// set raw-body options
|
||||||
|
opts.length = length |
||||||
|
opts.encoding = verify |
||||||
|
? null |
||||||
|
: encoding |
||||||
|
|
||||||
|
// assert charset is supported
|
||||||
|
if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) { |
||||||
|
return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', { |
||||||
|
charset: encoding.toLowerCase(), |
||||||
|
type: 'charset.unsupported' |
||||||
|
})) |
||||||
|
} |
||||||
|
|
||||||
|
// read body
|
||||||
|
debug('read body') |
||||||
|
getBody(stream, opts, function (error, body) { |
||||||
|
if (error) { |
||||||
|
var _error |
||||||
|
|
||||||
|
if (error.type === 'encoding.unsupported') { |
||||||
|
// echo back charset
|
||||||
|
_error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', { |
||||||
|
charset: encoding.toLowerCase(), |
||||||
|
type: 'charset.unsupported' |
||||||
|
}) |
||||||
|
} else { |
||||||
|
// set status code on error
|
||||||
|
_error = createError(400, error) |
||||||
|
} |
||||||
|
|
||||||
|
// unpipe from stream and destroy
|
||||||
|
if (stream !== req) { |
||||||
|
unpipe(req) |
||||||
|
destroy(stream, true) |
||||||
|
} |
||||||
|
|
||||||
|
// read off entire request
|
||||||
|
dump(req, function onfinished () { |
||||||
|
next(createError(400, _error)) |
||||||
|
}) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// verify
|
||||||
|
if (verify) { |
||||||
|
try { |
||||||
|
debug('verify body') |
||||||
|
verify(req, res, body, encoding) |
||||||
|
} catch (err) { |
||||||
|
next(createError(403, err, { |
||||||
|
body: body, |
||||||
|
type: err.type || 'entity.verify.failed' |
||||||
|
})) |
||||||
|
return |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// parse
|
||||||
|
var str = body |
||||||
|
try { |
||||||
|
debug('parse body') |
||||||
|
str = typeof body !== 'string' && encoding !== null |
||||||
|
? iconv.decode(body, encoding) |
||||||
|
: body |
||||||
|
req.body = parse(str) |
||||||
|
} catch (err) { |
||||||
|
next(createError(400, err, { |
||||||
|
body: str, |
||||||
|
type: err.type || 'entity.parse.failed' |
||||||
|
})) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
next() |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the content stream of the request. |
||||||
|
* |
||||||
|
* @param {object} req |
||||||
|
* @param {function} debug |
||||||
|
* @param {boolean} [inflate=true] |
||||||
|
* @return {object} |
||||||
|
* @api private |
||||||
|
*/ |
||||||
|
|
||||||
|
function contentstream (req, debug, inflate) { |
||||||
|
var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase() |
||||||
|
var length = req.headers['content-length'] |
||||||
|
var stream |
||||||
|
|
||||||
|
debug('content-encoding "%s"', encoding) |
||||||
|
|
||||||
|
if (inflate === false && encoding !== 'identity') { |
||||||
|
throw createError(415, 'content encoding unsupported', { |
||||||
|
encoding: encoding, |
||||||
|
type: 'encoding.unsupported' |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
switch (encoding) { |
||||||
|
case 'deflate': |
||||||
|
stream = zlib.createInflate() |
||||||
|
debug('inflate body') |
||||||
|
req.pipe(stream) |
||||||
|
break |
||||||
|
case 'gzip': |
||||||
|
stream = zlib.createGunzip() |
||||||
|
debug('gunzip body') |
||||||
|
req.pipe(stream) |
||||||
|
break |
||||||
|
case 'identity': |
||||||
|
stream = req |
||||||
|
stream.length = length |
||||||
|
break |
||||||
|
default: |
||||||
|
throw createError(415, 'unsupported content encoding "' + encoding + '"', { |
||||||
|
encoding: encoding, |
||||||
|
type: 'encoding.unsupported' |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
return stream |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Dump the contents of a request. |
||||||
|
* |
||||||
|
* @param {object} req |
||||||
|
* @param {function} callback |
||||||
|
* @api private |
||||||
|
*/ |
||||||
|
|
||||||
|
function dump (req, callback) { |
||||||
|
if (onFinished.isFinished(req)) { |
||||||
|
callback(null) |
||||||
|
} else { |
||||||
|
onFinished(req, callback) |
||||||
|
req.resume() |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,247 @@ |
|||||||
|
/*! |
||||||
|
* body-parser |
||||||
|
* Copyright(c) 2014 Jonathan Ong |
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Module dependencies. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
var bytes = require('bytes') |
||||||
|
var contentType = require('content-type') |
||||||
|
var createError = require('http-errors') |
||||||
|
var debug = require('debug')('body-parser:json') |
||||||
|
var read = require('../read') |
||||||
|
var typeis = require('type-is') |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
*/ |
||||||
|
|
||||||
|
module.exports = json |
||||||
|
|
||||||
|
/** |
||||||
|
* RegExp to match the first non-space in a string. |
||||||
|
* |
||||||
|
* Allowed whitespace is defined in RFC 7159: |
||||||
|
* |
||||||
|
* ws = *( |
||||||
|
* %x20 / ; Space |
||||||
|
* %x09 / ; Horizontal tab |
||||||
|
* %x0A / ; Line feed or New line |
||||||
|
* %x0D ) ; Carriage return |
||||||
|
*/ |
||||||
|
|
||||||
|
var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex
|
||||||
|
|
||||||
|
var JSON_SYNTAX_CHAR = '#' |
||||||
|
var JSON_SYNTAX_REGEXP = /#+/g |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a middleware to parse JSON bodies. |
||||||
|
* |
||||||
|
* @param {object} [options] |
||||||
|
* @return {function} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
function json (options) { |
||||||
|
var opts = options || {} |
||||||
|
|
||||||
|
var limit = typeof opts.limit !== 'number' |
||||||
|
? bytes.parse(opts.limit || '100kb') |
||||||
|
: opts.limit |
||||||
|
var inflate = opts.inflate !== false |
||||||
|
var reviver = opts.reviver |
||||||
|
var strict = opts.strict !== false |
||||||
|
var type = opts.type || 'application/json' |
||||||
|
var verify = opts.verify || false |
||||||
|
|
||||||
|
if (verify !== false && typeof verify !== 'function') { |
||||||
|
throw new TypeError('option verify must be function') |
||||||
|
} |
||||||
|
|
||||||
|
// create the appropriate type checking function
|
||||||
|
var shouldParse = typeof type !== 'function' |
||||||
|
? typeChecker(type) |
||||||
|
: type |
||||||
|
|
||||||
|
function parse (body) { |
||||||
|
if (body.length === 0) { |
||||||
|
// special-case empty json body, as it's a common client-side mistake
|
||||||
|
// TODO: maybe make this configurable or part of "strict" option
|
||||||
|
return {} |
||||||
|
} |
||||||
|
|
||||||
|
if (strict) { |
||||||
|
var first = firstchar(body) |
||||||
|
|
||||||
|
if (first !== '{' && first !== '[') { |
||||||
|
debug('strict violation') |
||||||
|
throw createStrictSyntaxError(body, first) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
debug('parse json') |
||||||
|
return JSON.parse(body, reviver) |
||||||
|
} catch (e) { |
||||||
|
throw normalizeJsonSyntaxError(e, { |
||||||
|
message: e.message, |
||||||
|
stack: e.stack |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return function jsonParser (req, res, next) { |
||||||
|
if (req._body) { |
||||||
|
debug('body already parsed') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
req.body = req.body || {} |
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!typeis.hasBody(req)) { |
||||||
|
debug('skip empty body') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type']) |
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!shouldParse(req)) { |
||||||
|
debug('skip parsing') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// assert charset per RFC 7159 sec 8.1
|
||||||
|
var charset = getCharset(req) || 'utf-8' |
||||||
|
if (charset.slice(0, 4) !== 'utf-') { |
||||||
|
debug('invalid charset') |
||||||
|
next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', { |
||||||
|
charset: charset, |
||||||
|
type: 'charset.unsupported' |
||||||
|
})) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// read
|
||||||
|
read(req, res, next, parse, debug, { |
||||||
|
encoding: charset, |
||||||
|
inflate: inflate, |
||||||
|
limit: limit, |
||||||
|
verify: verify |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Create strict violation syntax error matching native error. |
||||||
|
* |
||||||
|
* @param {string} str |
||||||
|
* @param {string} char |
||||||
|
* @return {Error} |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function createStrictSyntaxError (str, char) { |
||||||
|
var index = str.indexOf(char) |
||||||
|
var partial = '' |
||||||
|
|
||||||
|
if (index !== -1) { |
||||||
|
partial = str.substring(0, index) + JSON_SYNTAX_CHAR |
||||||
|
|
||||||
|
for (var i = index + 1; i < str.length; i++) { |
||||||
|
partial += JSON_SYNTAX_CHAR |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation') |
||||||
|
} catch (e) { |
||||||
|
return normalizeJsonSyntaxError(e, { |
||||||
|
message: e.message.replace(JSON_SYNTAX_REGEXP, function (placeholder) { |
||||||
|
return str.substring(index, index + placeholder.length) |
||||||
|
}), |
||||||
|
stack: e.stack |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the first non-whitespace character in a string. |
||||||
|
* |
||||||
|
* @param {string} str |
||||||
|
* @return {function} |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function firstchar (str) { |
||||||
|
var match = FIRST_CHAR_REGEXP.exec(str) |
||||||
|
|
||||||
|
return match |
||||||
|
? match[1] |
||||||
|
: undefined |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the charset of a request. |
||||||
|
* |
||||||
|
* @param {object} req |
||||||
|
* @api private |
||||||
|
*/ |
||||||
|
|
||||||
|
function getCharset (req) { |
||||||
|
try { |
||||||
|
return (contentType.parse(req).parameters.charset || '').toLowerCase() |
||||||
|
} catch (e) { |
||||||
|
return undefined |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Normalize a SyntaxError for JSON.parse. |
||||||
|
* |
||||||
|
* @param {SyntaxError} error |
||||||
|
* @param {object} obj |
||||||
|
* @return {SyntaxError} |
||||||
|
*/ |
||||||
|
|
||||||
|
function normalizeJsonSyntaxError (error, obj) { |
||||||
|
var keys = Object.getOwnPropertyNames(error) |
||||||
|
|
||||||
|
for (var i = 0; i < keys.length; i++) { |
||||||
|
var key = keys[i] |
||||||
|
if (key !== 'stack' && key !== 'message') { |
||||||
|
delete error[key] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// replace stack before message for Node.js 0.10 and below
|
||||||
|
error.stack = obj.stack.replace(error.message, obj.message) |
||||||
|
error.message = obj.message |
||||||
|
|
||||||
|
return error |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the simple type checker. |
||||||
|
* |
||||||
|
* @param {string} type |
||||||
|
* @return {function} |
||||||
|
*/ |
||||||
|
|
||||||
|
function typeChecker (type) { |
||||||
|
return function checkType (req) { |
||||||
|
return Boolean(typeis(req, type)) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,101 @@ |
|||||||
|
/*! |
||||||
|
* body-parser |
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Module dependencies. |
||||||
|
*/ |
||||||
|
|
||||||
|
var bytes = require('bytes') |
||||||
|
var debug = require('debug')('body-parser:raw') |
||||||
|
var read = require('../read') |
||||||
|
var typeis = require('type-is') |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
*/ |
||||||
|
|
||||||
|
module.exports = raw |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a middleware to parse raw bodies. |
||||||
|
* |
||||||
|
* @param {object} [options] |
||||||
|
* @return {function} |
||||||
|
* @api public |
||||||
|
*/ |
||||||
|
|
||||||
|
function raw (options) { |
||||||
|
var opts = options || {} |
||||||
|
|
||||||
|
var inflate = opts.inflate !== false |
||||||
|
var limit = typeof opts.limit !== 'number' |
||||||
|
? bytes.parse(opts.limit || '100kb') |
||||||
|
: opts.limit |
||||||
|
var type = opts.type || 'application/octet-stream' |
||||||
|
var verify = opts.verify || false |
||||||
|
|
||||||
|
if (verify !== false && typeof verify !== 'function') { |
||||||
|
throw new TypeError('option verify must be function') |
||||||
|
} |
||||||
|
|
||||||
|
// create the appropriate type checking function
|
||||||
|
var shouldParse = typeof type !== 'function' |
||||||
|
? typeChecker(type) |
||||||
|
: type |
||||||
|
|
||||||
|
function parse (buf) { |
||||||
|
return buf |
||||||
|
} |
||||||
|
|
||||||
|
return function rawParser (req, res, next) { |
||||||
|
if (req._body) { |
||||||
|
debug('body already parsed') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
req.body = req.body || {} |
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!typeis.hasBody(req)) { |
||||||
|
debug('skip empty body') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type']) |
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!shouldParse(req)) { |
||||||
|
debug('skip parsing') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// read
|
||||||
|
read(req, res, next, parse, debug, { |
||||||
|
encoding: null, |
||||||
|
inflate: inflate, |
||||||
|
limit: limit, |
||||||
|
verify: verify |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the simple type checker. |
||||||
|
* |
||||||
|
* @param {string} type |
||||||
|
* @return {function} |
||||||
|
*/ |
||||||
|
|
||||||
|
function typeChecker (type) { |
||||||
|
return function checkType (req) { |
||||||
|
return Boolean(typeis(req, type)) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,121 @@ |
|||||||
|
/*! |
||||||
|
* body-parser |
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Module dependencies. |
||||||
|
*/ |
||||||
|
|
||||||
|
var bytes = require('bytes') |
||||||
|
var contentType = require('content-type') |
||||||
|
var debug = require('debug')('body-parser:text') |
||||||
|
var read = require('../read') |
||||||
|
var typeis = require('type-is') |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
*/ |
||||||
|
|
||||||
|
module.exports = text |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a middleware to parse text bodies. |
||||||
|
* |
||||||
|
* @param {object} [options] |
||||||
|
* @return {function} |
||||||
|
* @api public |
||||||
|
*/ |
||||||
|
|
||||||
|
function text (options) { |
||||||
|
var opts = options || {} |
||||||
|
|
||||||
|
var defaultCharset = opts.defaultCharset || 'utf-8' |
||||||
|
var inflate = opts.inflate !== false |
||||||
|
var limit = typeof opts.limit !== 'number' |
||||||
|
? bytes.parse(opts.limit || '100kb') |
||||||
|
: opts.limit |
||||||
|
var type = opts.type || 'text/plain' |
||||||
|
var verify = opts.verify || false |
||||||
|
|
||||||
|
if (verify !== false && typeof verify !== 'function') { |
||||||
|
throw new TypeError('option verify must be function') |
||||||
|
} |
||||||
|
|
||||||
|
// create the appropriate type checking function
|
||||||
|
var shouldParse = typeof type !== 'function' |
||||||
|
? typeChecker(type) |
||||||
|
: type |
||||||
|
|
||||||
|
function parse (buf) { |
||||||
|
return buf |
||||||
|
} |
||||||
|
|
||||||
|
return function textParser (req, res, next) { |
||||||
|
if (req._body) { |
||||||
|
debug('body already parsed') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
req.body = req.body || {} |
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!typeis.hasBody(req)) { |
||||||
|
debug('skip empty body') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type']) |
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!shouldParse(req)) { |
||||||
|
debug('skip parsing') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// get charset
|
||||||
|
var charset = getCharset(req) || defaultCharset |
||||||
|
|
||||||
|
// read
|
||||||
|
read(req, res, next, parse, debug, { |
||||||
|
encoding: charset, |
||||||
|
inflate: inflate, |
||||||
|
limit: limit, |
||||||
|
verify: verify |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the charset of a request. |
||||||
|
* |
||||||
|
* @param {object} req |
||||||
|
* @api private |
||||||
|
*/ |
||||||
|
|
||||||
|
function getCharset (req) { |
||||||
|
try { |
||||||
|
return (contentType.parse(req).parameters.charset || '').toLowerCase() |
||||||
|
} catch (e) { |
||||||
|
return undefined |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the simple type checker. |
||||||
|
* |
||||||
|
* @param {string} type |
||||||
|
* @return {function} |
||||||
|
*/ |
||||||
|
|
||||||
|
function typeChecker (type) { |
||||||
|
return function checkType (req) { |
||||||
|
return Boolean(typeis(req, type)) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,307 @@ |
|||||||
|
/*! |
||||||
|
* body-parser |
||||||
|
* Copyright(c) 2014 Jonathan Ong |
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Module dependencies. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
var bytes = require('bytes') |
||||||
|
var contentType = require('content-type') |
||||||
|
var createError = require('http-errors') |
||||||
|
var debug = require('debug')('body-parser:urlencoded') |
||||||
|
var deprecate = require('depd')('body-parser') |
||||||
|
var read = require('../read') |
||||||
|
var typeis = require('type-is') |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
*/ |
||||||
|
|
||||||
|
module.exports = urlencoded |
||||||
|
|
||||||
|
/** |
||||||
|
* Cache of parser modules. |
||||||
|
*/ |
||||||
|
|
||||||
|
var parsers = Object.create(null) |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a middleware to parse urlencoded bodies. |
||||||
|
* |
||||||
|
* @param {object} [options] |
||||||
|
* @return {function} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
function urlencoded (options) { |
||||||
|
var opts = options || {} |
||||||
|
|
||||||
|
// notice because option default will flip in next major
|
||||||
|
if (opts.extended === undefined) { |
||||||
|
deprecate('undefined extended: provide extended option') |
||||||
|
} |
||||||
|
|
||||||
|
var extended = opts.extended !== false |
||||||
|
var inflate = opts.inflate !== false |
||||||
|
var limit = typeof opts.limit !== 'number' |
||||||
|
? bytes.parse(opts.limit || '100kb') |
||||||
|
: opts.limit |
||||||
|
var type = opts.type || 'application/x-www-form-urlencoded' |
||||||
|
var verify = opts.verify || false |
||||||
|
var depth = typeof opts.depth !== 'number' |
||||||
|
? Number(opts.depth || 32) |
||||||
|
: opts.depth |
||||||
|
|
||||||
|
if (verify !== false && typeof verify !== 'function') { |
||||||
|
throw new TypeError('option verify must be function') |
||||||
|
} |
||||||
|
|
||||||
|
// create the appropriate query parser
|
||||||
|
var queryparse = extended |
||||||
|
? extendedparser(opts) |
||||||
|
: simpleparser(opts) |
||||||
|
|
||||||
|
// create the appropriate type checking function
|
||||||
|
var shouldParse = typeof type !== 'function' |
||||||
|
? typeChecker(type) |
||||||
|
: type |
||||||
|
|
||||||
|
function parse (body) { |
||||||
|
return body.length |
||||||
|
? queryparse(body) |
||||||
|
: {} |
||||||
|
} |
||||||
|
|
||||||
|
return function urlencodedParser (req, res, next) { |
||||||
|
if (req._body) { |
||||||
|
debug('body already parsed') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
req.body = req.body || {} |
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!typeis.hasBody(req)) { |
||||||
|
debug('skip empty body') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type']) |
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!shouldParse(req)) { |
||||||
|
debug('skip parsing') |
||||||
|
next() |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// assert charset
|
||||||
|
var charset = getCharset(req) || 'utf-8' |
||||||
|
if (charset !== 'utf-8') { |
||||||
|
debug('invalid charset') |
||||||
|
next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', { |
||||||
|
charset: charset, |
||||||
|
type: 'charset.unsupported' |
||||||
|
})) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// read
|
||||||
|
read(req, res, next, parse, debug, { |
||||||
|
debug: debug, |
||||||
|
encoding: charset, |
||||||
|
inflate: inflate, |
||||||
|
limit: limit, |
||||||
|
verify: verify, |
||||||
|
depth: depth |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the extended query parser. |
||||||
|
* |
||||||
|
* @param {object} options |
||||||
|
*/ |
||||||
|
|
||||||
|
function extendedparser (options) { |
||||||
|
var parameterLimit = options.parameterLimit !== undefined |
||||||
|
? options.parameterLimit |
||||||
|
: 1000 |
||||||
|
|
||||||
|
var depth = typeof options.depth !== 'number' |
||||||
|
? Number(options.depth || 32) |
||||||
|
: options.depth |
||||||
|
var parse = parser('qs') |
||||||
|
|
||||||
|
if (isNaN(parameterLimit) || parameterLimit < 1) { |
||||||
|
throw new TypeError('option parameterLimit must be a positive number') |
||||||
|
} |
||||||
|
|
||||||
|
if (isNaN(depth) || depth < 0) { |
||||||
|
throw new TypeError('option depth must be a zero or a positive number') |
||||||
|
} |
||||||
|
|
||||||
|
if (isFinite(parameterLimit)) { |
||||||
|
parameterLimit = parameterLimit | 0 |
||||||
|
} |
||||||
|
|
||||||
|
return function queryparse (body) { |
||||||
|
var paramCount = parameterCount(body, parameterLimit) |
||||||
|
|
||||||
|
if (paramCount === undefined) { |
||||||
|
debug('too many parameters') |
||||||
|
throw createError(413, 'too many parameters', { |
||||||
|
type: 'parameters.too.many' |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
var arrayLimit = Math.max(100, paramCount) |
||||||
|
|
||||||
|
debug('parse extended urlencoding') |
||||||
|
try { |
||||||
|
return parse(body, { |
||||||
|
allowPrototypes: true, |
||||||
|
arrayLimit: arrayLimit, |
||||||
|
depth: depth, |
||||||
|
strictDepth: true, |
||||||
|
parameterLimit: parameterLimit |
||||||
|
}) |
||||||
|
} catch (err) { |
||||||
|
if (err instanceof RangeError) { |
||||||
|
throw createError(400, 'The input exceeded the depth', { |
||||||
|
type: 'querystring.parse.rangeError' |
||||||
|
}) |
||||||
|
} else { |
||||||
|
throw err |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the charset of a request. |
||||||
|
* |
||||||
|
* @param {object} req |
||||||
|
* @api private |
||||||
|
*/ |
||||||
|
|
||||||
|
function getCharset (req) { |
||||||
|
try { |
||||||
|
return (contentType.parse(req).parameters.charset || '').toLowerCase() |
||||||
|
} catch (e) { |
||||||
|
return undefined |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Count the number of parameters, stopping once limit reached |
||||||
|
* |
||||||
|
* @param {string} body |
||||||
|
* @param {number} limit |
||||||
|
* @api private |
||||||
|
*/ |
||||||
|
|
||||||
|
function parameterCount (body, limit) { |
||||||
|
var count = 0 |
||||||
|
var index = 0 |
||||||
|
|
||||||
|
while ((index = body.indexOf('&', index)) !== -1) { |
||||||
|
count++ |
||||||
|
index++ |
||||||
|
|
||||||
|
if (count === limit) { |
||||||
|
return undefined |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return count |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get parser for module name dynamically. |
||||||
|
* |
||||||
|
* @param {string} name |
||||||
|
* @return {function} |
||||||
|
* @api private |
||||||
|
*/ |
||||||
|
|
||||||
|
function parser (name) { |
||||||
|
var mod = parsers[name] |
||||||
|
|
||||||
|
if (mod !== undefined) { |
||||||
|
return mod.parse |
||||||
|
} |
||||||
|
|
||||||
|
// this uses a switch for static require analysis
|
||||||
|
switch (name) { |
||||||
|
case 'qs': |
||||||
|
mod = require('qs') |
||||||
|
break |
||||||
|
case 'querystring': |
||||||
|
mod = require('querystring') |
||||||
|
break |
||||||
|
} |
||||||
|
|
||||||
|
// store to prevent invoking require()
|
||||||
|
parsers[name] = mod |
||||||
|
|
||||||
|
return mod.parse |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the simple query parser. |
||||||
|
* |
||||||
|
* @param {object} options |
||||||
|
*/ |
||||||
|
|
||||||
|
function simpleparser (options) { |
||||||
|
var parameterLimit = options.parameterLimit !== undefined |
||||||
|
? options.parameterLimit |
||||||
|
: 1000 |
||||||
|
var parse = parser('querystring') |
||||||
|
|
||||||
|
if (isNaN(parameterLimit) || parameterLimit < 1) { |
||||||
|
throw new TypeError('option parameterLimit must be a positive number') |
||||||
|
} |
||||||
|
|
||||||
|
if (isFinite(parameterLimit)) { |
||||||
|
parameterLimit = parameterLimit | 0 |
||||||
|
} |
||||||
|
|
||||||
|
return function queryparse (body) { |
||||||
|
var paramCount = parameterCount(body, parameterLimit) |
||||||
|
|
||||||
|
if (paramCount === undefined) { |
||||||
|
debug('too many parameters') |
||||||
|
throw createError(413, 'too many parameters', { |
||||||
|
type: 'parameters.too.many' |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
debug('parse urlencoding') |
||||||
|
return parse(body, undefined, undefined, { maxKeys: parameterLimit }) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the simple type checker. |
||||||
|
* |
||||||
|
* @param {string} type |
||||||
|
* @return {function} |
||||||
|
*/ |
||||||
|
|
||||||
|
function typeChecker (type) { |
||||||
|
return function checkType (req) { |
||||||
|
return Boolean(typeis(req, type)) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
{ |
||||||
|
"name": "body-parser", |
||||||
|
"description": "Node.js body parsing middleware", |
||||||
|
"version": "1.20.3", |
||||||
|
"contributors": [ |
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>", |
||||||
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)" |
||||||
|
], |
||||||
|
"license": "MIT", |
||||||
|
"repository": "expressjs/body-parser", |
||||||
|
"dependencies": { |
||||||
|
"bytes": "3.1.2", |
||||||
|
"content-type": "~1.0.5", |
||||||
|
"debug": "2.6.9", |
||||||
|
"depd": "2.0.0", |
||||||
|
"destroy": "1.2.0", |
||||||
|
"http-errors": "2.0.0", |
||||||
|
"iconv-lite": "0.4.24", |
||||||
|
"on-finished": "2.4.1", |
||||||
|
"qs": "6.13.0", |
||||||
|
"raw-body": "2.5.2", |
||||||
|
"type-is": "~1.6.18", |
||||||
|
"unpipe": "1.0.0" |
||||||
|
}, |
||||||
|
"devDependencies": { |
||||||
|
"eslint": "8.34.0", |
||||||
|
"eslint-config-standard": "14.1.1", |
||||||
|
"eslint-plugin-import": "2.27.5", |
||||||
|
"eslint-plugin-markdown": "3.0.0", |
||||||
|
"eslint-plugin-node": "11.1.0", |
||||||
|
"eslint-plugin-promise": "6.1.1", |
||||||
|
"eslint-plugin-standard": "4.1.0", |
||||||
|
"methods": "1.1.2", |
||||||
|
"mocha": "10.2.0", |
||||||
|
"nyc": "15.1.0", |
||||||
|
"safe-buffer": "5.2.1", |
||||||
|
"supertest": "6.3.3" |
||||||
|
}, |
||||||
|
"files": [ |
||||||
|
"lib/", |
||||||
|
"LICENSE", |
||||||
|
"HISTORY.md", |
||||||
|
"SECURITY.md", |
||||||
|
"index.js" |
||||||
|
], |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8", |
||||||
|
"npm": "1.2.8000 || >= 1.4.16" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"lint": "eslint .", |
||||||
|
"test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/", |
||||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test", |
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,97 @@ |
|||||||
|
3.1.2 / 2022-01-27 |
||||||
|
================== |
||||||
|
|
||||||
|
* Fix return value for un-parsable strings |
||||||
|
|
||||||
|
3.1.1 / 2021-11-15 |
||||||
|
================== |
||||||
|
|
||||||
|
* Fix "thousandsSeparator" incorrecting formatting fractional part |
||||||
|
|
||||||
|
3.1.0 / 2019-01-22 |
||||||
|
================== |
||||||
|
|
||||||
|
* Add petabyte (`pb`) support |
||||||
|
|
||||||
|
3.0.0 / 2017-08-31 |
||||||
|
================== |
||||||
|
|
||||||
|
* Change "kB" to "KB" in format output |
||||||
|
* Remove support for Node.js 0.6 |
||||||
|
* Remove support for ComponentJS |
||||||
|
|
||||||
|
2.5.0 / 2017-03-24 |
||||||
|
================== |
||||||
|
|
||||||
|
* Add option "unit" |
||||||
|
|
||||||
|
2.4.0 / 2016-06-01 |
||||||
|
================== |
||||||
|
|
||||||
|
* Add option "unitSeparator" |
||||||
|
|
||||||
|
2.3.0 / 2016-02-15 |
||||||
|
================== |
||||||
|
|
||||||
|
* Drop partial bytes on all parsed units |
||||||
|
* Fix non-finite numbers to `.format` to return `null` |
||||||
|
* Fix parsing byte string that looks like hex |
||||||
|
* perf: hoist regular expressions |
||||||
|
|
||||||
|
2.2.0 / 2015-11-13 |
||||||
|
================== |
||||||
|
|
||||||
|
* add option "decimalPlaces" |
||||||
|
* add option "fixedDecimals" |
||||||
|
|
||||||
|
2.1.0 / 2015-05-21 |
||||||
|
================== |
||||||
|
|
||||||
|
* add `.format` export |
||||||
|
* add `.parse` export |
||||||
|
|
||||||
|
2.0.2 / 2015-05-20 |
||||||
|
================== |
||||||
|
|
||||||
|
* remove map recreation |
||||||
|
* remove unnecessary object construction |
||||||
|
|
||||||
|
2.0.1 / 2015-05-07 |
||||||
|
================== |
||||||
|
|
||||||
|
* fix browserify require |
||||||
|
* remove node.extend dependency |
||||||
|
|
||||||
|
2.0.0 / 2015-04-12 |
||||||
|
================== |
||||||
|
|
||||||
|
* add option "case" |
||||||
|
* add option "thousandsSeparator" |
||||||
|
* return "null" on invalid parse input |
||||||
|
* support proper round-trip: bytes(bytes(num)) === num |
||||||
|
* units no longer case sensitive when parsing |
||||||
|
|
||||||
|
1.0.0 / 2014-05-05 |
||||||
|
================== |
||||||
|
|
||||||
|
* add negative support. fixes #6 |
||||||
|
|
||||||
|
0.3.0 / 2014-03-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* added terabyte support |
||||||
|
|
||||||
|
0.2.1 / 2013-04-01 |
||||||
|
================== |
||||||
|
|
||||||
|
* add .component |
||||||
|
|
||||||
|
0.2.0 / 2012-10-28 |
||||||
|
================== |
||||||
|
|
||||||
|
* bytes(200).should.eql('200b') |
||||||
|
|
||||||
|
0.1.0 / 2012-07-04 |
||||||
|
================== |
||||||
|
|
||||||
|
* add bytes to string conversion [yields] |
@ -0,0 +1,23 @@ |
|||||||
|
(The MIT License) |
||||||
|
|
||||||
|
Copyright (c) 2012-2014 TJ Holowaychuk <tj@vision-media.ca> |
||||||
|
Copyright (c) 2015 Jed Watson <jed.watson@me.com> |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining |
||||||
|
a copy of this software and associated documentation files (the |
||||||
|
'Software'), to deal in the Software without restriction, including |
||||||
|
without limitation the rights to use, copy, modify, merge, publish, |
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to |
||||||
|
permit persons to whom the Software is furnished to do so, subject to |
||||||
|
the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be |
||||||
|
included in all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,152 @@ |
|||||||
|
# Bytes utility |
||||||
|
|
||||||
|
[![NPM Version][npm-image]][npm-url] |
||||||
|
[![NPM Downloads][downloads-image]][downloads-url] |
||||||
|
[![Build Status][ci-image]][ci-url] |
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url] |
||||||
|
|
||||||
|
Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa. |
||||||
|
|
||||||
|
## Installation |
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the |
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the |
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): |
||||||
|
|
||||||
|
```bash |
||||||
|
$ npm install bytes |
||||||
|
``` |
||||||
|
|
||||||
|
## Usage |
||||||
|
|
||||||
|
```js |
||||||
|
var bytes = require('bytes'); |
||||||
|
``` |
||||||
|
|
||||||
|
#### bytes(number|string value, [options]): number|string|null |
||||||
|
|
||||||
|
Default export function. Delegates to either `bytes.format` or `bytes.parse` based on the type of `value`. |
||||||
|
|
||||||
|
**Arguments** |
||||||
|
|
||||||
|
| Name | Type | Description | |
||||||
|
|---------|----------|--------------------| |
||||||
|
| value | `number`|`string` | Number value to format or string value to parse | |
||||||
|
| options | `Object` | Conversion options for `format` | |
||||||
|
|
||||||
|
**Returns** |
||||||
|
|
||||||
|
| Name | Type | Description | |
||||||
|
|---------|------------------|-------------------------------------------------| |
||||||
|
| results | `string`|`number`|`null` | Return null upon error. Numeric value in bytes, or string value otherwise. | |
||||||
|
|
||||||
|
**Example** |
||||||
|
|
||||||
|
```js |
||||||
|
bytes(1024); |
||||||
|
// output: '1KB' |
||||||
|
|
||||||
|
bytes('1KB'); |
||||||
|
// output: 1024 |
||||||
|
``` |
||||||
|
|
||||||
|
#### bytes.format(number value, [options]): string|null |
||||||
|
|
||||||
|
Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is |
||||||
|
rounded. |
||||||
|
|
||||||
|
**Arguments** |
||||||
|
|
||||||
|
| Name | Type | Description | |
||||||
|
|---------|----------|--------------------| |
||||||
|
| value | `number` | Value in bytes | |
||||||
|
| options | `Object` | Conversion options | |
||||||
|
|
||||||
|
**Options** |
||||||
|
|
||||||
|
| Property | Type | Description | |
||||||
|
|-------------------|--------|-----------------------------------------------------------------------------------------| |
||||||
|
| decimalPlaces | `number`|`null` | Maximum number of decimal places to include in output. Default value to `2`. | |
||||||
|
| fixedDecimals | `boolean`|`null` | Whether to always display the maximum number of decimal places. Default value to `false` | |
||||||
|
| thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `'.'`... Default value to `''`. | |
||||||
|
| unit | `string`|`null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). | |
||||||
|
| unitSeparator | `string`|`null` | Separator to use between number and unit. Default value to `''`. | |
||||||
|
|
||||||
|
**Returns** |
||||||
|
|
||||||
|
| Name | Type | Description | |
||||||
|
|---------|------------------|-------------------------------------------------| |
||||||
|
| results | `string`|`null` | Return null upon error. String value otherwise. | |
||||||
|
|
||||||
|
**Example** |
||||||
|
|
||||||
|
```js |
||||||
|
bytes.format(1024); |
||||||
|
// output: '1KB' |
||||||
|
|
||||||
|
bytes.format(1000); |
||||||
|
// output: '1000B' |
||||||
|
|
||||||
|
bytes.format(1000, {thousandsSeparator: ' '}); |
||||||
|
// output: '1 000B' |
||||||
|
|
||||||
|
bytes.format(1024 * 1.7, {decimalPlaces: 0}); |
||||||
|
// output: '2KB' |
||||||
|
|
||||||
|
bytes.format(1024, {unitSeparator: ' '}); |
||||||
|
// output: '1 KB' |
||||||
|
``` |
||||||
|
|
||||||
|
#### bytes.parse(string|number value): number|null |
||||||
|
|
||||||
|
Parse the string value into an integer in bytes. If no unit is given, or `value` |
||||||
|
is a number, it is assumed the value is in bytes. |
||||||
|
|
||||||
|
Supported units and abbreviations are as follows and are case-insensitive: |
||||||
|
|
||||||
|
* `b` for bytes |
||||||
|
* `kb` for kilobytes |
||||||
|
* `mb` for megabytes |
||||||
|
* `gb` for gigabytes |
||||||
|
* `tb` for terabytes |
||||||
|
* `pb` for petabytes |
||||||
|
|
||||||
|
The units are in powers of two, not ten. This means 1kb = 1024b according to this parser. |
||||||
|
|
||||||
|
**Arguments** |
||||||
|
|
||||||
|
| Name | Type | Description | |
||||||
|
|---------------|--------|--------------------| |
||||||
|
| value | `string`|`number` | String to parse, or number in bytes. | |
||||||
|
|
||||||
|
**Returns** |
||||||
|
|
||||||
|
| Name | Type | Description | |
||||||
|
|---------|-------------|-------------------------| |
||||||
|
| results | `number`|`null` | Return null upon error. Value in bytes otherwise. | |
||||||
|
|
||||||
|
**Example** |
||||||
|
|
||||||
|
```js |
||||||
|
bytes.parse('1KB'); |
||||||
|
// output: 1024 |
||||||
|
|
||||||
|
bytes.parse('1024'); |
||||||
|
// output: 1024 |
||||||
|
|
||||||
|
bytes.parse(1024); |
||||||
|
// output: 1024 |
||||||
|
``` |
||||||
|
|
||||||
|
## License |
||||||
|
|
||||||
|
[MIT](LICENSE) |
||||||
|
|
||||||
|
[ci-image]: https://badgen.net/github/checks/visionmedia/bytes.js/master?label=ci |
||||||
|
[ci-url]: https://github.com/visionmedia/bytes.js/actions?query=workflow%3Aci |
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master |
||||||
|
[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master |
||||||
|
[downloads-image]: https://badgen.net/npm/dm/bytes |
||||||
|
[downloads-url]: https://npmjs.org/package/bytes |
||||||
|
[npm-image]: https://badgen.net/npm/v/bytes |
||||||
|
[npm-url]: https://npmjs.org/package/bytes |
@ -0,0 +1,170 @@ |
|||||||
|
/*! |
||||||
|
* bytes |
||||||
|
* Copyright(c) 2012-2014 TJ Holowaychuk |
||||||
|
* Copyright(c) 2015 Jed Watson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
module.exports = bytes; |
||||||
|
module.exports.format = format; |
||||||
|
module.exports.parse = parse; |
||||||
|
|
||||||
|
/** |
||||||
|
* Module variables. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g; |
||||||
|
|
||||||
|
var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/; |
||||||
|
|
||||||
|
var map = { |
||||||
|
b: 1, |
||||||
|
kb: 1 << 10, |
||||||
|
mb: 1 << 20, |
||||||
|
gb: 1 << 30, |
||||||
|
tb: Math.pow(1024, 4), |
||||||
|
pb: Math.pow(1024, 5), |
||||||
|
}; |
||||||
|
|
||||||
|
var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i; |
||||||
|
|
||||||
|
/** |
||||||
|
* Convert the given value in bytes into a string or parse to string to an integer in bytes. |
||||||
|
* |
||||||
|
* @param {string|number} value |
||||||
|
* @param {{ |
||||||
|
* case: [string], |
||||||
|
* decimalPlaces: [number] |
||||||
|
* fixedDecimals: [boolean] |
||||||
|
* thousandsSeparator: [string] |
||||||
|
* unitSeparator: [string] |
||||||
|
* }} [options] bytes options. |
||||||
|
* |
||||||
|
* @returns {string|number|null} |
||||||
|
*/ |
||||||
|
|
||||||
|
function bytes(value, options) { |
||||||
|
if (typeof value === 'string') { |
||||||
|
return parse(value); |
||||||
|
} |
||||||
|
|
||||||
|
if (typeof value === 'number') { |
||||||
|
return format(value, options); |
||||||
|
} |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Format the given value in bytes into a string. |
||||||
|
* |
||||||
|
* If the value is negative, it is kept as such. If it is a float, |
||||||
|
* it is rounded. |
||||||
|
* |
||||||
|
* @param {number} value |
||||||
|
* @param {object} [options] |
||||||
|
* @param {number} [options.decimalPlaces=2] |
||||||
|
* @param {number} [options.fixedDecimals=false] |
||||||
|
* @param {string} [options.thousandsSeparator=] |
||||||
|
* @param {string} [options.unit=] |
||||||
|
* @param {string} [options.unitSeparator=] |
||||||
|
* |
||||||
|
* @returns {string|null} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
function format(value, options) { |
||||||
|
if (!Number.isFinite(value)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
var mag = Math.abs(value); |
||||||
|
var thousandsSeparator = (options && options.thousandsSeparator) || ''; |
||||||
|
var unitSeparator = (options && options.unitSeparator) || ''; |
||||||
|
var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2; |
||||||
|
var fixedDecimals = Boolean(options && options.fixedDecimals); |
||||||
|
var unit = (options && options.unit) || ''; |
||||||
|
|
||||||
|
if (!unit || !map[unit.toLowerCase()]) { |
||||||
|
if (mag >= map.pb) { |
||||||
|
unit = 'PB'; |
||||||
|
} else if (mag >= map.tb) { |
||||||
|
unit = 'TB'; |
||||||
|
} else if (mag >= map.gb) { |
||||||
|
unit = 'GB'; |
||||||
|
} else if (mag >= map.mb) { |
||||||
|
unit = 'MB'; |
||||||
|
} else if (mag >= map.kb) { |
||||||
|
unit = 'KB'; |
||||||
|
} else { |
||||||
|
unit = 'B'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
var val = value / map[unit.toLowerCase()]; |
||||||
|
var str = val.toFixed(decimalPlaces); |
||||||
|
|
||||||
|
if (!fixedDecimals) { |
||||||
|
str = str.replace(formatDecimalsRegExp, '$1'); |
||||||
|
} |
||||||
|
|
||||||
|
if (thousandsSeparator) { |
||||||
|
str = str.split('.').map(function (s, i) { |
||||||
|
return i === 0 |
||||||
|
? s.replace(formatThousandsRegExp, thousandsSeparator) |
||||||
|
: s |
||||||
|
}).join('.'); |
||||||
|
} |
||||||
|
|
||||||
|
return str + unitSeparator + unit; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Parse the string value into an integer in bytes. |
||||||
|
* |
||||||
|
* If no unit is given, it is assumed the value is in bytes. |
||||||
|
* |
||||||
|
* @param {number|string} val |
||||||
|
* |
||||||
|
* @returns {number|null} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
function parse(val) { |
||||||
|
if (typeof val === 'number' && !isNaN(val)) { |
||||||
|
return val; |
||||||
|
} |
||||||
|
|
||||||
|
if (typeof val !== 'string') { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
// Test if the string passed is valid
|
||||||
|
var results = parseRegExp.exec(val); |
||||||
|
var floatValue; |
||||||
|
var unit = 'b'; |
||||||
|
|
||||||
|
if (!results) { |
||||||
|
// Nothing could be extracted from the given string
|
||||||
|
floatValue = parseInt(val, 10); |
||||||
|
unit = 'b' |
||||||
|
} else { |
||||||
|
// Retrieve the value and the unit
|
||||||
|
floatValue = parseFloat(results[1]); |
||||||
|
unit = results[4].toLowerCase(); |
||||||
|
} |
||||||
|
|
||||||
|
if (isNaN(floatValue)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
return Math.floor(map[unit] * floatValue); |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
{ |
||||||
|
"name": "bytes", |
||||||
|
"description": "Utility to parse a string bytes to bytes and vice-versa", |
||||||
|
"version": "3.1.2", |
||||||
|
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)", |
||||||
|
"contributors": [ |
||||||
|
"Jed Watson <jed.watson@me.com>", |
||||||
|
"Théo FIDRY <theo.fidry@gmail.com>" |
||||||
|
], |
||||||
|
"license": "MIT", |
||||||
|
"keywords": [ |
||||||
|
"byte", |
||||||
|
"bytes", |
||||||
|
"utility", |
||||||
|
"parse", |
||||||
|
"parser", |
||||||
|
"convert", |
||||||
|
"converter" |
||||||
|
], |
||||||
|
"repository": "visionmedia/bytes.js", |
||||||
|
"devDependencies": { |
||||||
|
"eslint": "7.32.0", |
||||||
|
"eslint-plugin-markdown": "2.2.1", |
||||||
|
"mocha": "9.2.0", |
||||||
|
"nyc": "15.1.0" |
||||||
|
}, |
||||||
|
"files": [ |
||||||
|
"History.md", |
||||||
|
"LICENSE", |
||||||
|
"Readme.md", |
||||||
|
"index.js" |
||||||
|
], |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.8" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"lint": "eslint .", |
||||||
|
"test": "mocha --check-leaks --reporter spec", |
||||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test", |
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
{ |
||||||
|
"root": true, |
||||||
|
|
||||||
|
"extends": "@ljharb", |
||||||
|
|
||||||
|
"rules": { |
||||||
|
"func-name-matching": 0, |
||||||
|
"id-length": 0, |
||||||
|
"new-cap": [2, { |
||||||
|
"capIsNewExceptions": [ |
||||||
|
"GetIntrinsic", |
||||||
|
], |
||||||
|
}], |
||||||
|
"no-magic-numbers": 0, |
||||||
|
}, |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
# These are supported funding model platforms |
||||||
|
|
||||||
|
github: [ljharb] |
||||||
|
patreon: # Replace with a single Patreon username |
||||||
|
open_collective: # Replace with a single Open Collective username |
||||||
|
ko_fi: # Replace with a single Ko-fi username |
||||||
|
tidelift: npm/call-bind-apply-helpers |
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry |
||||||
|
liberapay: # Replace with a single Liberapay username |
||||||
|
issuehunt: # Replace with a single IssueHunt username |
||||||
|
otechie: # Replace with a single Otechie username |
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
@ -0,0 +1,9 @@ |
|||||||
|
{ |
||||||
|
"all": true, |
||||||
|
"check-coverage": false, |
||||||
|
"reporter": ["text-summary", "text", "html", "json"], |
||||||
|
"exclude": [ |
||||||
|
"coverage", |
||||||
|
"test" |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
# Changelog |
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file. |
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) |
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
||||||
|
|
||||||
|
## [v1.0.1](https://github.com/ljharb/call-bind-apply-helpers/compare/v1.0.0...v1.0.1) - 2024-12-08 |
||||||
|
|
||||||
|
### Commits |
||||||
|
|
||||||
|
- [types] `reflectApply`: fix types [`4efc396`](https://github.com/ljharb/call-bind-apply-helpers/commit/4efc3965351a4f02cc55e836fa391d3d11ef2ef8) |
||||||
|
- [Fix] `reflectApply`: oops, Reflect is not a function [`83cc739`](https://github.com/ljharb/call-bind-apply-helpers/commit/83cc7395de6b79b7730bdf092f1436f0b1263c75) |
||||||
|
- [Dev Deps] update `@arethetypeswrong/cli` [`80bd5d3`](https://github.com/ljharb/call-bind-apply-helpers/commit/80bd5d3ae58b4f6b6995ce439dd5a1bcb178a940) |
||||||
|
|
||||||
|
## v1.0.0 - 2024-12-05 |
||||||
|
|
||||||
|
### Commits |
||||||
|
|
||||||
|
- Initial implementation, tests, readme [`7879629`](https://github.com/ljharb/call-bind-apply-helpers/commit/78796290f9b7430c9934d6f33d94ae9bc89fce04) |
||||||
|
- Initial commit [`3f1dc16`](https://github.com/ljharb/call-bind-apply-helpers/commit/3f1dc164afc43285631b114a5f9dd9137b2b952f) |
||||||
|
- npm init [`081df04`](https://github.com/ljharb/call-bind-apply-helpers/commit/081df048c312fcee400922026f6e97281200a603) |
||||||
|
- Only apps should have lockfiles [`5b9ca0f`](https://github.com/ljharb/call-bind-apply-helpers/commit/5b9ca0fe8101ebfaf309c549caac4e0a017ed930) |
@ -0,0 +1,21 @@ |
|||||||
|
MIT License |
||||||
|
|
||||||
|
Copyright (c) 2024 Jordan Harband |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||||
|
SOFTWARE. |
@ -0,0 +1,62 @@ |
|||||||
|
# call-bind-apply-helpers <sup>[![Version Badge][npm-version-svg]][package-url]</sup> |
||||||
|
|
||||||
|
[![github actions][actions-image]][actions-url] |
||||||
|
[![coverage][codecov-image]][codecov-url] |
||||||
|
[![dependency status][deps-svg]][deps-url] |
||||||
|
[![dev dependency status][dev-deps-svg]][dev-deps-url] |
||||||
|
[![License][license-image]][license-url] |
||||||
|
[![Downloads][downloads-image]][downloads-url] |
||||||
|
|
||||||
|
[![npm badge][npm-badge-png]][package-url] |
||||||
|
|
||||||
|
Helper functions around Function call/apply/bind, for use in `call-bind`. |
||||||
|
|
||||||
|
The only packages that should likely ever use this package directly are `call-bind` and `get-intrinsic`. |
||||||
|
Please use `call-bind` unless you have a very good reason not to. |
||||||
|
|
||||||
|
## Getting started |
||||||
|
|
||||||
|
```sh |
||||||
|
npm install --save call-bind-apply-helpers |
||||||
|
``` |
||||||
|
|
||||||
|
## Usage/Examples |
||||||
|
|
||||||
|
```js |
||||||
|
const assert = require('assert'); |
||||||
|
const callBindBasic = require('call-bind-apply-helpers'); |
||||||
|
|
||||||
|
function f(a, b) { |
||||||
|
assert.equal(this, 1); |
||||||
|
assert.equal(a, 2); |
||||||
|
assert.equal(b, 3); |
||||||
|
assert.equal(arguments.length, 2); |
||||||
|
} |
||||||
|
|
||||||
|
const fBound = callBindBasic([f, 1]); |
||||||
|
|
||||||
|
delete Function.prototype.call; |
||||||
|
delete Function.prototype.bind; |
||||||
|
|
||||||
|
fBound(2, 3); |
||||||
|
``` |
||||||
|
|
||||||
|
## Tests |
||||||
|
|
||||||
|
Clone the repo, `npm install`, and run `npm test` |
||||||
|
|
||||||
|
[package-url]: https://npmjs.org/package/call-bind-apply-helpers |
||||||
|
[npm-version-svg]: https://versionbadg.es/ljharb/call-bind-apply-helpers.svg |
||||||
|
[deps-svg]: https://david-dm.org/ljharb/call-bind-apply-helpers.svg |
||||||
|
[deps-url]: https://david-dm.org/ljharb/call-bind-apply-helpers |
||||||
|
[dev-deps-svg]: https://david-dm.org/ljharb/call-bind-apply-helpers/dev-status.svg |
||||||
|
[dev-deps-url]: https://david-dm.org/ljharb/call-bind-apply-helpers#info=devDependencies |
||||||
|
[npm-badge-png]: https://nodei.co/npm/call-bind-apply-helpers.png?downloads=true&stars=true |
||||||
|
[license-image]: https://img.shields.io/npm/l/call-bind-apply-helpers.svg |
||||||
|
[license-url]: LICENSE |
||||||
|
[downloads-image]: https://img.shields.io/npm/dm/call-bind-apply-helpers.svg |
||||||
|
[downloads-url]: https://npm-stat.com/charts.html?package=call-bind-apply-helpers |
||||||
|
[codecov-image]: https://codecov.io/gh/ljharb/call-bind-apply-helpers/branch/main/graphs/badge.svg |
||||||
|
[codecov-url]: https://app.codecov.io/gh/ljharb/call-bind-apply-helpers/ |
||||||
|
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/call-bind-apply-helpers |
||||||
|
[actions-url]: https://github.com/ljharb/call-bind-apply-helpers/actions |
@ -0,0 +1 @@ |
|||||||
|
export = Reflect.apply; |
@ -0,0 +1,10 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
var bind = require('function-bind'); |
||||||
|
|
||||||
|
var $apply = require('./functionApply'); |
||||||
|
var $call = require('./functionCall'); |
||||||
|
var $reflectApply = require('./reflectApply'); |
||||||
|
|
||||||
|
/** @type {import('./actualApply')} */ |
||||||
|
module.exports = $reflectApply || bind.call($call, $apply); |
@ -0,0 +1,19 @@ |
|||||||
|
import actualApply from './actualApply'; |
||||||
|
|
||||||
|
type TupleSplitHead<T extends any[], N extends number> = T['length'] extends N |
||||||
|
? T |
||||||
|
: T extends [...infer R, any] |
||||||
|
? TupleSplitHead<R, N> |
||||||
|
: never |
||||||
|
|
||||||
|
type TupleSplitTail<T, N extends number, O extends any[] = []> = O['length'] extends N |
||||||
|
? T |
||||||
|
: T extends [infer F, ...infer R] |
||||||
|
? TupleSplitTail<[...R], N, [...O, F]> |
||||||
|
: never |
||||||
|
|
||||||
|
type TupleSplit<T extends any[], N extends number> = [TupleSplitHead<T, N>, TupleSplitTail<T, N>] |
||||||
|
|
||||||
|
declare function applyBind(...args: TupleSplit<Parameters<typeof actualApply>, 2>[1]): ReturnType<typeof actualApply>; |
||||||
|
|
||||||
|
export = applyBind; |
@ -0,0 +1,10 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
var bind = require('function-bind'); |
||||||
|
var $apply = require('./functionApply'); |
||||||
|
var actualApply = require('./actualApply'); |
||||||
|
|
||||||
|
/** @type {import('./applyBind')} */ |
||||||
|
module.exports = function applyBind() { |
||||||
|
return actualApply(bind, $apply, arguments); |
||||||
|
}; |
@ -0,0 +1 @@ |
|||||||
|
export = Function.prototype.apply; |
@ -0,0 +1,4 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
/** @type {import('./functionApply')} */ |
||||||
|
module.exports = Function.prototype.apply; |
@ -0,0 +1 @@ |
|||||||
|
export = Function.prototype.call; |
@ -0,0 +1,4 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
/** @type {import('./functionCall')} */ |
||||||
|
module.exports = Function.prototype.call; |
@ -0,0 +1,46 @@ |
|||||||
|
type RemoveFromTuple< |
||||||
|
Tuple extends unknown[], |
||||||
|
RemoveCount extends number, |
||||||
|
Index extends 1[] = [] |
||||||
|
> = Index["length"] extends RemoveCount |
||||||
|
? Tuple |
||||||
|
: Tuple extends [first: unknown, ...infer Rest] |
||||||
|
? RemoveFromTuple<Rest, RemoveCount, [...Index, 1]> |
||||||
|
: Tuple; |
||||||
|
|
||||||
|
type ConcatTuples< |
||||||
|
Prefix extends unknown[], |
||||||
|
Suffix extends unknown[] |
||||||
|
> = [...Prefix, ...Suffix]; |
||||||
|
|
||||||
|
type ReplaceThis<T, NewThis> = T extends (this: infer OldThis, ...args: infer A) => infer R |
||||||
|
? (this: NewThis, ...args: A) => R |
||||||
|
: never; |
||||||
|
|
||||||
|
type BindFunction< |
||||||
|
TThis, |
||||||
|
T extends (this: TThis, ...args: any[]) => any, // Allow specific types to propagate
|
||||||
|
TBoundArgs extends unknown[], |
||||||
|
ReceiverBound extends boolean |
||||||
|
> = ReceiverBound extends true |
||||||
|
? (...args: RemoveFromTuple<Parameters<T>, TBoundArgs["length"] & number>) => ReturnType<ReplaceThis<T, TThis>> |
||||||
|
: (...args: ConcatTuples<[TThis], RemoveFromTuple<Parameters<T>, TBoundArgs["length"] & number>>) => ReturnType<T>; |
||||||
|
|
||||||
|
declare function callBind< |
||||||
|
TThis, |
||||||
|
T extends (this: TThis, ...args: any[]) => any, |
||||||
|
TBoundArgs extends Partial<Parameters<T>> |
||||||
|
>( |
||||||
|
args: [fn: T, thisArg: TThis, ...boundArgs: TBoundArgs] |
||||||
|
): BindFunction<TThis, T, TBoundArgs, true>; |
||||||
|
|
||||||
|
declare function callBind< |
||||||
|
TThis, |
||||||
|
T extends (this: TThis, ...args: any[]) => any, |
||||||
|
TBoundArgs extends Partial<Parameters<T>> |
||||||
|
>( |
||||||
|
args: [fn: T, ...boundArgs: TBoundArgs] |
||||||
|
): BindFunction<TThis, T, TBoundArgs, false>; |
||||||
|
|
||||||
|
export as namespace callBind; |
||||||
|
export = callBind; |
@ -0,0 +1,15 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
var bind = require('function-bind'); |
||||||
|
var $TypeError = require('es-errors/type'); |
||||||
|
|
||||||
|
var $call = require('./functionCall'); |
||||||
|
var $actualApply = require('./actualApply'); |
||||||
|
|
||||||
|
/** @type {import('.')} */ |
||||||
|
module.exports = function callBindBasic(args) { |
||||||
|
if (args.length < 1 || typeof args[0] !== 'function') { |
||||||
|
throw new $TypeError('a function is required'); |
||||||
|
} |
||||||
|
return $actualApply(bind, $call, args); |
||||||
|
}; |
@ -0,0 +1,85 @@ |
|||||||
|
{ |
||||||
|
"name": "call-bind-apply-helpers", |
||||||
|
"version": "1.0.1", |
||||||
|
"description": "Helper functions around Function call/apply/bind, for use in `call-bind`", |
||||||
|
"main": "index.js", |
||||||
|
"exports": { |
||||||
|
".": "./index.js", |
||||||
|
"./actualApply": "./actualApply.js", |
||||||
|
"./applyBind": "./applyBind.js", |
||||||
|
"./functionApply": "./functionApply.js", |
||||||
|
"./functionCall": "./functionCall.js", |
||||||
|
"./reflectApply": "./reflectApply.js", |
||||||
|
"./package.json": "./package.json" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"prepack": "npmignore --auto --commentLines=auto", |
||||||
|
"prepublish": "not-in-publish || npm run prepublishOnly", |
||||||
|
"prepublishOnly": "safe-publish-latest", |
||||||
|
"prelint": "evalmd README.md", |
||||||
|
"lint": "eslint --ext=.js,.mjs .", |
||||||
|
"postlint": "tsc -p . && attw -P", |
||||||
|
"pretest": "npm run lint", |
||||||
|
"tests-only": "nyc tape 'test/**/*.js'", |
||||||
|
"test": "npm run tests-only", |
||||||
|
"posttest": "npx npm@'>=10.2' audit --production", |
||||||
|
"version": "auto-changelog && git add CHANGELOG.md", |
||||||
|
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" |
||||||
|
}, |
||||||
|
"repository": { |
||||||
|
"type": "git", |
||||||
|
"url": "git+https://github.com/ljharb/call-bind-apply-helpers.git" |
||||||
|
}, |
||||||
|
"author": "Jordan Harband <ljharb@gmail.com>", |
||||||
|
"license": "MIT", |
||||||
|
"bugs": { |
||||||
|
"url": "https://github.com/ljharb/call-bind-apply-helpers/issues" |
||||||
|
}, |
||||||
|
"homepage": "https://github.com/ljharb/call-bind-apply-helpers#readme", |
||||||
|
"dependencies": { |
||||||
|
"es-errors": "^1.3.0", |
||||||
|
"function-bind": "^1.1.2" |
||||||
|
}, |
||||||
|
"devDependencies": { |
||||||
|
"@arethetypeswrong/cli": "^0.17.1", |
||||||
|
"@ljharb/eslint-config": "^21.1.1", |
||||||
|
"@ljharb/tsconfig": "^0.2.2", |
||||||
|
"@types/for-each": "^0.3.3", |
||||||
|
"@types/function-bind": "^1.1.10", |
||||||
|
"@types/object-inspect": "^1.13.0", |
||||||
|
"@types/tape": "^5.6.5", |
||||||
|
"auto-changelog": "^2.5.0", |
||||||
|
"encoding": "^0.1.13", |
||||||
|
"es-value-fixtures": "^1.5.0", |
||||||
|
"eslint": "=8.8.0", |
||||||
|
"evalmd": "^0.0.19", |
||||||
|
"for-each": "^0.3.3", |
||||||
|
"has-strict-mode": "^1.0.1", |
||||||
|
"in-publish": "^2.0.1", |
||||||
|
"npmignore": "^0.3.1", |
||||||
|
"nyc": "^10.3.2", |
||||||
|
"object-inspect": "^1.13.3", |
||||||
|
"safe-publish-latest": "^2.0.0", |
||||||
|
"tape": "^5.9.0", |
||||||
|
"typescript": "next" |
||||||
|
}, |
||||||
|
"testling": { |
||||||
|
"files": "test/index.js" |
||||||
|
}, |
||||||
|
"auto-changelog": { |
||||||
|
"output": "CHANGELOG.md", |
||||||
|
"template": "keepachangelog", |
||||||
|
"unreleased": false, |
||||||
|
"commitLimit": false, |
||||||
|
"backfillLimit": false, |
||||||
|
"hideCredit": true |
||||||
|
}, |
||||||
|
"publishConfig": { |
||||||
|
"ignore": [ |
||||||
|
".github/workflows" |
||||||
|
] |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.4" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
declare const reflectApply: false | typeof Reflect.apply; |
||||||
|
|
||||||
|
export = reflectApply; |
@ -0,0 +1,4 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
/** @type {import('./reflectApply')} */ |
||||||
|
module.exports = typeof Reflect !== 'undefined' && Reflect && Reflect.apply; |
@ -0,0 +1,63 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
var callBind = require('../'); |
||||||
|
var hasStrictMode = require('has-strict-mode')(); |
||||||
|
var forEach = require('for-each'); |
||||||
|
var inspect = require('object-inspect'); |
||||||
|
var v = require('es-value-fixtures'); |
||||||
|
|
||||||
|
var test = require('tape'); |
||||||
|
|
||||||
|
test('callBindBasic', function (t) { |
||||||
|
forEach(v.nonFunctions, function (nonFunction) { |
||||||
|
t['throws']( |
||||||
|
// @ts-expect-error
|
||||||
|
function () { callBind([nonFunction]); }, |
||||||
|
TypeError, |
||||||
|
inspect(nonFunction) + ' is not a function' |
||||||
|
); |
||||||
|
}); |
||||||
|
|
||||||
|
var sentinel = { sentinel: true }; |
||||||
|
/** @type {<T>(this: T, a: number, b: number) => [T | undefined, number, number]} */ |
||||||
|
var func = function (a, b) { |
||||||
|
// eslint-disable-next-line no-invalid-this
|
||||||
|
return [!hasStrictMode && this === global ? undefined : this, a, b]; |
||||||
|
}; |
||||||
|
t.equal(func.length, 2, 'original function length is 2'); |
||||||
|
|
||||||
|
/** type {(thisArg: unknown, a: number, b: number) => [unknown, number, number]} */ |
||||||
|
var bound = callBind([func]); |
||||||
|
/** type {((a: number, b: number) => [sentinel, typeof a, typeof b])} */ |
||||||
|
var boundR = callBind([func, sentinel]); |
||||||
|
/** type {((b: number) => [sentinel, number, typeof b])} */ |
||||||
|
var boundArg = callBind([func, sentinel, 1]); |
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(bound(), [undefined, undefined, undefined], 'bound func with no args'); |
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(func(), [undefined, undefined, undefined], 'unbound func with too few args'); |
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(bound(1, 2), [hasStrictMode ? 1 : Object(1), 2, undefined], 'bound func too few args'); |
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(boundR(), [sentinel, undefined, undefined], 'bound func with receiver, with too few args'); |
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(boundArg(), [sentinel, 1, undefined], 'bound func with receiver and arg, with too few args'); |
||||||
|
|
||||||
|
t.deepEqual(func(1, 2), [undefined, 1, 2], 'unbound func with right args'); |
||||||
|
t.deepEqual(bound(1, 2, 3), [hasStrictMode ? 1 : Object(1), 2, 3], 'bound func with right args'); |
||||||
|
t.deepEqual(boundR(1, 2), [sentinel, 1, 2], 'bound func with receiver, with right args'); |
||||||
|
t.deepEqual(boundArg(2), [sentinel, 1, 2], 'bound func with receiver and arg, with right arg'); |
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(func(1, 2, 3), [undefined, 1, 2], 'unbound func with too many args'); |
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(bound(1, 2, 3, 4), [hasStrictMode ? 1 : Object(1), 2, 3], 'bound func with too many args'); |
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(boundR(1, 2, 3), [sentinel, 1, 2], 'bound func with receiver, with too many args'); |
||||||
|
// @ts-expect-error
|
||||||
|
t.deepEqual(boundArg(2, 3), [sentinel, 1, 2], 'bound func with receiver and arg, with too many args'); |
||||||
|
|
||||||
|
t.end(); |
||||||
|
}); |
@ -0,0 +1,9 @@ |
|||||||
|
{ |
||||||
|
"extends": "@ljharb/tsconfig", |
||||||
|
"compilerOptions": { |
||||||
|
"target": "es2021", |
||||||
|
}, |
||||||
|
"exclude": [ |
||||||
|
"coverage", |
||||||
|
], |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
{ |
||||||
|
"root": true, |
||||||
|
|
||||||
|
"extends": "@ljharb", |
||||||
|
|
||||||
|
"rules": { |
||||||
|
"new-cap": [2, { |
||||||
|
"capIsNewExceptions": [ |
||||||
|
"GetIntrinsic", |
||||||
|
], |
||||||
|
}], |
||||||
|
}, |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
# These are supported funding model platforms |
||||||
|
|
||||||
|
github: [ljharb] |
||||||
|
patreon: # Replace with a single Patreon username |
||||||
|
open_collective: # Replace with a single Open Collective username |
||||||
|
ko_fi: # Replace with a single Ko-fi username |
||||||
|
tidelift: npm/call-bound |
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry |
||||||
|
liberapay: # Replace with a single Liberapay username |
||||||
|
issuehunt: # Replace with a single IssueHunt username |
||||||
|
otechie: # Replace with a single Otechie username |
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
@ -0,0 +1,9 @@ |
|||||||
|
{ |
||||||
|
"all": true, |
||||||
|
"check-coverage": false, |
||||||
|
"reporter": ["text-summary", "text", "html", "json"], |
||||||
|
"exclude": [ |
||||||
|
"coverage", |
||||||
|
"test" |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
# Changelog |
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file. |
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) |
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
||||||
|
|
||||||
|
## [v1.0.3](https://github.com/ljharb/call-bound/compare/v1.0.2...v1.0.3) - 2024-12-15 |
||||||
|
|
||||||
|
### Commits |
||||||
|
|
||||||
|
- [Refactor] use `call-bind-apply-helpers` instead of `call-bind` [`5e0b134`](https://github.com/ljharb/call-bound/commit/5e0b13496df14fb7d05dae9412f088da8d3f75be) |
||||||
|
- [Deps] update `get-intrinsic` [`41fc967`](https://github.com/ljharb/call-bound/commit/41fc96732a22c7b7e8f381f93ccc54bb6293be2e) |
||||||
|
- [readme] fix example [`79a0137`](https://github.com/ljharb/call-bound/commit/79a0137723f7c6d09c9c05452bbf8d5efb5d6e49) |
||||||
|
- [meta] add `sideEffects` flag [`08b07be`](https://github.com/ljharb/call-bound/commit/08b07be7f1c03f67dc6f3cdaf0906259771859f7) |
||||||
|
|
||||||
|
## [v1.0.2](https://github.com/ljharb/call-bound/compare/v1.0.1...v1.0.2) - 2024-12-10 |
||||||
|
|
||||||
|
### Commits |
||||||
|
|
||||||
|
- [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/tsconfig`, `gopd` [`e6a5ffe`](https://github.com/ljharb/call-bound/commit/e6a5ffe849368fe4f74dfd6cdeca1b9baa39e8d5) |
||||||
|
- [Deps] update `call-bind`, `get-intrinsic` [`2aeb5b5`](https://github.com/ljharb/call-bound/commit/2aeb5b521dc2b2683d1345c753ea1161de2d1c14) |
||||||
|
- [types] improve return type [`1a0c9fe`](https://github.com/ljharb/call-bound/commit/1a0c9fe3114471e7ca1f57d104e2efe713bb4871) |
||||||
|
|
||||||
|
## v1.0.1 - 2024-12-05 |
||||||
|
|
||||||
|
### Commits |
||||||
|
|
||||||
|
- Initial implementation, tests, readme, types [`6d94121`](https://github.com/ljharb/call-bound/commit/6d94121a9243602e506334069f7a03189fe3363d) |
||||||
|
- Initial commit [`0eae867`](https://github.com/ljharb/call-bound/commit/0eae867334ea025c33e6e91cdecfc9df96680cf9) |
||||||
|
- npm init [`71b2479`](https://github.com/ljharb/call-bound/commit/71b2479c6723e0b7d91a6b663613067e98b7b275) |
||||||
|
- Only apps should have lockfiles [`c3754a9`](https://github.com/ljharb/call-bound/commit/c3754a949b7f9132b47e2d18c1729889736741eb) |
||||||
|
- [actions] skip `npm ls` in node < 10 [`74275a5`](https://github.com/ljharb/call-bound/commit/74275a5186b8caf6309b6b97472bdcb0df4683a8) |
||||||
|
- [Dev Deps] add missing peer dep [`1354de8`](https://github.com/ljharb/call-bound/commit/1354de8679413e4ae9c523d85f76fa7a5e032d97) |