не отображает категории и бренды

This commit is contained in:
2025-05-14 23:56:09 +04:00
parent b4561960b6
commit 743ae61c4b
1122 changed files with 62104 additions and 13 deletions

30
ProductController.js Normal file
View File

@@ -0,0 +1,30 @@
import ProductModel from "./ProductModel.js";
import ProductView from "./ProductView.js";
export default class ProductController {
constructor(root, apiUrl) {
this.model = new ProductModel(apiUrl);
this.view = new ProductView(root, {
onEdit: (id) => this.handleEdit(id),
onDelete: (id) => this.handleDelete(id),
});
this.init();
}
async init() {
const products = await this.model.getAll();
this.view.render(products);
}
async handleEdit(id) {
alert(`Редактировать продукт с id=${id}`);
}
async handleDelete(id) {
if (confirm("Удалить этот продукт?")) {
await this.model.delete(id);
this.init();
}
}
}

37
ProductModel.js Normal file
View File

@@ -0,0 +1,37 @@
export default class ProductModel {
constructor(apiUrl) {
this.apiUrl = apiUrl;
}
async getAll() {
const res = await fetch(`${this.apiUrl}/products`);
return await res.json();
}
async getById(id) {
const res = await fetch(`${this.apiUrl}/products/${id}`);
return await res.json();
}
async create(data) {
const res = await fetch(`${this.apiUrl}/products`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
});
return await res.json();
}
async update(id, data) {
const res = await fetch(`${this.apiUrl}/products/${id}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
});
return await res.json();
}
async delete(id) {
return await fetch(`${this.apiUrl}/products/${id}`, { method: "DELETE" });
}
}

48
ProductView.js Normal file
View File

@@ -0,0 +1,48 @@
export default class ProductView {
constructor(root, handlers) {
this.root = root;
this.handlers = handlers;
}
render(products) {
this.root.innerHTML = "";
const table = document.createElement("table");
table.innerHTML = `
<tr><th>ID</th><th>Название</th><th>Категория</th><th>Бренд</th><th>Действия</th></tr>
`;
products.forEach((p) => {
const row = document.createElement("tr");
row.innerHTML = `
<td>${p.id}</td>
<td>${p.name}</td>
<td>${p.categoryId}</td>
<td>${p.brandId}</td>
<td>
<button data-id="${p.id}" class="edit">✏️</button>
<button data-id="${p.id}" class="delete">🗑️</button>
</td>
`;
table.appendChild(row);
});
this.root.appendChild(table);
this.root
.querySelectorAll(".edit")
.forEach((btn) =>
btn.addEventListener("click", (e) =>
this.handlers.onEdit(parseInt(e.target.dataset.id)),
),
);
this.root
.querySelectorAll(".delete")
.forEach((btn) =>
btn.addEventListener("click", (e) =>
this.handlers.onDelete(parseInt(e.target.dataset.id)),
),
);
}
}

View File

@@ -35,6 +35,7 @@
<li><a class="dropdown-item" href="contacs.html"><i class="bi bi-envelope"></i> Наши контакты</a></li>
<li><a class="dropdown-item" href="delivery.html"><i class="bi bi-truck"></i> Доставка</a></li>
<li><a class="dropdown-item" href="refund.html"><i class="bi bi-arrow-repeat"></i> Возврат</a></li>
<li><a class="dropdown-item" href="products.html"><i class="bi bi-box"></i> Товары</a></li>
</ul>
</li>
</ul>

68
add.html Normal file
View File

@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<title>Добавить товар</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" />
</head>
<body class="p-4">
<div class="container">
<h1 class="mb-4">Добавить товар</h1>
<form id="product-form">
<div class="mb-3">
<label for="name" class="form-label">Название</label>
<input type="text" class="form-control" id="name" required />
</div>
<div class="mb-3">
<label for="categoryId" class="form-label">Категория</label>
<select id="categoryId" class="form-select" required></select>
</div>
<div class="mb-3">
<label for="brandId" class="form-label">Бренд</label>
<select id="brandId" class="form-select" required></select>
</div>
<button type="submit" class="btn btn-success">Сохранить</button>
<a href="products.html" class="btn btn-secondary">Назад</a>
<a href="index.html" class="btn btn-outline-secondary">🏠 На главную</a>
</form>
</div>
<script type="module">
const API_URL = 'http://localhost:3001';
async function fetchOptions(endpoint, selectEl) {
const res = await fetch(`${API_URL}/${endpoint}`);
const data = await res.json();
data.forEach(item => {
const opt = document.createElement('option');
opt.value = item.id;
opt.textContent = item.name;
selectEl.appendChild(opt);
});
}
const form = document.getElementById('product-form');
const nameInput = document.getElementById('name');
const categorySelect = document.getElementById('categoryId');
const brandSelect = document.getElementById('brandId');
await fetchOptions('categories', categorySelect);
await fetchOptions('brands', brandSelect);
form.addEventListener('submit', async (e) => {
e.preventDefault();
const product = {
name: nameInput.value,
categoryId: parseInt(categorySelect.value),
brandId: parseInt(brandSelect.value)
};
await fetch(`${API_URL}/products`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(product)
});
window.location.href = 'products.html';
});
</script>
</body>
</html>

View File

@@ -35,6 +35,7 @@
<li><a class="dropdown-item" href="contacs.html"><i class="bi bi-envelope"></i> Наши контакты</a></li>
<li><a class="dropdown-item" href="delivery.html"><i class="bi bi-truck"></i> Доставка</a></li>
<li><a class="dropdown-item" href="refund.html"><i class="bi bi-arrow-repeat"></i> Возврат</a></li>
<li><a class="dropdown-item" href="products.html"><i class="bi bi-box"></i> Товары</a></li>
</ul>
</li>
</ul>

58
db.json Normal file
View File

@@ -0,0 +1,58 @@
{
"products": [
{
"name": "марджела",
"categoryId": 2,
"brandId": 3,
"id": "1"
},
{
"id": "2",
"name": "dwdawd",
"categoryId": 1,
"brandId": 1
},
{
"id": "3",
"name": "dwd",
"categoryId": 2,
"brandId": 1
},
{
"id": "4",
"name": "dwdw",
"categoryId": 2,
"brandId": 1
},
{
"id": "5",
"name": "zhopa",
"categoryId": 1,
"brandId": 1
}
],
"categories": [
{
"id": "1",
"name": "Электроника"
},
{
"id": "2",
"name": "Одежда"
}
],
"brands": [
{
"id": "1",
"name": "ASUS"
},
{
"id": "2",
"name": "Nike"
},
{
"id": "3",
"name": "New balance"
}
]
}

View File

@@ -35,6 +35,7 @@
<li><a class="dropdown-item" href="contacs.html"><i class="bi bi-envelope"></i> Наши контакты</a></li>
<li><a class="dropdown-item" href="delivery.html"><i class="bi bi-truck"></i> Доставка</a></li>
<li><a class="dropdown-item" href="refund.html"><i class="bi bi-arrow-repeat"></i> Возврат</a></li>
<li><a class="dropdown-item" href="products.html"><i class="bi bi-box"></i> Товары</a></li>
</ul>
</li>
</ul>

85
edit.html Normal file
View File

@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<title>Редактировать товар</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" />
</head>
<body class="p-4">
<div class="container">
<h1 class="mb-4">Редактировать товар</h1>
<form id="product-form">
<div class="mb-3">
<label for="name" class="form-label">Название</label>
<input type="text" class="form-control" id="name" required />
</div>
<div class="mb-3">
<label for="categoryId" class="form-label">Категория</label>
<select id="categoryId" class="form-select" required></select>
</div>
<div class="mb-3">
<label for="brandId" class="form-label">Бренд</label>
<select id="brandId" class="form-select" required></select>
</div>
<button type="submit" class="btn btn-primary">Обновить</button>
<a href="products.html" class="btn btn-secondary">Назад</a>
<a href="index.html" class="btn btn-outline-secondary">🏠 На главную</a>
</form>
</div>
<script type="module">
const API_URL = 'http://localhost:3001';
const params = new URLSearchParams(window.location.search);
const id = params.get('id');
if (!id) {
alert('ID не указан');
window.location.href = 'index.html';
}
const form = document.getElementById('product-form');
const nameInput = document.getElementById('name');
const categorySelect = document.getElementById('categoryId');
const brandSelect = document.getElementById('brandId');
async function fetchOptions(endpoint, selectEl) {
const res = await fetch(`${API_URL}/${endpoint}`);
const data = await res.json();
data.forEach(item => {
const opt = document.createElement('option');
opt.value = item.id;
opt.textContent = item.name;
selectEl.appendChild(opt);
});
}
async function fillForm() {
const res = await fetch(`${API_URL}/products/${id}`);
const product = await res.json();
nameInput.value = product.name;
categorySelect.value = product.categoryId;
brandSelect.value = product.brandId;
}
await fetchOptions('categories', categorySelect);
await fetchOptions('brands', brandSelect);
await fillForm();
form.addEventListener('submit', async (e) => {
e.preventDefault();
const updated = {
name: nameInput.value,
categoryId: parseInt(categorySelect.value),
brandId: parseInt(brandSelect.value)
};
await fetch(`${API_URL}/products/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(updated)
});
window.location.href = 'products.html';
});
</script>
</body>
</html>

View File

@@ -35,6 +35,7 @@
<li><a class="dropdown-item" href="contacs.html"><i class="bi bi-envelope"></i> Наши контакты</a></li>
<li><a class="dropdown-item" href="delivery.html"><i class="bi bi-truck"></i> Доставка</a></li>
<li><a class="dropdown-item" href="refund.html"><i class="bi bi-arrow-repeat"></i> Возврат</a></li>
<li><a class="dropdown-item" href="products.html"><i class="bi bi-box"></i> Товары</a></li>
</ul>
</li>
</ul>

1
node_modules/.bin/json-server generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../json-server/lib/bin.js

1
node_modules/.bin/json5 generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../json5/lib/cli.js

1
node_modules/.bin/mime generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../mime/bin/cli.js

532
node_modules/.package-lock.json generated vendored
View File

@@ -234,6 +234,12 @@
"url": "https://opencollective.com/unts"
}
},
"node_modules/@polka/url": {
"version": "1.0.0-next.29",
"resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz",
"integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==",
"license": "MIT"
},
"node_modules/@popperjs/core": {
"version": "2.11.8",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
@@ -245,6 +251,244 @@
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@tinyhttp/accepts": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@tinyhttp/accepts/-/accepts-2.2.3.tgz",
"integrity": "sha512-9pQN6pJAJOU3McmdJWTcyq7LLFW8Lj5q+DadyKcvp+sxMkEpktKX5sbfJgJuOvjk6+1xWl7pe0YL1US1vaO/1w==",
"license": "MIT",
"dependencies": {
"mime": "4.0.4",
"negotiator": "^0.6.3"
},
"engines": {
"node": ">=12.20.0"
},
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
}
},
"node_modules/@tinyhttp/app": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/@tinyhttp/app/-/app-2.5.2.tgz",
"integrity": "sha512-DcB3Y8GQppLQlO2VxRYF7LzTEAoZb+VRQXuIsErcu2fNaM1xdx6NQZDso5rlZUiaeg6KYYRfU34N4XkZbv6jSA==",
"license": "MIT",
"dependencies": {
"@tinyhttp/cookie": "2.1.1",
"@tinyhttp/proxy-addr": "2.2.1",
"@tinyhttp/req": "2.2.5",
"@tinyhttp/res": "2.2.5",
"@tinyhttp/router": "2.2.3",
"header-range-parser": "1.1.3",
"regexparam": "^2.0.2"
},
"engines": {
"node": ">=14.21.3"
},
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
}
},
"node_modules/@tinyhttp/content-disposition": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/@tinyhttp/content-disposition/-/content-disposition-2.2.2.tgz",
"integrity": "sha512-crXw1txzrS36huQOyQGYFvhTeLeG0Si1xu+/l6kXUVYpE0TjFjEZRqTbuadQLfKGZ0jaI+jJoRyqaWwxOSHW2g==",
"license": "MIT",
"engines": {
"node": ">=12.20.0"
},
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
}
},
"node_modules/@tinyhttp/content-type": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/@tinyhttp/content-type/-/content-type-0.1.4.tgz",
"integrity": "sha512-dl6f3SHIJPYbhsW1oXdrqOmLSQF/Ctlv3JnNfXAE22kIP7FosqJHxkz/qj2gv465prG8ODKH5KEyhBkvwrueKQ==",
"license": "MIT",
"engines": {
"node": ">=12.4"
}
},
"node_modules/@tinyhttp/cookie": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@tinyhttp/cookie/-/cookie-2.1.1.tgz",
"integrity": "sha512-h/kL9jY0e0Dvad+/QU3efKZww0aTvZJslaHj3JTPmIPC9Oan9+kYqmh3M6L5JUQRuTJYFK2nzgL2iJtH2S+6dA==",
"license": "MIT",
"engines": {
"node": ">=12.20.0"
},
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
}
},
"node_modules/@tinyhttp/cookie-signature": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@tinyhttp/cookie-signature/-/cookie-signature-2.1.1.tgz",
"integrity": "sha512-VDsSMY5OJfQJIAtUgeQYhqMPSZptehFSfvEEtxr+4nldPA8IImlp3QVcOVuK985g4AFR4Hl1sCbWCXoqBnVWnw==",
"license": "MIT",
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/cors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.1.tgz",
"integrity": "sha512-qrmo6WJuaiCzKWagv2yA/kw6hIISfF/hOqPWwmI6w0o8apeTMmRN3DoCFvQ/wNVuWVdU5J4KU7OX8aaSOEq51A==",
"license": "MIT",
"dependencies": {
"@tinyhttp/vary": "^0.1.3"
},
"engines": {
"node": ">=12.20 || 14.x || >=16"
}
},
"node_modules/@tinyhttp/encode-url": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@tinyhttp/encode-url/-/encode-url-2.1.1.tgz",
"integrity": "sha512-AhY+JqdZ56qV77tzrBm0qThXORbsVjs/IOPgGCS7x/wWnsa/Bx30zDUU/jPAUcSzNOzt860x9fhdGpzdqbUeUw==",
"license": "MIT",
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/etag": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@tinyhttp/etag/-/etag-2.1.2.tgz",
"integrity": "sha512-j80fPKimGqdmMh6962y+BtQsnYPVCzZfJw0HXjyH70VaJBHLKGF+iYhcKqzI3yef6QBNa8DKIPsbEYpuwApXTw==",
"license": "MIT",
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/forwarded": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@tinyhttp/forwarded/-/forwarded-2.1.2.tgz",
"integrity": "sha512-9H/eulJ68ElY/+zYpTpNhZ7vxGV+cnwaR6+oQSm7bVgZMyuQfgROW/qvZuhmgDTIxnGMXst+Ba4ij6w6Krcs3w==",
"license": "MIT",
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/logger": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@tinyhttp/logger/-/logger-2.1.0.tgz",
"integrity": "sha512-Ma1fJ9CwUbn9r61/4HW6+nflsVoslpOnCrfQ6UeZq7GGIgwLzofms3HoSVG7M+AyRMJpxlfcDdbH5oFVroDMKA==",
"license": "MIT",
"dependencies": {
"colorette": "^2.0.20",
"dayjs": "^1.11.13",
"http-status-emojis": "^2.2.0"
},
"engines": {
"node": ">=14.18 || >=16.20"
}
},
"node_modules/@tinyhttp/proxy-addr": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@tinyhttp/proxy-addr/-/proxy-addr-2.2.1.tgz",
"integrity": "sha512-BicqMqVI91hHq2BQmnqJUh0FQUnx7DncwSGgu2ghlh+JZG2rHK2ZN/rXkfhrx1rrUw6hnd0L36O8GPMh01+dDQ==",
"license": "MIT",
"dependencies": {
"@tinyhttp/forwarded": "2.1.2",
"ipaddr.js": "^2.2.0"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/req": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/@tinyhttp/req/-/req-2.2.5.tgz",
"integrity": "sha512-trfsXwtmsNjMcGKcLJ+45h912kLRqBQCQD06ams3Tq0kf4gHLxjHjoYOC1Z9yGjOn81XllRx8wqvnvr+Kbe3gw==",
"license": "MIT",
"dependencies": {
"@tinyhttp/accepts": "2.2.3",
"@tinyhttp/type-is": "2.2.4",
"@tinyhttp/url": "2.1.1",
"header-range-parser": "^1.1.3"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/res": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/@tinyhttp/res/-/res-2.2.5.tgz",
"integrity": "sha512-yBsqjWygpuKAVz4moWlP4hqzwiDDqfrn2mA0wviJAcgvGiyOErtlQwXY7aj3aPiCpURvxvEFO//Gdy6yV+xEpA==",
"license": "MIT",
"dependencies": {
"@tinyhttp/content-disposition": "2.2.2",
"@tinyhttp/cookie": "2.1.1",
"@tinyhttp/cookie-signature": "2.1.1",
"@tinyhttp/encode-url": "2.1.1",
"@tinyhttp/req": "2.2.5",
"@tinyhttp/send": "2.2.3",
"@tinyhttp/vary": "^0.1.3",
"es-escape-html": "^0.1.1",
"mime": "4.0.4"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/router": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@tinyhttp/router/-/router-2.2.3.tgz",
"integrity": "sha512-O0MQqWV3Vpg/uXsMYg19XsIgOhwjyhTYWh51Qng7bxqXixxx2PEvZWnFjP7c84K7kU/nUX41KpkEBTLnznk9/Q==",
"license": "MIT",
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/send": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@tinyhttp/send/-/send-2.2.3.tgz",
"integrity": "sha512-o4cVHHGQ8WjVBS8UT0EE/2WnjoybrfXikHwsRoNlG1pfrC/Sd01u1N4Te8cOd/9aNGLr4mGxWb5qTm2RRtEi7g==",
"license": "MIT",
"dependencies": {
"@tinyhttp/content-type": "^0.1.4",
"@tinyhttp/etag": "2.1.2",
"mime": "4.0.4"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/type-is": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/@tinyhttp/type-is/-/type-is-2.2.4.tgz",
"integrity": "sha512-7F328NheridwjIfefBB2j1PEcKKABpADgv7aCJaE8x8EON77ZFrAkI3Rir7pGjopV7V9MBmW88xUQigBEX2rmQ==",
"license": "MIT",
"dependencies": {
"@tinyhttp/content-type": "^0.1.4",
"mime": "4.0.4"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/url": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@tinyhttp/url/-/url-2.1.1.tgz",
"integrity": "sha512-POJeq2GQ5jI7Zrdmj22JqOijB5/GeX+LEX7DUdml1hUnGbJOTWDx7zf2b5cCERj7RoXL67zTgyzVblBJC+NJWg==",
"license": "MIT",
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/@tinyhttp/vary": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@tinyhttp/vary/-/vary-0.1.3.tgz",
"integrity": "sha512-SoL83sQXAGiHN1jm2VwLUWQSQeDAAl1ywOm6T0b0Cg1CZhVsjoiZadmjhxF6FHCCY7OHHVaLnTgSMxTPIDLxMg==",
"license": "MIT",
"engines": {
"node": ">=12.20"
}
},
"node_modules/@types/estree": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz",
@@ -386,6 +630,21 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/chokidar": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
"license": "MIT",
"dependencies": {
"readdirp": "^4.0.1"
},
"engines": {
"node": ">= 14.16.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
@@ -406,6 +665,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/colorette": {
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
"integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
"license": "MIT"
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -428,6 +693,12 @@
"node": ">= 8"
}
},
"node_modules/dayjs": {
"version": "1.11.13",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz",
"integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==",
"license": "MIT"
},
"node_modules/debug": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
@@ -453,6 +724,30 @@
"dev": true,
"license": "MIT"
},
"node_modules/dot-prop": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-9.0.0.tgz",
"integrity": "sha512-1gxPBJpI/pcjQhKgIU91II6Wkay+dLcN3M6rf2uwP8hRur3HtQXjVrdAK3sjC0piaEuxzMwjXChcETiJl47lAQ==",
"license": "MIT",
"dependencies": {
"type-fest": "^4.18.2"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/es-escape-html": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/es-escape-html/-/es-escape-html-0.1.1.tgz",
"integrity": "sha512-yUx1o+8RsG7UlszmYPtks+dm6Lho2m8lgHMOsLJQsFI0R8XwUJwiMhM1M4E/S8QLeGyf6MkDV/pWgjQ0tdTSyQ==",
"license": "MIT",
"engines": {
"node": ">=12.x"
}
},
"node_modules/escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
@@ -665,6 +960,18 @@
"node": ">=0.10.0"
}
},
"node_modules/eta": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/eta/-/eta-3.5.0.tgz",
"integrity": "sha512-e3x3FBvGzeCIHhF+zhK8FZA2vC5uFn6b4HJjegUbIWrDb4mJ7JjTGMJY9VGIbRVpmSwHopNiaJibhjIr+HfLug==",
"license": "MIT",
"engines": {
"node": ">=6.0.0"
},
"funding": {
"url": "https://github.com/eta-dev/eta?sponsor=1"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@@ -780,6 +1087,21 @@
"node": ">=8"
}
},
"node_modules/header-range-parser": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/header-range-parser/-/header-range-parser-1.1.3.tgz",
"integrity": "sha512-B9zCFt3jH8g09LR1vHL4pcAn8yMEtlSlOUdQemzHMRKMImNIhhszdeosYFfNW0WXKQtXIlWB+O4owHJKvEJYaA==",
"license": "MIT",
"engines": {
"node": ">=12.22.0"
}
},
"node_modules/http-status-emojis": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/http-status-emojis/-/http-status-emojis-2.2.0.tgz",
"integrity": "sha512-ompKtgwpx8ff0hsbpIB7oE4ax1LXoHmftsHHStMELX56ivG3GhofTX8ZHWlUaFKfGjcGjw6G3rPk7dJRXMmbbg==",
"license": "MIT"
},
"node_modules/ignore": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
@@ -817,6 +1139,24 @@
"node": ">=0.8.19"
}
},
"node_modules/inflection": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/inflection/-/inflection-3.0.2.tgz",
"integrity": "sha512-+Bg3+kg+J6JUWn8J6bzFmOWkTQ6L/NHfDRSYU+EVvuKHDxUDHAXgqixHfVlzuBQaPOTac8hn43aPhMNk6rMe3g==",
"license": "MIT",
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/ipaddr.js": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz",
"integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==",
"license": "MIT",
"engines": {
"node": ">= 10"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -874,6 +1214,45 @@
"dev": true,
"license": "MIT"
},
"node_modules/json-server": {
"version": "1.0.0-beta.3",
"resolved": "https://registry.npmjs.org/json-server/-/json-server-1.0.0-beta.3.tgz",
"integrity": "sha512-DwE69Ep5ccwIJZBUIWEENC30Yj8bwr4Ax9W9VoIWAYnB8Sj4ReptscO8/DRHv/nXwVlmb3Bk73Ls86+VZdYkkA==",
"license": "SEE LICENSE IN ./LICENSE",
"dependencies": {
"@tinyhttp/app": "^2.4.0",
"@tinyhttp/cors": "^2.0.1",
"@tinyhttp/logger": "^2.0.0",
"chalk": "^5.3.0",
"chokidar": "^4.0.1",
"dot-prop": "^9.0.0",
"eta": "^3.5.0",
"inflection": "^3.0.0",
"json5": "^2.2.3",
"lowdb": "^7.0.1",
"milliparsec": "^4.0.0",
"sirv": "^2.0.4",
"sort-on": "^6.1.0"
},
"bin": {
"json-server": "lib/bin.js"
},
"engines": {
"node": ">=18.3"
}
},
"node_modules/json-server/node_modules/chalk": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz",
"integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==",
"license": "MIT",
"engines": {
"node": "^12.17.0 || ^14.13 || >=16.0.0"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
@@ -881,6 +1260,18 @@
"dev": true,
"license": "MIT"
},
"node_modules/json5": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"license": "MIT",
"bin": {
"json5": "lib/cli.js"
},
"engines": {
"node": ">=6"
}
},
"node_modules/keyv": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
@@ -928,6 +1319,45 @@
"dev": true,
"license": "MIT"
},
"node_modules/lowdb": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/lowdb/-/lowdb-7.0.1.tgz",
"integrity": "sha512-neJAj8GwF0e8EpycYIDFqEPcx9Qz4GUho20jWFR7YiFeXzF1YMLdxB36PypcTSPMA+4+LvgyMacYhlr18Zlymw==",
"license": "MIT",
"dependencies": {
"steno": "^4.0.2"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/milliparsec": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/milliparsec/-/milliparsec-4.0.0.tgz",
"integrity": "sha512-/wk9d4Z6/9ZvoEH/6BI4TrTCgmkpZPuSRN/6fI9aUHOfXdNTuj/VhLS7d+NqG26bi6L9YmGXutVYvWC8zQ0qtA==",
"license": "MIT",
"engines": {
"node": ">=20"
}
},
"node_modules/mime": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/mime/-/mime-4.0.4.tgz",
"integrity": "sha512-v8yqInVjhXyqP6+Kw4fV3ZzeMRqEW6FotRsKXjRS5VMTNIuXsdRoAvklpoRgSqXm6o9VNH4/C0mgedko9DdLsQ==",
"funding": [
"https://github.com/sponsors/broofa"
],
"license": "MIT",
"bin": {
"mime": "bin/cli.js"
},
"engines": {
"node": ">=16"
}
},
"node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
@@ -941,6 +1371,15 @@
"node": "*"
}
},
"node_modules/mrmime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz",
"integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==",
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -955,6 +1394,15 @@
"dev": true,
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.4",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz",
"integrity": "sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/optionator": {
"version": "0.9.4",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
@@ -1088,6 +1536,28 @@
"node": ">=6"
}
},
"node_modules/readdirp": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
"license": "MIT",
"engines": {
"node": ">= 14.18.0"
},
"funding": {
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/regexparam": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/regexparam/-/regexparam-2.0.2.tgz",
"integrity": "sha512-A1PeDEYMrkLrfyOwv2jwihXbo9qxdGD3atBYQA9JJgreAx8/7rC6IUkWOw2NQlOxLp2wL0ifQbh1HuidDfYA6w==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
@@ -1121,6 +1591,47 @@
"node": ">=8"
}
},
"node_modules/sirv": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz",
"integrity": "sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==",
"license": "MIT",
"dependencies": {
"@polka/url": "^1.0.0-next.24",
"mrmime": "^2.0.0",
"totalist": "^3.0.0"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/sort-on": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/sort-on/-/sort-on-6.1.0.tgz",
"integrity": "sha512-WTECP0nYNWO1n2g5bpsV0yZN9cBmZsF8ThHFbOqVN0HBFRoaQZLLEMvMmJlKHNPYQeVngeI5+jJzIfFqOIo1OA==",
"license": "MIT",
"dependencies": {
"dot-prop": "^9.0.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/steno": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/steno/-/steno-4.0.2.tgz",
"integrity": "sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/strip-json-comments": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
@@ -1164,6 +1675,15 @@
"url": "https://opencollective.com/synckit"
}
},
"node_modules/totalist": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz",
"integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
@@ -1184,6 +1704,18 @@
"node": ">= 0.8.0"
}
},
"node_modules/type-fest": {
"version": "4.41.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz",
"integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==",
"license": "(MIT OR CC0-1.0)",
"engines": {
"node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",

49
node_modules/@polka/url/build.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
const qs = require('querystring');
/**
* @typedef ParsedURL
* @type {import('.').ParsedURL}
*/
/**
* @typedef Request
* @property {string} url
* @property {ParsedURL} _parsedUrl
*/
/**
* @param {Request} req
* @returns {ParsedURL|void}
*/
function parse(req) {
let raw = req.url;
if (raw == null) return;
let prev = req._parsedUrl;
if (prev && prev.raw === raw) return prev;
let pathname=raw, search='', query, hash;
if (raw.length > 1) {
let idx = raw.indexOf('#', 1);
if (idx !== -1) {
hash = raw.substring(idx);
pathname = raw.substring(0, idx);
}
idx = pathname.indexOf('?', 1);
if (idx !== -1) {
search = pathname.substring(idx);
pathname = pathname.substring(0, idx);
if (search.length > 1) {
query = qs.parse(search.substring(1));
}
}
}
return req._parsedUrl = { pathname, search, query, hash, raw };
}
exports.parse = parse;

47
node_modules/@polka/url/build.mjs generated vendored Normal file
View File

@@ -0,0 +1,47 @@
import * as qs from 'node:querystring';
/**
* @typedef ParsedURL
* @type {import('.').ParsedURL}
*/
/**
* @typedef Request
* @property {string} url
* @property {ParsedURL} _parsedUrl
*/
/**
* @param {Request} req
* @returns {ParsedURL|void}
*/
export function parse(req) {
let raw = req.url;
if (raw == null) return;
let prev = req._parsedUrl;
if (prev && prev.raw === raw) return prev;
let pathname=raw, search='', query, hash;
if (raw.length > 1) {
let idx = raw.indexOf('#', 1);
if (idx !== -1) {
hash = raw.substring(idx);
pathname = raw.substring(0, idx);
}
idx = pathname.indexOf('?', 1);
if (idx !== -1) {
search = pathname.substring(idx);
pathname = pathname.substring(0, idx);
if (search.length > 1) {
query = qs.parse(search.substring(1));
}
}
}
return req._parsedUrl = { pathname, search, query, hash, raw };
}

11
node_modules/@polka/url/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import type { IncomingMessage } from 'http';
export interface ParsedURL {
pathname: string;
search: string;
query: Record<string, string | string[]> | undefined;
hash: string | undefined;
raw: string;
}
export function parse(req: IncomingMessage): ParsedURL;

30
node_modules/@polka/url/package.json generated vendored Normal file
View File

@@ -0,0 +1,30 @@
{
"version": "1.0.0-next.29",
"name": "@polka/url",
"repository": "lukeed/polka",
"description": "Super fast, memoized `req.url` parser",
"module": "build.mjs",
"types": "index.d.ts",
"main": "build.js",
"license": "MIT",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./build.mjs",
"require": "./build.js"
},
"./package.json": "./package.json"
},
"files": [
"build.*",
"index.d.*"
],
"author": {
"name": "Luke Edwards",
"email": "luke@lukeed.com",
"url": "https://lukeed.com"
},
"publishConfig": {
"access": "public"
}
}

68
node_modules/@polka/url/readme.md generated vendored Normal file
View File

@@ -0,0 +1,68 @@
# @polka/url [![npm](https://badgen.now.sh/npm/v/@polka/url)](https://npmjs.org/package/@polka/url) [![licenses](https://licenses.dev/b/npm/%40polka%2Furl)](https://licenses.dev/npm/%40polka%2Furl)
> Super fast, memoized `req.url` parser; _not_ limited to [Polka][polka]!
Parses the `url` from a [`IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) request. The returned object will always only contain the following keys: `search`, `query`, `pathname`, and `raw`.
> **Note:** This library does not process `protocol`, `hostname`, `port`, etc.<br>This is because the incoming `req.url` value only begins with the path information.
Parsed requests will be mutated with a `_parsedUrl` key, containing the returned output. This is used for future memoization, avoiding the need to fully parse the same `url` value multiple times.
## Install
```
$ npm install --save @polka/url
```
## Usage
```js
const parse = require('@polka/url');
let req = {
url: '/foo/bar?fizz=buzz'
};
let output = parse(req);
//=> {
//=> pathname: '/foo/bar',
//=> raw: '/foo/bar?fizz=buzz',
//=> search: '?fizz=buzz',
//=> query: {
//=> fizz: 'buzz'
//=> },
//=> }
// Attaches result for future memoization
assert.deepEqual(output, req._parsedUrl); //=> true
```
## API
### url(req)
Returns: `Object` or `undefined`
> **Important:** The `req` must have a `url` key, otherwise `undefined` will be returned.<br>If no input is provided at all, a `TypeError` will be thrown.
#### req
Type: `IncomingMessage` or `{ url: string }`
The incoming HTTP request (`req`) or a plain `Object` with a `url` key.
> **Note:** In Node.js servers, the [`req.url`](https://nodejs.org/api/http.html#http_message_url) begins with a pathname & does not include a `hash`.
## Benchmarks
Check out the [`bench`](/bench) directory for in-depth benchmark results and comparisons.
## Support
Any issues or questions can be sent to the [Polka][polka] repository.<br>However, please specify that your inquiry is about `@polka/url` specifically.
## License
MIT © [Luke Edwards](https://lukeed.com)
[polka]: https://github.com/lukeed/polka

21
node_modules/@tinyhttp/accepts/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

117
node_modules/@tinyhttp/accepts/README.md generated vendored Normal file
View File

@@ -0,0 +1,117 @@
# @tinyhttp/accepts
> [`accepts`](https://github.com/jshttp/accepts) rewrite in TypeScript.
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 `*`
## Install
```sh
pnpm i @tinyhttp/accepts
```
## API
```ts
import { Accepts } from '@tinyhttp/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).
## Example
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.
```ts
import Accepts from '@tinyhttp/accepts'
import { createServer } from 'node:http'
createServer((req, res) => {
const accept = new 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()
}).listen(3000)
```
You can test this out with the cURL program:
```sh
curl -I -H 'Accept: text/html' http://localhost:3000/
```

48
node_modules/@tinyhttp/accepts/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
import type { IncomingMessage as I, IncomingHttpHeaders } from 'node:http';
import Negotiator from 'negotiator';
export declare class Accepts {
headers: IncomingHttpHeaders;
negotiator: Negotiator;
constructor(req: Pick<I, 'headers'>);
/**
* Check if the given `type(s)` is acceptable, returning the best match when true, otherwise `false`, 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. When no types are given as arguments, returns all types accepted by the client in the preference order.
*/
types(types: string | string[], ...args: string[]): string[] | string | false;
get type(): (types: string | string[], ...args: string[]) => string[] | string | false;
/**
* Return accepted encodings or best fit based on `encodings`.
*
* Given `Accept-Encoding: gzip, deflate`
* an array sorted by quality is returned:
*
* ['gzip', 'deflate']
*/
encodings(encodings: string | string[], ...args: string[]): string | string[] | boolean;
get encoding(): (encodings: string | string[], ...args: string[]) => string | string[] | boolean;
/**
* 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']
*/
charsets(charsets?: string | string[], ...args: string[]): string | string[] | boolean;
get charset(): (charsets: string | string[], ...args: string[]) => string | string[] | boolean;
/**
* 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']
*
*/
languages(languages: string | string[], ...args: string[]): string | string[] | boolean;
get lang(): (languages: string | string[], ...args: string[]) => string | string[] | boolean;
get langs(): (languages: string | string[], ...args: string[]) => string | string[] | boolean;
get language(): (languages: string | string[], ...args: string[]) => string | string[] | boolean;
}
//# sourceMappingURL=index.d.ts.map

1
node_modules/@tinyhttp/accepts/dist/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,IAAI,CAAC,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAE1E,OAAO,UAAU,MAAM,YAAY,CAAA;AAMnC,qBAAa,OAAO;IAClB,OAAO,EAAE,mBAAmB,CAAA;IAC5B,UAAU,EAAE,UAAU,CAAA;gBACV,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC;IAInC;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK;IA0B7E,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,CAErF;IACD;;;;;;;OAOG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO;IAevF,IAAI,QAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAE/F;IACD;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO;IAetF,IAAI,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAE7F;IACD;;;;;;;;OAQG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO;IAevF,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAE3F;IACD,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAE5F;IACD,IAAI,QAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAE/F;CACF"}

117
node_modules/@tinyhttp/accepts/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
import mime from 'mime';
import Negotiator from 'negotiator';
const extToMime = (type) => (type.indexOf('/') === -1 ? mime.getType(type) : type);
const validMime = (type) => typeof type === 'string';
export class Accepts {
constructor(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 `false`, 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. When no types are given as arguments, returns all types accepted by the client in the preference order.
*/
types(types, ...args) {
let mimeTypes = [];
// support flattened arguments
if (types && !Array.isArray(types)) {
mimeTypes = [types, ...args];
}
else if (types) {
mimeTypes = [...types, ...args];
}
// no types, return all requested types
if (!mimeTypes || mimeTypes.length === 0) {
return this.negotiator.mediaTypes();
}
// no accept header, return first given type
if (!this.headers.accept) {
return mimeTypes[0];
}
const mimes = mimeTypes.map(extToMime);
const accepts = this.negotiator.mediaTypes(mimes.filter(validMime));
const [first] = accepts;
return first ? mimeTypes[mimes.indexOf(first)] : false;
}
get type() {
return this.types;
}
/**
* Return accepted encodings or best fit based on `encodings`.
*
* Given `Accept-Encoding: gzip, deflate`
* an array sorted by quality is returned:
*
* ['gzip', 'deflate']
*/
encodings(encodings, ...args) {
let _encodings = encodings;
// support flattened arguments
if (_encodings && !Array.isArray(_encodings)) {
_encodings = [_encodings, ...args];
}
// no encodings, return all requested encodings
if (!_encodings || _encodings.length === 0) {
return this.negotiator.encodings();
}
return this.negotiator.encodings(_encodings)[0] || false;
}
get encoding() {
return this.encodings;
}
/**
* 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']
*/
charsets(charsets, ...args) {
let _charsets = charsets;
// support flattened arguments
if (_charsets && !Array.isArray(_charsets)) {
_charsets = [_charsets, ...args];
}
// no charsets, return all requested charsets
if (!_charsets || _charsets.length === 0) {
return this.negotiator.charsets();
}
return this.negotiator.charsets(_charsets)[0] || false;
}
get charset() {
return this.charsets;
}
/**
* 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']
*
*/
languages(languages, ...args) {
let _languages = languages;
// support flattened arguments
if (_languages && !Array.isArray(_languages)) {
_languages = [_languages, ...args];
}
// no languages, return all requested languages
if (!_languages || _languages.length === 0) {
return this.negotiator.languages();
}
return this.negotiator.languages(_languages)[0] || false;
}
get lang() {
return this.languages;
}
get langs() {
return this.languages;
}
get language() {
return this.languages;
}
}
//# sourceMappingURL=index.js.map

1
node_modules/@tinyhttp/accepts/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAE1F,MAAM,SAAS,GAAG,CAAC,IAAa,EAAW,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAA;AAEtE,MAAM,OAAO,OAAO;IAGlB,YAAY,GAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAA;IACvC,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,KAAwB,EAAE,GAAG,IAAc;QAC/C,IAAI,SAAS,GAAa,EAAE,CAAA;QAE5B,8BAA8B;QAC9B,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAA;QAC9B,CAAC;aAAM,IAAI,KAAK,EAAE,CAAC;YACjB,SAAS,GAAG,CAAC,GAAG,KA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ACD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;CACF"}

35
node_modules/@tinyhttp/accepts/package.json generated vendored Normal file
View File

@@ -0,0 +1,35 @@
{
"name": "@tinyhttp/accepts",
"description": "accepts rewrite in TypeScript",
"version": "2.2.3",
"license": "MIT",
"homepage": "https://tinyhttp.v1rtl.site",
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
},
"repository": {
"type": "git",
"url": "https://github.com/tinyhttp/tinyhttp.git",
"directory": "packages/cookie-signature"
},
"engines": {
"node": ">=12.20.0"
},
"type": "module",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"files": [
"dist"
],
"devDependencies": {
"@types/negotiator": "^0.6.3"
},
"dependencies": {
"mime": "4.0.4",
"negotiator": "^0.6.3"
},
"scripts": {
"build": "tsc"
}
}

21
node_modules/@tinyhttp/app/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

25
node_modules/@tinyhttp/app/README.md generated vendored Normal file
View File

@@ -0,0 +1,25 @@
# @tinyhttp/app
The core of tinyhttp. Contains the `App`, `Request` and `Response`. Additionally, it provides special tinyhttp-specific types.
## Install
```sh
pnpm i @tinyhttp/app
```
## Example
```ts
import { App } from '@tinyhttp/app'
import type { Request, Response, NextFunction } from '@tinyhttp/app'
new App()
.use((req: Request, res: Response, next: NextFunction) => {
console.log('Did a request')
next()
})
.get('/', (_, res) => res.send('<h1>Hello World</h1>'))
.get('/page/:page', (req, res) => res.send(`You opened ${req.params.page}`))
.listen(3000)
```

55
node_modules/@tinyhttp/app/dist/app.d.ts generated vendored Normal file
View File

@@ -0,0 +1,55 @@
import { type Server } from 'node:http';
import type { Handler, Middleware, NextFunction, UseMethodParams } from '@tinyhttp/router';
import { Router } from '@tinyhttp/router';
import type { TemplateEngineOptions } from './index.js';
import type { ErrorHandler } from './onError.js';
import type { Request } from './request.js';
import type { Response } from './response.js';
import type { AppConstructor, AppInterface, AppRenderOptions, AppSettings, TemplateEngine } from './types.js';
/**
* `App` class - the starting point of tinyhttp app.
*
* With the `App` you can:
* * use routing methods and `.use(...)`
* * set no match (404) and error (500) handlers
* * configure template engines
* * store data in locals
* * listen the http server on a specified port
*
* In case you use TypeScript, you can pass custom types to this class because it is also a generic class.
*
* Example:
*
* ```ts
* interface CoolReq extends Request {
* genericsAreDope: boolean
* }
*
* const app = App<any, CoolReq, Response>()
* ```
*/
export declare class App<Req extends Request = Request, Res extends Response = Response> extends Router<App, Req, Res> implements AppInterface<Req, Res> {
#private;
middleware: Middleware<Req, Res>[];
locals: Record<string, unknown>;
noMatchHandler: Handler;
onError: ErrorHandler;
settings: AppSettings;
engines: Record<string, TemplateEngine>;
applyExtensions?: Handler;
attach: (req: Req, res: Res, next?: NextFunction) => void;
cache: Record<string, unknown>;
constructor(options?: AppConstructor<Req, Res>);
set<K extends keyof AppSettings>(setting: K, value: AppSettings[K]): this;
enable<K extends keyof AppSettings>(setting: K): this;
enabled<K extends keyof AppSettings>(setting: K): boolean;
disable<K extends keyof AppSettings>(setting: K): this;
path(): any;
engine<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(ext: string, fn: TemplateEngine<RenderOptions>): this;
render<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(name: string, data?: Record<string, unknown>, options?: AppRenderOptions<RenderOptions>, cb?: (err: unknown, html?: unknown) => void): void;
use(...args: UseMethodParams<Req, Res, AppInterface<any, any>>): this;
route(path: string): App<any, any>;
handler<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(req: Req, res: Res, next?: NextFunction): void;
listen(port?: number, cb?: () => void, host?: string): Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
}
//# sourceMappingURL=app.d.ts.map

1
node_modules/@tinyhttp/app/dist/app.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,WAAW,CAAA;AAErD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAkB,MAAM,kBAAkB,CAAA;AAGzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGhD,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YA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AAM,EACX,EAAE,EAAE,cAAc,CAAC,aAAa,CAAC,GAChC,IAAI;IAKP,MAAM,CAAC,aAAa,SAAS,qBAAqB,GAAG,qBAAqB,EACxE,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAClC,OAAO,GAAE,gBAAgB,CAAC,aAAa,CAAyC,EAChF,EAAE,GAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAe;IA0CvD,GAAG,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI;IAmErE,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;IAsBlC,OAAO,CAAC,aAAa,SAAS,qBAAqB,GAAG,qBAAqB,EACzE,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,CAAC,EAAE,YAAY;IAmHrB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM;CAGrD"}

323
node_modules/@tinyhttp/app/dist/app.js generated vendored Normal file
View File

@@ -0,0 +1,323 @@
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _App_instances, _App_find;
import { createServer } from 'node:http';
import { getPathname } from '@tinyhttp/req';
import { Router, pushMiddleware } from '@tinyhttp/router';
import { parse as rg } from 'regexparam';
import { extendMiddleware } from './extend.js';
import { onErrorHandler } from './onError.js';
import { getURLParams } from './request.js';
import { View } from './view.js';
/**
* Add leading slash if not present (e.g. path -> /path, /path -> /path)
* @param x
*/
const lead = (x) => (x.charCodeAt(0) === 47 ? x : `/${x}`);
const trail = (x) => (x.charCodeAt(x.length - 1) === 47 ? x.substring(0, x.length - 1) : x);
const mount = (fn) => (fn instanceof App ? fn.attach : fn);
const applyHandler = (h) => async (req, res, next) => {
try {
if (h[Symbol.toStringTag] === 'AsyncFunction') {
await h(req, res, next);
}
else
h(req, res, next);
}
catch (e) {
next === null || next === void 0 ? void 0 : next(e);
}
};
/**
* `App` class - the starting point of tinyhttp app.
*
* With the `App` you can:
* * use routing methods and `.use(...)`
* * set no match (404) and error (500) handlers
* * configure template engines
* * store data in locals
* * listen the http server on a specified port
*
* In case you use TypeScript, you can pass custom types to this class because it is also a generic class.
*
* Example:
*
* ```ts
* interface CoolReq extends Request {
* genericsAreDope: boolean
* }
*
* const app = App<any, CoolReq, Response>()
* ```
*/
export class App extends Router {
constructor(options = {}) {
super();
_App_instances.add(this);
this.middleware = [];
this.locals = {};
this.engines = {};
this.onError = (options === null || options === void 0 ? void 0 : options.onError) || onErrorHandler;
// @ts-expect-error typescript is not smart enough to understand "this" ts(2345)
this.noMatchHandler = (options === null || options === void 0 ? void 0 : options.noMatchHandler) || this.onError.bind(this, { code: 404 });
this.settings = {
view: View,
xPoweredBy: true,
views: `${process.cwd()}/views`,
'view cache': process.env.NODE_ENV === 'production',
'trust proxy': 0,
...options.settings
};
if (options.applyExtensions)
this.applyExtensions = options === null || options === void 0 ? void 0 : options.applyExtensions;
const boundHandler = this.handler.bind(this);
this.attach = (req, res, next) => setImmediate(boundHandler, req, res, next);
this.cache = {};
}
set(setting, value) {
this.settings[setting] = value;
return this;
}
enable(setting) {
this.settings[setting] = true;
return this;
}
enabled(setting) {
return Boolean(this.settings[setting]);
}
disable(setting) {
this.settings[setting] = false;
return this;
}
path() {
return this.parent ? this.parent.path() + this.mountpath : '';
}
engine(ext, fn) {
this.engines[ext[0] === '.' ? ext : `.${ext}`] = fn;
return this;
}
render(name, data = {}, options = {}, cb = () => { }) {
let view;
const { _locals, ...opts } = options;
let locals = this.locals;
if (_locals)
locals = { ...locals, ..._locals };
locals = { ...locals, ...data };
if (opts.cache == null)
opts.cache = this.enabled('view cache');
if (opts.cache) {
view = this.cache[name];
}
if (!view) {
const ViewClass = this.settings.view || View;
try {
view = new ViewClass(name, {
defaultEngine: this.settings['view engine'],
root: this.settings.views,
engines: this.engines
});
}
catch (err) {
return cb(err);
}
if (opts.cache) {
this.cache[name] = view;
}
}
try {
view.render(opts, locals, cb);
}
catch (err) {
cb(err);
}
}
use(...args) {
var _a;
const base = args[0];
const fns = args.slice(1).flat();
let pathArray = [];
if (typeof base === 'function' || base instanceof App) {
fns.unshift(base);
}
else {
// if base is not an array of paths, then convert it to an array.
let basePaths = [];
if (Array.isArray(base))
basePaths = base;
else if (typeof base === 'string')
basePaths = [base];
basePaths = basePaths.filter((element) => {
if (typeof element === 'string') {
pathArray.push(element);
return false;
}
return true;
});
fns.unshift(...basePaths);
}
pathArray = pathArray.length ? pathArray.map((path) => lead(path)) : ['/'];
const mountpath = pathArray.join(', ');
let regex;
for (const fn of fns) {
if (fn instanceof App) {
for (const path of pathArray) {
regex = rg(path, true);
fn.mountpath = mountpath;
this.apps[path] = fn;
// @ts-expect-error typescript is not smart enough to understand "this" ts(2345)
fn.parent = this;
}
}
}
for (const path of pathArray) {
const handlerPaths = [];
const handlerFunctions = [];
const handlerPathBase = path === '/' ? '' : lead(path);
for (const fn of fns) {
if (fn instanceof App && ((_a = fn.middleware) === null || _a === void 0 ? void 0 : _a.length)) {
for (const mw of fn.middleware) {
handlerPaths.push(handlerPathBase + lead(mw.path));
handlerFunctions.push(fn);
}
}
else {
handlerPaths.push('');
handlerFunctions.push(fn);
}
}
pushMiddleware(this.middleware)({
path,
regex,
type: 'mw',
handler: mount(handlerFunctions[0]),
handlers: handlerFunctions.slice(1).map(mount),
fullPaths: handlerPaths
});
}
return this;
}
route(path) {
const app = new App({ settings: this.settings });
this.use(path, app);
return app;
}
handler(req, res, next) {
/* Set X-Powered-By header */
const { xPoweredBy } = this.settings;
if (xPoweredBy)
res.setHeader('X-Powered-By', typeof xPoweredBy === 'string' ? xPoweredBy : 'tinyhttp');
// @ts-expect-error typescript is not smart enough to understand "this" ts(2345)
const exts = this.applyExtensions || extendMiddleware(this);
let mw = [
{
handler: exts,
type: 'mw',
path: '/'
}
];
req.baseUrl = '';
const handle = (mw, pathname) => async (req, res, next) => {
var _a;
const { path, handler, regex } = mw;
let params;
try {
params = regex ? getURLParams(regex, pathname) : {};
}
catch (e) {
console.error(e);
if (e instanceof URIError)
return res.sendStatus(400);
throw e;
}
let prefix = path;
if (regex) {
for (const key of regex.keys) {
if (key === 'wild') {
prefix = prefix.replace('*', params.wild);
}
else {
prefix = prefix.replace(`:${key}`, params[key]);
}
}
}
req.params = { ...req.params, ...params };
if (mw.type === 'mw') {
req.url = lead(req.originalUrl.substring(prefix.length));
req.baseUrl = trail(req.originalUrl.substring(0, prefix.length));
}
if (!req.path)
req.path = pathname;
if ((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enableReqRoute)
req.route = mw;
await applyHandler(handler)(req, res, next);
};
let idx = 0;
const loop = () => {
req.originalUrl = req.baseUrl + req.url;
const pathname = getPathname(req.url);
const matched = __classPrivateFieldGet(this, _App_instances, "m", _App_find).call(this, pathname).filter((x) => (req.method === 'HEAD' || (x.method ? x.method === req.method : true)) && !mw.includes(x));
if (matched.length && matched[0] !== null) {
if (idx !== 0) {
idx = mw.length;
req.params = {};
}
mw = [
...mw,
...matched,
{
type: 'mw',
handler: (req, res, next) => {
if (req.method === 'HEAD') {
res.statusCode = 204;
return res.end('');
}
next === null || next === void 0 ? void 0 : next();
},
path: '/'
}
];
}
else if (this.parent == null) {
mw.push({
handler: this.noMatchHandler,
type: 'route',
path: '/'
});
}
void handle(mw[idx++], pathname)(req, res, next);
};
const parentNext = next;
next = (err) => {
if (err != null) {
// @ts-expect-error The 'this' context of type 'this' is not assignable to method's 'this' of type 'App<Request, Response<unknown>>' ts(2345)
return this.onError(err, req, res);
}
if (res.writableEnded)
return;
if (idx >= mw.length) {
if (parentNext != null)
parentNext();
return;
}
loop();
};
loop();
}
listen(port, cb, host) {
return createServer().on('request', this.attach).listen(port, host, cb);
}
}
_App_instances = new WeakSet(), _App_find = function _App_find(url) {
return this.middleware.filter((m) => {
m.regex = m.regex || rg(m.path, m.type === 'mw');
let fullPathRegex;
m.fullPath && typeof m.fullPath === 'string'
? (fullPathRegex = rg(m.fullPath, m.type === 'mw'))
: (fullPathRegex = null);
return m.regex.pattern.test(url) && (m.type === 'mw' && fullPathRegex ? fullPathRegex.pattern.test(url) : true);
});
};
//# sourceMappingURL=app.js.map

1
node_modules/@tinyhttp/app/dist/app.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

8
node_modules/@tinyhttp/app/dist/extend.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type { App } from './app.js';
import type { Handler } from './index.js';
import type { TemplateEngineOptions } from './types.js';
/**
* Extends Request and Response objects with custom properties and methods
*/
export declare const extendMiddleware: <EngineOptions extends TemplateEngineOptions = TemplateEngineOptions>(app: App) => Handler;
//# sourceMappingURL=extend.d.ts.map

1
node_modules/@tinyhttp/app/dist/extend.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../src/extend.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAKzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,aAAa,SAAS,qBAAqB,+BAA+B,GAAG,KA+DtG,OAAO,CAAA"}

64
node_modules/@tinyhttp/app/dist/extend.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
import { compile } from '@tinyhttp/proxy-addr';
import { checkIfXMLHttpRequest, getAccepts, getAcceptsCharsets, getAcceptsEncodings, getAcceptsLanguages, getFreshOrStale, getQueryParams, getRangeFromHeader, getRequestHeader, reqIs } from '@tinyhttp/req';
import { append, attachment, clearCookie, download, formatResponse, getResponseHeader, json, redirect, send, sendFile, sendStatus, setContentType, setCookie, setHeader, setLinksHeader, setLocationHeader, setVaryHeader, status } from '@tinyhttp/res';
import { getSubdomains } from './request.js';
import { getHost, getIP, getIPs, getProtocol } from './request.js';
import { renderTemplate } from './response.js';
/**
* Extends Request and Response objects with custom properties and methods
*/
export const extendMiddleware = (app) => ((req, res, next) => {
const { settings } = app;
res.get = getResponseHeader(res);
req.get = getRequestHeader(req);
if (settings === null || settings === void 0 ? void 0 : settings.bindAppToReqRes) {
req.app = app;
res.app = app;
}
if (settings === null || settings === void 0 ? void 0 : settings.networkExtensions) {
let trust = (settings === null || settings === void 0 ? void 0 : settings['trust proxy']) || 0;
if (trust && typeof trust !== 'function') {
trust = compile(trust);
settings['trust proxy'] = trust;
}
req.protocol = getProtocol(req, trust);
req.secure = req.protocol === 'https';
const host = getHost(req, trust);
req.hostname = host === null || host === void 0 ? void 0 : host.hostname;
req.port = host === null || host === void 0 ? void 0 : host.port;
req.subdomains = getSubdomains(req, trust, settings.subdomainOffset);
req.ip = getIP(req, trust);
req.ips = getIPs(req, trust);
}
req.query = getQueryParams(req.url);
req.is = reqIs(req);
req.range = getRangeFromHeader(req);
req.accepts = getAccepts(req);
req.acceptsCharsets = getAcceptsCharsets(req);
req.acceptsEncodings = getAcceptsEncodings(req);
req.acceptsLanguages = getAcceptsLanguages(req);
req.xhr = checkIfXMLHttpRequest(req);
res.header = res.set = setHeader(res);
res.send = send(req, res);
res.json = json(res);
res.status = status(res);
res.sendStatus = sendStatus(req, res);
res.sendFile = sendFile(req, res);
res.type = setContentType(res);
res.location = setLocationHeader(req, res);
res.links = setLinksHeader(res);
res.vary = setVaryHeader(res);
res.cookie = setCookie(req, res);
res.clearCookie = clearCookie(req, res);
res.render = renderTemplate(req, res, app);
res.format = formatResponse(req, res, next);
res.redirect = redirect(req, res, next);
res.attachment = attachment(res);
res.download = download(req, res);
res.append = append(res);
res.locals = res.locals || Object.create(null);
Object.defineProperty(req, 'fresh', { get: getFreshOrStale.bind(null, req, res), configurable: true });
req.stale = !req.fresh;
next();
});
//# sourceMappingURL=extend.js.map

1
node_modules/@tinyhttp/app/dist/extend.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../src/extend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACN,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,MAAM,EACN,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,MAAM,EACP,MAAM,eAAe,CAAA;AAItB,OAAO,EAAgB,aAAa,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAG9C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAsE,GAAQ,EAAE,EAAE,CAChH,CAAC,CAAC,GAAY,EAAE,GAA4B,EAAE,IAAkB,EAAE,EAAE;IAClE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IAExB,GAAG,CAAC,GAAG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C,MAAM,GAAG,SAAS,CAAoB,GAAG,EAAE,GAAG,CAAC,CAAA;IACnD,GAAG,CAAC,WAAW,GAAG,WAAW,CAAoB,GAAG,EAAE,GAAG,CAAC,CAAA;IAC1D,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAC1C,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IACvC,GAAG,CAAC,UAAU,GAAG,UAAU,CAAW,GAAG,CAAC,CAAA;IAC1C,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAoB,GAAG,EAAE,GAAG,CAAC,CAAA;IACpD,GAAG,CAAC,MAAM,GAAG,MAAM,CAAW,GAAG,CAAC,CAAA;IAClC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAE9C,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;IACtG,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAA;IAEtB,IAAI,EAAE,CAAA;AACR,CAAC,CAAY,CAAA"}

15
node_modules/@tinyhttp/app/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
export { App } from './app.js';
export * from './request.js';
export * from './response.js';
export { extendMiddleware } from './extend.js';
export { onErrorHandler, type ErrorHandler } from './onError.js';
export { View } from './view.js';
export type { AppSettings, TemplateEngineOptions, TemplateEngine, AppConstructor } from './types.js';
import type { Middleware, NextFunction, AsyncHandler as RAsyncHandler, Handler as RHandler, SyncHandler as RSyncHandler } from '@tinyhttp/router';
import type { Request } from './request.js';
import type { Response } from './response.js';
export type Handler = RHandler<Request, Response>;
export type AsyncHandler = RAsyncHandler<Request, Response>;
export type SyncHandler = RSyncHandler<Request, Response>;
export type { NextFunction, Middleware, Request, Response };
//# sourceMappingURL=index.d.ts.map

1
node_modules/@tinyhttp/app/dist/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEpG,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,YAAY,IAAI,aAAa,EAC7B,OAAO,IAAI,QAAQ,EACnB,WAAW,IAAI,YAAY,EAC5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACjD,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AAC3D,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACzD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA"}

7
node_modules/@tinyhttp/app/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export { App } from './app.js';
export * from './request.js';
export * from './response.js';
export { extendMiddleware } from './extend.js';
export { onErrorHandler } from './onError.js';
export { View } from './view.js';
//# sourceMappingURL=index.js.map

1
node_modules/@tinyhttp/app/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}

7
node_modules/@tinyhttp/app/dist/onError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import type { NextFunction } from '@tinyhttp/router';
import type { App } from './app.js';
import type { Request } from './request.js';
import type { Response } from './response.js';
export type ErrorHandler = (this: App, err: any, req: Request, res: Response, next?: NextFunction) => void;
export declare const onErrorHandler: ErrorHandler;
//# sourceMappingURL=onError.d.ts.map

1
node_modules/@tinyhttp/app/dist/onError.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"onError.d.ts","sourceRoot":"","sources":["../src/onError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAA;AAE1G,eAAO,MAAM,cAAc,EAAE,YAU5B,CAAA"}

15
node_modules/@tinyhttp/app/dist/onError.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { STATUS_CODES } from 'node:http';
export const onErrorHandler = function (err, _req, res) {
if (this.onError === onErrorHandler && this.parent)
return this.parent.onError(err, _req, res);
if (err instanceof Error)
console.error(err);
const code = err.code in STATUS_CODES ? err.code : err.status;
if (typeof err === 'string' || Buffer.isBuffer(err))
res.writeHead(500).end(err);
else if (code in STATUS_CODES)
res.writeHead(code).end(STATUS_CODES[code]);
else
res.writeHead(500).end(err.message);
};
//# sourceMappingURL=onError.js.map

1
node_modules/@tinyhttp/app/dist/onError.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"onError.js","sourceRoot":"","sources":["../src/onError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAQxC,MAAM,CAAC,MAAM,cAAc,GAAiB,UAAqB,GAAQ,EAAE,IAAa,EAAE,GAAa;IACrG,IAAI,IAAI,CAAC,OAAO,KAAK,cAAc,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAE9F,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE5C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAA;IAE7D,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;SAC3E,IAAI,IAAI,IAAI,YAAY;QAAE,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;;QACrE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AAC1C,CAAC,CAAA"}

59
node_modules/@tinyhttp/app/dist/request.d.ts generated vendored Normal file
View File

@@ -0,0 +1,59 @@
import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
import type { ParsedUrlQuery } from 'node:querystring';
import { type Trust } from '@tinyhttp/proxy-addr';
import type { Options, Ranges } from 'header-range-parser';
import type { Middleware } from '@tinyhttp/router';
import type { App } from './app.js';
import type { Socket } from 'node:net';
import type { TLSSocket } from 'node:tls';
import type { URLParams } from '@tinyhttp/req';
export { getURLParams } from '@tinyhttp/req';
export type Host = {
hostname: string;
port?: number;
};
export declare const getProtocol: (req: Request, trust: Trust) => Protocol;
export declare const getHost: (req: Request, trust: Trust) => Host | undefined;
export declare const getIP: (req: Pick<Request, "headers" | "connection" | "socket">, trust: Trust) => string | undefined;
export declare const getIPs: (req: Pick<Request, "headers" | "connection" | "socket">, trust: Trust) => string[] | undefined;
export declare const getSubdomains: (req: Request, trust: Trust, subdomainOffset?: number) => string[];
export type Connection = IncomingMessage['socket'] & {
encrypted: boolean;
};
export type Protocol = 'http' | 'https' | string;
export type { URLParams };
type AcceptsReturns = string | boolean | string[];
export interface Request extends IncomingMessage {
originalUrl: string;
path: string;
url: string;
baseUrl: string;
query: ParsedUrlQuery;
params: URLParams;
connection: Connection;
socket: TLSSocket | Socket;
route?: Middleware;
protocol: Protocol;
secure: boolean;
xhr: boolean;
hostname?: string;
port?: number;
ip?: string;
ips?: string[];
subdomains?: string[];
get: <HeaderName extends string>(header: HeaderName) => IncomingHttpHeaders[HeaderName];
range: (size: number, options?: Options) => -1 | -2 | -3 | Ranges | undefined;
accepts: (...types: string[]) => AcceptsReturns;
acceptsEncodings: (...encodings: string[]) => AcceptsReturns;
acceptsCharsets: (...charsets: string[]) => AcceptsReturns;
acceptsLanguages: (...languages: string[]) => AcceptsReturns;
is: (...types: string[]) => string | boolean;
cookies?: any;
signedCookies?: any;
secret?: string | string[];
fresh?: boolean;
stale?: boolean;
body?: any;
app?: App;
}
//# sourceMappingURL=request.d.ts.map

1
node_modules/@tinyhttp/app/dist/request.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,KAAK,KAAK,EAAwC,MAAM,sBAAsB,CAAA;AACvF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAGnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAQD,eAAO,MAAM,WAAW,QAAS,OAAO,SAAS,KAAK,KAAG,QAUxD,CAAA;AAgDD,eAAO,MAAM,OAAO,QAAS,OAAO,SAAS,KAAK,KAAG,IAAI,GAAG,SAY3D,CAAA;AAED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ACrB,GAAG,EAAE,CAAC,UAAU,SAAS,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,mBAAmB,CAAC,UAAU,CAAC,CAAA;IACvF,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,SAAS,CAAA;IAC7E,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,cAAc,CAAA;IAC/C,gBAAgB,EAAE,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,KAAK,cAAc,CAAA;IAC5D,eAAe,EAAE,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,KAAK,cAAc,CAAA;IAC1D,gBAAgB,EAAE,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,KAAK,cAAc,CAAA;IAC5D,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,OAAO,CAAA;IAC5C,OAAO,CAAC,EAAE,GAAG,CAAA;IACb,aAAa,CAAC,EAAE,GAAG,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,GAAG,CAAC,EAAE,GAAG,CAAA;CACV"}

85
node_modules/@tinyhttp/app/dist/request.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
import { all, compile, proxyaddr as proxyAddr } from '@tinyhttp/proxy-addr';
import { isIP } from 'node:net';
export { getURLParams } from '@tinyhttp/req';
const trustRemoteAddress = ({ socket }, trust) => {
const val = socket.remoteAddress;
if (typeof trust !== 'function')
trust = compile(trust);
return trust(val, 0);
};
export const getProtocol = (req, trust) => {
const proto = `http${req.secure ? 's' : ''}`;
if (!trustRemoteAddress(req, trust))
return proto;
const header = req.headers['X-Forwarded-Proto'] || proto;
const index = header.indexOf(',');
return index !== -1 ? header.substring(0, index).trim() : header.trim();
};
const normalizeHostString = (host) => decodeURIComponent(host).toLowerCase().normalize();
const getAuthorityHeaderHostString = (req) => {
const authority = req.get(':authority');
if (Array.isArray(authority))
return undefined;
if (Array.isArray(authority) || !authority)
return undefined;
const index = authority.indexOf('@');
if (index === -1)
return normalizeHostString(authority);
return normalizeHostString(authority.substring(index + 1));
};
const getForwardedHeaderHostString = (req) => {
const forwardedHost = req.get('x-forwarded-host');
if (Array.isArray(forwardedHost))
return undefined;
if (!forwardedHost)
return undefined;
return normalizeHostString(forwardedHost);
};
const getDefaultHeaderHostString = (req) => {
const host = req.get('host');
if (!host || host.indexOf(',') !== -1)
return undefined;
if (host.indexOf(',') !== -1)
return undefined;
return normalizeHostString(host);
};
const getHostString = (req, trust) => {
var _a;
if (trustRemoteAddress(req, trust)) {
const forwardedHost = getForwardedHeaderHostString(req);
if (forwardedHost)
return forwardedHost;
}
const authorityHost = getAuthorityHeaderHostString(req);
const defaultHost = getDefaultHeaderHostString(req);
if (authorityHost && defaultHost) {
if (authorityHost !== defaultHost)
throw new Error('Request `:authority` pseudo-header does not agree with `Host` header');
return authorityHost;
}
return (_a = authorityHost !== null && authorityHost !== void 0 ? authorityHost : defaultHost) !== null && _a !== void 0 ? _a : undefined;
};
export const getHost = (req, trust) => {
const host = getHostString(req, trust);
if (!host)
return undefined;
// IPv6 literal support
const index = host.indexOf(':', host[0] === '[' ? host.indexOf(']') + 1 : 0);
if (index === -1)
return { hostname: host };
const hostname = host.substring(0, index);
const port = Number(host.substring(index + 1));
if (Number.isNaN(port))
throw new TypeError('Port number is NaN, therefore Host is malformed');
return { hostname, port };
};
export const getIP = (req, trust) => proxyAddr(req, trust).replace(/^.*:/, ''); // striping the redundant prefix addeded by OS to IPv4 address
export const getIPs = (req, trust) => all(req, trust);
export const getSubdomains = (req, trust, subdomainOffset = 2) => {
const host = getHost(req, trust);
if (!(host === null || host === void 0 ? void 0 : host.hostname))
return [];
const subdomains = isIP(host.hostname) ? [host.hostname] : host.hostname.split('.').reverse();
return subdomains.slice(subdomainOffset);
};
//# sourceMappingURL=request.js.map

1
node_modules/@tinyhttp/app/dist/request.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,GAAG,EAAE,OAAO,EAAE,SAAS,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAMvF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAK/B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAO5C,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAuC,EAAE,KAAY,EAAW,EAAE;IACpG,MAAM,GAAG,GAAG,MAAM,CAAC,aAAuB,CAAA;IAC1C,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IACvD,OAAO,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;AACtB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAY,EAAE,KAAY,EAAY,EAAE;IAClE,MAAM,KAAK,GAAG,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAE5C,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAEjD,MAAM,MAAM,GAAI,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAY,IAAI,KAAK,CAAA;IAEpE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAEjC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAA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C1C,CAAC,CAAA"}

44
node_modules/@tinyhttp/app/dist/response.d.ts generated vendored Normal file
View File

@@ -0,0 +1,44 @@
import type { OutgoingHttpHeaders, ServerResponse } from 'node:http';
import type { SerializeOptions } from '@tinyhttp/cookie';
import type { DownloadOptions, FormatProps, SendFileOptions } from '@tinyhttp/res';
import type { App } from './app.js';
import type { Request } from './request.js';
import type { AppRenderOptions, TemplateEngineOptions } from './types.js';
export declare const renderTemplate: <O extends TemplateEngineOptions = TemplateEngineOptions>(_req: Request, res: Response, app: App) => (file: string, data?: Record<string, unknown>, options?: AppRenderOptions<O>) => Response;
export interface Response<B = unknown> extends ServerResponse {
header(field: string | Record<string, unknown>, val?: string | any[]): Response<B>;
set(field: string | Record<string, unknown>, val?: string | any[]): Response<B>;
get<HeaderName extends string>(field: HeaderName): OutgoingHttpHeaders[HeaderName];
send(body: B): Response<B>;
sendFile(path: string, options?: SendFileOptions, cb?: (err?: unknown) => void): Response<B>;
json(body: B): Response<B>;
status(status: number): Response<B>;
sendStatus(statusCode: number): Response<B>;
cookie(name: string, value: string | Record<string, unknown>, options?: SerializeOptions & Partial<{
signed: boolean;
}>): Response<B>;
clearCookie(name: string, options?: SerializeOptions): Response<B>;
location(url: string): Response<B>;
links(links: {
[key: string]: string;
}): Response<B>;
render<O extends TemplateEngineOptions = TemplateEngineOptions>(file: string, data?: Record<string, any>, options?: AppRenderOptions<O>): Response<B>;
vary(field: string): Response<B>;
format(obj: FormatProps): Response<B>;
redirect(url: string, status?: number): Response<B>;
type(type: string): Response<B>;
download(path: string, filename: string, options?: DownloadOptions, cb?: (err?: unknown) => void): Response<B>;
attachment(filename?: string): Response<B>;
app?: App;
locals: Record<string, any>;
/**
* Send JSON response with JSONP callback support.
*
* To enable this method, install the `@tinyhttp/jsonp` package and attach the method to `res.jsonp` property.
*
* @param obj Response object
*/
jsonp(obj: any): Response<B>;
append(field: string, value: any): Response<B>;
}
//# sourceMappingURL=response.d.ts.map

1
node_modules/@tinyhttp/app/dist/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AC,CAAC,CAAC,CAAA;IAChC,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IACnD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC9G,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC1C,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAE5B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;CAC/C"}

9
node_modules/@tinyhttp/app/dist/response.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export const renderTemplate = (_req, res, app) => (file, data, options) => {
app.render(file, data ? { ...res.locals, ...data } : res.locals, options, (err, html) => {
if (err)
throw err;
res.send(html);
});
return res;
};
//# sourceMappingURL=response.js.map

1
node_modules/@tinyhttp/app/dist/response.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"response.js","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,cAAc,GACzB,CAA0D,IAAa,EAAE,GAAa,EAAE,GAAQ,EAAE,EAAE,CACpG,CAAC,IAAY,EAAE,IAA8B,EAAE,OAA6B,EAAY,EAAE;IACxF,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAY,EAAE,IAAa,EAAE,EAAE;QACxG,IAAI,GAAG;YAAE,MAAM,GAAG,CAAA;QAClB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}

108
node_modules/@tinyhttp/app/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,108 @@
import type { Server } from 'node:http';
import type { Trust } from '@tinyhttp/proxy-addr';
import type { Handler, NextFunction, RouterInterface, UseMethodParams } from '@tinyhttp/router';
import type { ErrorHandler } from './onError.js';
import type { Request } from './request.js';
import type { Response } from './response.js';
import type { View } from './view.js';
/**
* tinyhttp App has a few settings for toggling features
*/
export type AppSettings = Partial<{
networkExtensions: boolean;
subdomainOffset: number;
bindAppToReqRes: boolean;
xPoweredBy: string | boolean;
enableReqRoute: boolean;
views: string | string[];
view: typeof View;
'view cache': boolean;
'view engine': string;
'trust proxy': Trust;
}>;
export type TemplateEngineOptions = {
[key: string]: unknown;
cache?: boolean;
};
/**
* Function that processes the template
*/
export type TemplateEngine<O extends TemplateEngineOptions = TemplateEngineOptions> = (path: string, locals: Record<string, unknown>, opts: AppRenderOptions<O>, cb: (err: Error | null, html: unknown) => void) => void;
export type AppRenderOptions<O extends TemplateEngineOptions = TemplateEngineOptions> = O & Partial<{
cache: boolean;
ext: string;
viewsFolder: string;
_locals: Record<string, unknown>;
}>;
export type AppConstructor<Req extends Request = Request, Res extends Response = Response> = Partial<{
noMatchHandler: Handler<Req, Res>;
onError: ErrorHandler;
settings: AppSettings;
applyExtensions: Handler<Req, Res>;
new (options: AppConstructor<Req, Res>): AppInterface<Req, Res>;
}>;
export interface AppInterface<Req extends Request, Res extends Response> extends RouterInterface<AppInterface<Req, Res>, Req, Res> {
/**
* Set app setting
* @param setting setting name
* @param value setting value
*/
set<K extends keyof AppSettings>(setting: K, value: AppSettings[K]): AppInterface<Req, Res>;
/**
* Enable app setting
* @param setting Setting name
*/
enable<K extends keyof AppSettings>(setting: K): AppInterface<Req, Res>;
/**
* Check if setting is enabled
* @param setting Setting name
* @returns
*/
enabled<K extends keyof AppSettings>(setting: K): boolean;
/**
* Disable app setting
* @param setting Setting name
*/
disable<K extends keyof AppSettings>(setting: K): AppInterface<Req, Res>;
/**
* Return the app's absolute pathname
* based on the parent(s) that have
* mounted it.
*
* For example if the application was
* mounted as `"/admin"`, which itself
* was mounted as `"/blog"` then the
* return value would be `"/blog/admin"`.
*
*/
path(): string;
/**
* Register a template engine with extension
*/
engine<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(ext: string, fn: TemplateEngine<RenderOptions>): AppInterface<Req, Res>;
/**
* Render a template
* @param name What to render
* @param data data that is passed to a template
* @param options Template engine options
* @param cb Callback that consumes error and html
*/
render<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions>(name: string, data: Record<string, unknown>, options: AppRenderOptions<RenderOptions>, cb: (err: unknown, html?: unknown) => void): void;
use(...args: UseMethodParams<Req, Res, AppInterface<any, any>>): AppInterface<Req, Res>;
route(path: string): AppInterface<Req, Res>;
/**
* Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware
* @param req Req object
* @param res Res object
* @param next 'Next' function
*/
handler(req: Req, res: Res, next?: NextFunction): void;
/**
* Creates HTTP server and dispatches middleware
* @param port server listening port
* @param cb callback to be invoked after server starts listening
* @param host server listening host
*/
listen(port?: number, cb?: () => void, host?: string): Server;
}
//# sourceMappingURL=types.d.ts.map

1
node_modules/@tinyhttp/app/dist/types.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{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,EAAE,MAAM,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAC9D"}

2
node_modules/@tinyhttp/app/dist/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

1
node_modules/@tinyhttp/app/dist/types.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}

38
node_modules/@tinyhttp/app/dist/view.d.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
/*!
* Ported from https://github.com/expressjs/express/blob/master/lib/view.js
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
import type { TemplateEngine, TemplateEngineOptions } from './types.js';
/**
* Initialize a new `View` with the given `name`.
*
* Options:
*
* - `defaultEngine` the default template engine name
* - `engines` template engine require() cache
* - `root` root path for view lookup
*
* @param name
* @param options
* @public
*/
export declare class View<RenderOptions extends TemplateEngineOptions = TemplateEngineOptions> {
#private;
ext?: string;
defaultEngine?: string;
name: string;
engine: TemplateEngine<RenderOptions>;
path: string;
root: string | string[];
constructor(name: string, opts?: Partial<{
defaultEngine: string;
root: string | string[];
engines: Record<string, TemplateEngine<RenderOptions>>;
}>);
render(options: RenderOptions, data: Record<string, unknown>, cb: (err: Error | null, html: unknown) => void): void;
}
//# sourceMappingURL=view.d.ts.map

1
node_modules/@tinyhttp/app/dist/view.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAUvE;;;;;;;;;;;;GAYG;AAEH,qBAAa,IAAI,CAAC,aAAa,SAAS,qBAAqB,GAAG,qBAAqB;;IACnF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,CAAA;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAK;gBAE1B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,OAAO,CAAC;QACZ,aAAa,EAAE,MAAM,CAAA;QACrB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,CAAA;KACvD,CAAM;IAiET,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI;CAG7G"}

100
node_modules/@tinyhttp/app/dist/view.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
/*!
* Ported from https://github.com/expressjs/express/blob/master/lib/view.js
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _View_instances, _View_lookup, _View_resolve;
import { statSync } from 'node:fs';
import { basename, dirname, extname, join, resolve } from 'node:path';
function tryStat(path) {
try {
return statSync(path);
}
catch (e) {
return undefined;
}
}
/**
* Initialize a new `View` with the given `name`.
*
* Options:
*
* - `defaultEngine` the default template engine name
* - `engines` template engine require() cache
* - `root` root path for view lookup
*
* @param name
* @param options
* @public
*/
export class View {
constructor(name, opts = {}) {
var _a, _b;
_View_instances.add(this);
this.root = [];
this.ext = extname(name);
this.name = name;
if (opts.root)
this.root = opts.root;
if (opts.defaultEngine)
this.defaultEngine = opts.defaultEngine;
if (!this.ext && !this.defaultEngine)
throw new Error('No default engine was specified and no extension was provided.');
let fileName = name;
if (!this.ext) {
// get extension from default engine name
this.ext = ((_a = this.defaultEngine) === null || _a === void 0 ? void 0 : _a[0]) !== '.' ? `.${this.defaultEngine}` : this.defaultEngine;
fileName += this.ext;
}
if (!((_b = opts.engines) === null || _b === void 0 ? void 0 : _b[this.ext]))
throw new Error(`No engine was found for ${this.ext}`);
const path = __classPrivateFieldGet(this, _View_instances, "m", _View_lookup).call(this, fileName);
const dirs = Array.isArray(this.root) && this.root.length > 1
? `directories "${this.root.slice(0, -1).join('", "')}" or "${this.root[this.root.length - 1]}"`
: `directory "${this.root}"`;
if (!path)
throw new Error(`Failed to lookup view "${name}" in views ${dirs}`);
this.engine = opts.engines[this.ext];
this.path = path;
}
render(options, data, cb) {
this.engine(this.path, data, options, cb);
}
}
_View_instances = new WeakSet(), _View_lookup = function _View_lookup(name) {
let path;
const roots = [].concat(this.root);
for (let i = 0; i < roots.length && !path; i++) {
const root = roots[i];
// resolve the path
const loc = resolve(root, name);
const dir = dirname(loc);
const file = basename(loc);
// resolve the file
path = __classPrivateFieldGet(this, _View_instances, "m", _View_resolve).call(this, dir, file);
}
return path;
}, _View_resolve = function _View_resolve(dir, file) {
const ext = this.ext;
// <path>.<ext>
let path = join(dir, file);
let stat = tryStat(path);
if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
return path;
}
// <path>/index.<ext>
path = join(dir, basename(file, ext), `index${ext}`);
stat = tryStat(path);
if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
return path;
}
};
//# sourceMappingURL=view.js.map

1
node_modules/@tinyhttp/app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& fast web framework as a replacement of Express",
"type": "module",
"homepage": "https://tinyhttp.v1rtl.site",
"repository": {
"type": "git",
"url": "https://github.com/tinyhttp/tinyhttp.git",
"directory": "packages/app"
},
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
},
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"files": [
"dist"
],
"engines": {
"node": ">=14.21.3"
},
"keywords": [
"tinyhttp",
"router",
"backend",
"http",
"framework",
"api"
],
"author": "v1rtl",
"license": "MIT",
"dependencies": {
"header-range-parser": "1.1.3",
"regexparam": "^2.0.2",
"@tinyhttp/cookie": "2.1.1",
"@tinyhttp/proxy-addr": "2.2.1",
"@tinyhttp/req": "2.2.5",
"@tinyhttp/res": "2.2.5",
"@tinyhttp/router": "2.2.3"
},
"scripts": {
"build": "tsc"
}
}

21
node_modules/@tinyhttp/content-disposition/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

107
node_modules/@tinyhttp/content-disposition/README.md generated vendored Normal file
View File

@@ -0,0 +1,107 @@
# @tinyhttp/content-disposition
> [`content-disposition`](https://github.com/jshttp/content-disposition) rewrite
> in TypeScript.
Create and parse HTTP `Content-Disposition` header
## Install
```sh
pnpm i @tinyhttp/content-disposition
```
## API
```ts
import { contentDisposition, parse } from '@tinyhttp/content-disposition'
```
### `contentDisposition(filename)`
Create an attachment `Content-Disposition` header value using the given file
name, if supplied. The `filename` is optional and if no file name is desired,
but you want to specify `options`, set `filename` to `undefined`.
```js
res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf'))
```
**note** HTTP headers are of the ISO-8859-1 character set. If you are writing
this header through a means different from `setHeader` in Node.js, you'll want
to specify the `'binary'` encoding in Node.js.
#### Options
`contentDisposition` accepts these properties in the options object.
##### `fallback`
If the `filename` option is outside ISO-8859-1, then the file name is actually
stored in a supplemental field for clients that support Unicode file names and a
ISO-8859-1 version of the file name is automatically generated.
This specifies the ISO-8859-1 file name to override the automatic generation or
disables the generation all together, defaults to `true`.
- A string will specify the ISO-8859-1 file name to use in place of automatic
generation.
- `false` will disable including a ISO-8859-1 file name and only include the
Unicode version (unless the file name is already ISO-8859-1).
- `true` will enable automatic generation if the file name is outside
ISO-8859-1.
If the `filename` option is ISO-8859-1 and this option is specified and has a
different value, then the `filename` option is encoded in the extended field and
this set as the fallback field, even though they are both ISO-8859-1.
##### `type`
Specifies the disposition type, defaults to `"attachment"`. This can also be
`"inline"`, or any other value (all values except inline are treated like
`attachment`, but can convey additional information if both parties agree to
it). The type is normalized to lower-case.
### `contentDisposition.parse(string)`
```js
contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt')
```
Parse a `Content-Disposition` header string. This automatically handles extended
("Unicode") parameters by decoding them and providing them under the standard
parameter name. This will return an object with the following properties
(examples are shown for the string
`'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`):
- `type`: The disposition type (always lower case). Example: `'attachment'`
- `parameters`: An object of the parameters in the disposition (name of
parameter always lower case and extended versions replace non-extended
versions). Example: `{filename: "€ rates.txt"}`
## Example
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.
```ts
import { contentDisposition } from '@tinyhttp/content-disposition'
import destroy from 'destroy'
import fs from 'node:fs'
import { createServer } from 'node:http'
import onFinished from 'on-finished'
const filePath = '/path/to/public/plans.pdf'
createServer((req, res) => {
res.setHeader('Content-Type', 'application/pdf')
res.setHeader('Content-Disposition', contentDisposition(filePath))
const stream = fs.createReadStream(filePath)
stream.pipe(res)
onFinished(res, () => destroy(stream))
})
```

View File

@@ -0,0 +1,21 @@
export declare class ContentDisposition {
type: string;
parameters: Record<string, unknown>;
constructor(type: string, parameters: Record<string, string | undefined | boolean>);
}
/**
* Create an attachment Content-Disposition header.
*
* @param filename file name
* @param options
*/
export declare function contentDisposition(filename?: string, options?: Partial<{
type: string;
fallback: string | boolean;
}>): string;
/**
* Parse Content-Disposition header string.
* @param header string
*/
export declare function parse(header: string): ContentDisposition;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8BA,qBAAa,kBAAkB;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;gBACvB,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CAInF;AAoFD;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAChC,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,GAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAC3B,CAAM,GACN,MAAM,CAGR;AA2BD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAuDxD"}

View File

@@ -0,0 +1,162 @@
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
const ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
const HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
const HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g;
const NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g;
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
const QESC_REGEXP = /\\([\u0000-\u007f])/g;
const QUOTE_REGEXP = /([\\"])/g;
const PARAM_REGEXP =
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
/;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g;
const TEXT_REGEXP = /^[\x20-\x7e\x80-\xff]+$/;
const TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/;
const EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/;
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
const DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/;
const getlatin1 = (val) => {
// simple Unicode -> ISO-8859-1 transformation
return String(val).replace(NON_LATIN1_REGEXP, '?');
};
export class ContentDisposition {
constructor(type, parameters) {
this.type = type;
this.parameters = parameters;
}
}
const qstring = (val) => `"${String(val).replace(QUOTE_REGEXP, '\\$1')}"`;
const pencode = (char) => `%${String(char).charCodeAt(0).toString(16).toUpperCase()}`;
function ustring(val) {
const str = String(val);
// percent encode as UTF-8
const encoded = encodeURIComponent(str).replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode);
return `UTF-8''${encoded}`;
}
const basename = (str) => str.slice(str.lastIndexOf('/') + 1);
function format({ parameters, type }) {
if (!type || typeof type !== 'string' || !TOKEN_REGEXP.test(type)) {
throw new TypeError('invalid type');
}
// start with normalized type
let string = String(type).toLowerCase();
// append parameters
if (parameters && typeof parameters === 'object') {
const params = Object.keys(parameters).sort();
for (const param of params) {
const val = param.slice(-1) === '*' ? ustring(parameters[param]) : qstring(parameters[param]);
string += `; ${param}=${val}`;
}
}
return string;
}
function createParams(filename, fallback) {
if (filename === undefined)
return {};
const params = {};
// fallback defaults to true
if (!fallback)
fallback = true;
if (typeof fallback === 'string' && NON_LATIN1_REGEXP.test(fallback)) {
throw new TypeError('fallback must be ISO-8859-1 string');
}
// restrict to file base name
const name = basename(filename);
// determine if name is suitable for quoted string
const isQuotedString = TEXT_REGEXP.test(name);
// generate fallback name
const fallbackName = typeof fallback !== 'string' ? fallback && getlatin1(name) : basename(fallback);
const hasFallback = typeof fallbackName === 'string' && fallbackName !== name;
// set extended filename parameter
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
params['filename*'] = name;
}
// set filename parameter
if (isQuotedString || hasFallback) {
params.filename = hasFallback ? fallbackName : name;
}
return params;
}
const pdecode = (_str, hex) => String.fromCharCode(Number.parseInt(hex, 16));
/**
* Create an attachment Content-Disposition header.
*
* @param filename file name
* @param options
*/
export function contentDisposition(filename, options = {}) {
// format into string
return format(new ContentDisposition(options.type || 'attachment', createParams(filename, options.fallback)));
}
function decodefield(str) {
const match = EXT_VALUE_REGEXP.exec(str);
if (!match)
throw new TypeError('invalid extended field value');
const charset = match[1].toLowerCase();
const encoded = match[2];
let value;
switch (charset) {
case 'iso-8859-1':
value = getlatin1(encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode));
break;
case 'utf-8':
try {
value = decodeURIComponent(encoded);
}
catch {
throw new TypeError('invalid encoded utf-8');
}
break;
default:
throw new TypeError('unsupported charset in extended field');
}
return value;
}
/**
* Parse Content-Disposition header string.
* @param header string
*/
export function parse(header) {
let match = DISPOSITION_TYPE_REGEXP.exec(header);
if (!match)
throw new TypeError('invalid type format');
// normalize type
let index = match[0].length;
const type = match[1].toLowerCase();
let key;
const names = [];
const params = {};
let value;
// calculate index to start at
index = PARAM_REGEXP.lastIndex = match[0].slice(-1) === ';' ? index - 1 : index;
// match parameters
while ((match = PARAM_REGEXP.exec(header))) {
if (match.index !== index)
throw new TypeError('invalid parameter format');
index += match[0].length;
key = match[1].toLowerCase();
value = match[2];
if (names.indexOf(key) !== -1) {
throw new TypeError('invalid duplicate parameter');
}
names.push(key);
if (key.indexOf('*') + 1 === key.length) {
// decode extended value
key = key.slice(0, -1);
value = decodefield(value);
// overwrite existing value
params[key] = value;
continue;
}
if (typeof params[key] === 'string')
continue;
if (value[0] === '"') {
value = value.slice(1, value.length - 1).replace(QESC_REGEXP, '$1');
}
params[key] = value;
}
if (index !== -1 && index !== header.length) {
throw new TypeError('invalid parameter format');
}
return new ContentDisposition(type, params);
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
{
"name": "@tinyhttp/content-disposition",
"description": "content-disposition rewrite in TypeScript",
"version": "2.2.2",
"license": "MIT",
"homepage": "https://tinyhttp.v1rtl.site",
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
},
"repository": {
"type": "git",
"url": "https://github.com/tinyhttp/tinyhttp.git",
"directory": "packages/content-disposition"
},
"engines": {
"node": ">=12.20.0"
},
"type": "module",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"files": [
"dist"
],
"scripts": {
"build": "tsc"
}
}

21
node_modules/@tinyhttp/content-type/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

82
node_modules/@tinyhttp/content-type/README.md generated vendored Normal file
View File

@@ -0,0 +1,82 @@
# @tinyhttp/content-type
[![Version][v-badge-url]][npm-url] [![Downloads][dl-badge-url]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Codecov][cov-badge-url]][cov-url]
> [`content-type`](https://github.com/jshttp/content-type) rewrite in TypeScript and ESM.
Create and parse HTTP Content-Type header according to RFC 7231
## Install
```sh
pnpm i @tinyhttp/content-type
```
## API
```ts
import { parse, format } from '@tinyhttp/content-type'
```
### `parse(string: string | Request | Response)`
```ts
const obj = parse('image/svg+xml; charset=utf-8')
```
Parse a `Content-Type` header. This will return an object with the following
properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
- `type`: The media type (the type and subtype, always lower case).
Example: `'image/svg+xml'`
- `parameters`: An object of the parameters in the media type (name of parameter
always lower case). Example: `{charset: 'utf-8'}`
Throws a `TypeError` if the string is missing or invalid.
```ts
const obj = contentType.parse(req)
```
Parse the `Content-Type` header from the given `req`. Short-cut for
`contentType.parse(req.headers['content-type'])`.
Throws a `TypeError` if the `Content-Type` header is missing or invalid.
```js
const obj = contentType.parse(res)
```
Parse the `Content-Type` header set on the given `res`. Short-cut for
`contentType.parse(res.getHeader('content-type'))`.
Throws a `TypeError` if the `Content-Type` header is missing or invalid.
### `format(obj)`
```ts
const str = contentType.format({
type: 'image/svg+xml',
parameters: { charset: 'utf-8' },
})
```
Format an object into a `Content-Type` header. This will return a string of the
content type for the given object with the following properties (examples are
shown that produce the string `'image/svg+xml; charset=utf-8'`):
- `type`: The media type (will be lower-cased). Example: `'image/svg+xml'`
- `parameters`: An object of the parameters in the media type (name of the
parameter will be lower-cased). Example: `{charset: 'utf-8'}`
Throws a `TypeError` if the object contains an invalid type or parameter names.
[v-badge-url]: https://img.shields.io/npm/v/@tinyhttp/content-type.svg?style=for-the-badge&color=FF69B4&label=&logo=npm
[npm-url]: https://www.npmjs.com/package/@tinyhttp/content-type
[cov-badge-url]: https://img.shields.io/coveralls/github/tinyhttp/content-type?style=for-the-badge&color=FF69B4
[cov-url]: https://coveralls.io/github/tinyhttp/@tinyhttp/content-type
[dl-badge-url]: https://img.shields.io/npm/dt/@tinyhttp/content-type?style=for-the-badge&color=FF69B4
[github-actions]: https://github.com/tinyhttp/content-type/actions
[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/content-type/ci.yml?branch=master&style=for-the-badge&color=FF69B4&label=&logo=github

24
node_modules/@tinyhttp/content-type/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { IncomingHttpHeaders, ServerResponse } from 'node:http';
type Request = {
headers: IncomingHttpHeaders;
};
type Response = Pick<ServerResponse, 'getHeader'>;
/**
* Class to represent a content type.
*/
declare class ContentType {
parameters?: Record<string, unknown>;
type: string;
constructor(type: string);
}
/**
* Format object to media type.
*/
declare function format(obj: ContentType): string;
/**
* Parse media type to object.
*/
declare function parse(string: string | Request | Response): ContentType;
export { format, parse };

89
node_modules/@tinyhttp/content-type/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,89 @@
// src/index.ts
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
var QUOTE_REGEXP = /([\\"])/g;
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
function qstring(val) {
const str = String(val);
if (TOKEN_REGEXP.test(str))
return str;
if (str.length > 0 && !TEXT_REGEXP.test(str))
throw new TypeError("invalid parameter value");
return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
}
function getcontenttype(obj) {
let header;
if ("getHeader" in obj && typeof obj.getHeader === "function") {
header = obj.getHeader("content-type");
} else if ("headers" in obj && typeof obj.headers === "object") {
const h = obj.headers;
header = h && h["content-type"];
}
if (typeof header !== "string") {
throw new TypeError("content-type header is missing from object");
}
return header;
}
var ContentType = class {
parameters;
type;
constructor(type) {
this.parameters = {};
this.type = type;
}
};
function format(obj) {
if (!obj || typeof obj !== "object")
throw new TypeError("argument obj is required");
const { parameters, type } = obj;
if (!type || !TYPE_REGEXP.test(type))
throw new TypeError("invalid type");
let string = type;
if (parameters && typeof parameters == "object") {
const params = Object.keys(parameters).sort();
for (const param of params) {
if (!TOKEN_REGEXP.test(param))
throw new TypeError("invalid parameter name");
string += "; " + param + "=" + qstring(parameters[param]);
}
}
return string;
}
function parse(string) {
if (!string)
throw new TypeError("argument string is required");
const header = typeof string == "object" ? getcontenttype(string) : string;
if (typeof header !== "string")
throw new TypeError("argument string is required to be a string");
let index = header.indexOf(";");
const type = index != -1 ? header.slice(0, index).trim() : header.trim();
if (!TYPE_REGEXP.test(type))
throw new TypeError("invalid media type");
const obj = new ContentType(type.toLowerCase());
if (index != -1) {
let key;
let match;
let value;
PARAM_REGEXP.lastIndex = index;
while (match = PARAM_REGEXP.exec(header)) {
if (match.index !== index)
throw new TypeError("invalid parameter format");
index += match[0].length;
key = match[1].toLowerCase();
value = match[2];
if (value[0] == '"') {
value = value.slice(1, value.length - 1).replace(QESC_REGEXP, "$1");
}
obj.parameters[key] = value;
}
if (index != header.length)
throw new TypeError("invalid parameter format");
}
return obj;
}
export {
format,
parse
};

37
node_modules/@tinyhttp/content-type/package.json generated vendored Normal file
View File

@@ -0,0 +1,37 @@
{
"name": "@tinyhttp/content-type",
"description": "content-type rewrite in TypeScript and ESM",
"version": "0.1.4",
"repository": "https://github.com/tinyhttp/content-type.git",
"engines": {
"node": ">=12.4"
},
"files": [
"dist"
],
"author": "v1rtl <hi@v1rtl.site>",
"license": "MIT",
"type": "module",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"devDependencies": {
"@types/node": "^20.6.4",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"c8": "^8.0.1",
"eslint": "^8.50.0",
"tsm": "^2.3.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"uvu": "^0.5.6"
},
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsup src/index.ts --format esm --dts",
"test": "uvu -r tsm test",
"test:coverage": "c8 --include=src pnpm test",
"test:report": "c8 report --reporter=text-lcov > coverage.lcov"
}
}

21
node_modules/@tinyhttp/cookie-signature/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

25
node_modules/@tinyhttp/cookie-signature/README.md generated vendored Normal file
View File

@@ -0,0 +1,25 @@
# @tinyhttp/cookie-signature
[![npm (scoped)](https://img.shields.io/npm/v/@tinyhttp/cookie-signature?style=flat-square)](https://npmjs.com/package/@tinyhttp/cookie-signature) [![npm](https://img.shields.io/npm/dt/@tinyhttp/cookie-signature?style=flat-square)](https://npmjs.com/package/@tinyhttp/cookie-signature)
HTTP cookie signing and unsigning. A rewrite of [cookie-signature](https://github.com/tj/node-cookie-signature) module.
## Install
```sh
pnpm i @tinyhttp/cookie-signature
```
## API
```js
import { sign, unsign } from '@tinyhttp/cookie-signature'
```
### `sign(val, secret)`
Signd the given `val` with `secret`.
### `unsign(val, secret)`
Unsign and decode the given `val` with `secret`, returning `false` if the signature is invalid.

View File

@@ -0,0 +1,10 @@
/**
* Sign the given `val` with `secret`.
*/
export declare const sign: (val: string, secret: string) => string;
/**
* Unsign and decode the given `val` with `secret`,
* returning `false` if the signature is invalid.
*/
export declare const unsign: (val: string, secret: string) => string | false;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,IAAI,QAAS,MAAM,UAAU,MAAM,KAAG,MACuC,CAAA;AAE1F;;;GAGG;AACH,eAAO,MAAM,MAAM,QAAS,MAAM,UAAU,MAAM,KAAG,MAAM,GAAG,KAQ7D,CAAA"}

15
node_modules/@tinyhttp/cookie-signature/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { createHmac, timingSafeEqual } from "node:crypto";
const sign = (val, secret) => `${val}.${createHmac("sha256", secret).update(val).digest("base64").replace(/=+$/, "")}`;
const unsign = (val, secret) => {
const str = val.slice(0, val.lastIndexOf("."));
const mac = sign(str, secret);
const macBuffer = Buffer.from(mac);
const valBuffer = Buffer.alloc(macBuffer.length);
valBuffer.write(val);
return timingSafeEqual(macBuffer, valBuffer) ? str : false;
};
export {
sign,
unsign
};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from 'node:crypto'\n\n/**\n * Sign the given `val` with `secret`.\n */\nexport const sign = (val: string, secret: string): string =>\n `${val}.${createHmac('sha256', secret).update(val).digest('base64').replace(/=+$/, '')}`\n\n/**\n * Unsign and decode the given `val` with `secret`,\n * returning `false` if the signature is invalid.\n */\nexport const unsign = (val: string, secret: string): string | false => {\n const str = val.slice(0, val.lastIndexOf('.'))\n const mac = sign(str, secret)\n const macBuffer = Buffer.from(mac)\n const valBuffer = Buffer.alloc(macBuffer.length)\n\n valBuffer.write(val)\n return timingSafeEqual(macBuffer, valBuffer) ? str : false\n}\n"],"names":[],"mappings":";AAKa,MAAA,OAAO,CAAC,KAAa,WAChC,GAAG,GAAG,IAAI,WAAW,UAAU,MAAM,EAAE,OAAO,GAAG,EAAE,OAAO,QAAQ,EAAE,QAAQ,OAAO,EAAE,CAAC;AAM3E,MAAA,SAAS,CAAC,KAAa,WAAmC;AACrE,QAAM,MAAM,IAAI,MAAM,GAAG,IAAI,YAAY,GAAG,CAAC;AACvC,QAAA,MAAM,KAAK,KAAK,MAAM;AACtB,QAAA,YAAY,OAAO,KAAK,GAAG;AACjC,QAAM,YAAY,OAAO,MAAM,UAAU,MAAM;AAE/C,YAAU,MAAM,GAAG;AACnB,SAAO,gBAAgB,WAAW,SAAS,IAAI,MAAM;AACvD;"}

36
node_modules/@tinyhttp/cookie-signature/package.json generated vendored Normal file
View File

@@ -0,0 +1,36 @@
{
"name": "@tinyhttp/cookie-signature",
"version": "2.1.1",
"description": "HTTP cookie signing and unsigning",
"homepage": "https://tinyhttp.v1rtl.site",
"repository": {
"type": "git",
"url": "https://github.com/tinyhttp/tinyhttp.git",
"directory": "packages/cookie-signature"
},
"engines": {
"node": ">=12.20.0"
},
"type": "module",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"keywords": [
"tinyhttp",
"node.js",
"web framework",
"web",
"backend",
"static",
"cookie"
],
"files": [
"dist"
],
"author": "v1rtl",
"license": "MIT",
"dependencies": {},
"scripts": {
"dev": "vite",
"build": "vite build"
}
}

21
node_modules/@tinyhttp/cookie/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

176
node_modules/@tinyhttp/cookie/README.md generated vendored Normal file
View File

@@ -0,0 +1,176 @@
# @tinyhttp/cookie
[![npm (scoped)](https://img.shields.io/npm/v/@tinyhttp/cookie?style=flat-square)](https://npmjs.com/package/@tinyhttp/cookie) [![npm](https://img.shields.io/npm/dt/@tinyhttp/cookie?style=flat-square)](https://npmjs.com/package/@tinyhttp/cookie)
> A rewrite of [cookie](https://github.com/jshttp/cookie) module.
HTTP cookie parser and serializer for Node.js.
## Install
```sh
pnpm i @tinyhttp/cookie
```
## API
```js
import { parse, serialize } from '@tinyhttp/cookie'
```
### `parse(str, options)`
Parse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs.
The `str` argument is the string representing a `Cookie` header value and `options` is an
optional object containing additional parsing options.
```js
import { parse } from '@tinyhttp/cookie'
parse('foo=bar; equation=E%3Dmc%5E2')
// { foo: 'bar', equation: 'E=mc^2' }
```
#### Options
`parse` accepts these properties in the options object.
##### `decode`
Specifies a function that will be used to decode a cookie's value. Since the value of a cookie
has a limited character set (and must be a simple string), this function can be used to decode
a previously-encoded cookie value into a JavaScript string or other object.
The default function is the global `decodeURIComponent`, which will decode any URL-encoded
sequences into their byte representations.
**note** if an error is thrown from this function, the original, non-decoded cookie value will
be returned as the cookie's value.
### `serialize(name, value, options)`
Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the
name for the cookie, the `value` argument is the value to set the cookie to, and the `options`
argument is an optional object containing additional serialization options.
```js
import { serialize } from '@tinyhttp/cookie'
serialize('foo', 'bar')
// foo=bar
```
#### Options
`serialize` accepts these properties in the options object.
##### `domain`
Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6265-5.2.3]. By default, no
domain is set, and most clients will consider the cookie to apply to only the current domain.
##### `encode`
Specifies a function that will be used to encode a cookie's value. Since value of a cookie
has a limited character set (and must be a simple string), this function can be used to encode
a value into a string suited for a cookie's value.
The default function is the global `encodeURIComponent`, which will encode a JavaScript string
into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
##### `expires`
Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6265-5.2.1].
By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and
will delete it on a condition like exiting a web browser application.
**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
so if both are set, they should point to the same date and time.
##### `httpOnly`
Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6265-5.2.6]. When truthy,
the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set.
**note** be careful when setting this to `true`, as compliant clients will not allow client-side
JavaScript to see the cookie in `document.cookie`.
##### `maxAge`
Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6265-5.2.2].
The given number will be converted to an integer by rounding down. By default, no maximum age is set.
**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
so if both are set, they should point to the same date and time.
##### `path`
Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path
is considered the ["default path"][rfc-6265-5.1.4].
##### `sameSite`
Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-03-4.1.2.7].
- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
- `false` will not set the `SameSite` attribute.
- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
More information about the different enforcement levels can be found in
[the specification][rfc-6265bis-03-4.1.2.7].
**note** This is an attribute that has not yet been fully standardized, and may change in the future.
This also means many clients may ignore this attribute until they understand it.
##### `secure`
Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6265-5.2.5]. When truthy,
the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to
the server in the future if the browser does not have an HTTPS connection.
## Example
```ts
import { App } from '@tinyhttp/app'
import { parse, serialize } from '@tinyhttp/cookie'
import { escapeHTML } from 'es-escape-html'
new App()
.use((req, res) => {
if (req.query?.name) {
// Set a new cookie with the name
res.set(
'Set-Cookie',
serialize('name', String(query.name), {
httpOnly: true,
maxAge: 60 * 60 * 24 * 7 // 1 week
})
)
// Redirect back after setting cookie
res
.status(302)
.set('Location', req.headers.referer || '/')
.end()
}
const cookie = parse(req.headers.cookie || '')
const { name } = cookie
res.set('Content-Type', 'text/html; charset=UTF-8')
res.write(name ? `<p>Welcome back, <strong>${escapeHTML(name)}</strong>!</p>` : '<p>Hello, new visitor!</p>')
res.write('<form method="GET">')
res.write('<input placeholder="enter your name" name="name"><input type="submit" value="Set Name">')
res.end('</form>')
})
.listen(3000)
```

22
node_modules/@tinyhttp/cookie/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/**
* Parse a cookie header.
*
* Parse the given cookie header string into an object
* The object has the various cookies as keys(names) => values
*
*/
export declare function parse(str: string, options?: {
decode: (str: string) => string;
}): Record<string, string>;
export type SerializeOptions = Partial<{
encode: (str: string) => string;
maxAge: number;
domain: string;
path: string;
httpOnly: boolean;
secure: boolean;
sameSite: boolean | 'Strict' | 'strict' | 'Lax' | 'lax' | 'None' | 'none' | string;
expires: Date;
}>;
export declare function serialize(name: string, val: string, opt?: SerializeOptions): string;
//# sourceMappingURL=index.d.ts.map

1
node_modules/@tinyhttp/cookie/dist/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IACP,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;CAGhC,GACA,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBxB;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC;IACrC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IAClF,OAAO,EAAE,IAAI,CAAA;CACd,CAAC,CAAA;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,gBAAqB,GAAG,MAAM,CAyDvF"}

70
node_modules/@tinyhttp/cookie/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
const pairSplitRegExp = /; */;
const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
function tryDecode(str, decode) {
try {
return decode(str);
} catch (e) {
return str;
}
}
function parse(str, options = {
decode: decodeURIComponent
}) {
const obj = {};
const pairs = str.split(pairSplitRegExp);
for (const pair of pairs) {
let eqIdx = pair.indexOf("=");
if (eqIdx < 0) continue;
const key = pair.slice(0, eqIdx).trim();
let val = pair.slice(++eqIdx, pair.length).trim();
if ('"' === val[0]) val = val.slice(1, -1);
if (obj[key] == null) obj[key] = tryDecode(val, options.decode);
}
return obj;
}
function serialize(name, val, opt = {}) {
if (!opt.encode) opt.encode = encodeURIComponent;
if (!fieldContentRegExp.test(name)) throw new TypeError("argument name is invalid");
const value = opt.encode(val);
if (value && !fieldContentRegExp.test(value)) throw new TypeError("argument val is invalid");
let str = `${name}=${value}`;
if (null != opt.maxAge) {
const maxAge = opt.maxAge - 0;
if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError("option maxAge is invalid");
str += `; Max-Age=${Math.floor(maxAge)}`;
}
if (opt.domain) {
if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid");
str += `; Domain=${opt.domain}`;
}
if (opt.path) {
if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid");
str += `; Path=${opt.path}`;
}
if (opt.expires) str += `; Expires=${opt.expires.toUTCString()}`;
if (opt.httpOnly) str += "; HttpOnly";
if (opt.secure) str += "; Secure";
if (opt.sameSite) {
const sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
switch (sameSite) {
case true:
case "strict":
str += "; SameSite=Strict";
break;
case "lax":
str += "; SameSite=Lax";
break;
case "none":
str += "; SameSite=None";
break;
default:
throw new TypeError("option sameSite is invalid");
}
}
return str;
}
export {
parse,
serialize
};
//# sourceMappingURL=index.js.map

1
node_modules/@tinyhttp/cookie/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["const pairSplitRegExp = /; */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\n\n// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str)\n } catch (e) {\n return str\n }\n}\n\n/**\n * Parse a cookie header.\n *\n * Parse the given cookie header string into an object\n * The object has the various cookies as keys(names) => values\n *\n */\nexport function parse(\n str: string,\n options: {\n decode: (str: string) => string\n } = {\n decode: decodeURIComponent\n }\n): Record<string, string> {\n const obj: Record<string, string> = {}\n const pairs = str.split(pairSplitRegExp)\n\n for (const pair of pairs) {\n let eqIdx = pair.indexOf('=')\n\n // skip things that don't look like key=value\n if (eqIdx < 0) continue\n\n const key = pair.slice(0, eqIdx).trim()\n let val = pair.slice(++eqIdx, pair.length).trim()\n\n // quoted values\n if ('\"' === val[0]) val = val.slice(1, -1)\n\n // only assign once\n if (obj[key] == null) obj[key] = tryDecode(val, options.decode)\n }\n\n return obj\n}\n\nexport type SerializeOptions = Partial<{\n encode: (str: string) => string\n maxAge: number\n domain: string\n path: string\n httpOnly: boolean\n secure: boolean\n sameSite: boolean | 'Strict' | 'strict' | 'Lax' | 'lax' | 'None' | 'none' | string\n expires: Date\n}>\n\nexport function serialize(name: string, val: string, opt: SerializeOptions = {}): string {\n if (!opt.encode) opt.encode = encodeURIComponent\n\n if (!fieldContentRegExp.test(name)) throw new TypeError('argument name is invalid')\n\n const value = opt.encode(val)\n\n if (value && !fieldContentRegExp.test(value)) throw new TypeError('argument val is invalid')\n\n let str = `${name}=${value}`\n\n if (null != opt.maxAge) {\n const maxAge = opt.maxAge - 0\n\n if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError('option maxAge is invalid')\n\n str += `; Max-Age=${Math.floor(maxAge)}`\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) throw new TypeError('option domain is invalid')\n\n str += `; Domain=${opt.domain}`\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) throw new TypeError('option path is invalid')\n\n str += `; Path=${opt.path}`\n }\n\n if (opt.expires) str += `; Expires=${opt.expires.toUTCString()}`\n\n if (opt.httpOnly) str += '; HttpOnly'\n\n if (opt.secure) str += '; Secure'\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite\n\n switch (sameSite) {\n case true:\n case 'strict':\n str += '; SameSite=Strict'\n break\n case 'lax':\n str += '; SameSite=Lax'\n break\n case 'none':\n str += '; S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AM,MAAM,CAAC;AAAA,EACxC;AAEA,MAAI,IAAI,QAAQ;AACV,QAAA,CAAC,mBAAmB,KAAK,IAAI,MAAM,EAAG,OAAM,IAAI,UAAU,0BAA0B;AAEjF,WAAA,YAAY,IAAI,MAAM;AAAA,EAC/B;AAEA,MAAI,IAAI,MAAM;AACR,QAAA,CAAC,mBAAmB,KAAK,IAAI,IAAI,EAAG,OAAM,IAAI,UAAU,wBAAwB;AAE7E,WAAA,UAAU,IAAI,IAAI;AAAA,EAC3B;AAEA,MAAI,IAAI,QAAS,QAAO,aAAa,IAAI,QAAQ,YAAa,CAAA;AAE1D,MAAA,IAAI,SAAiB,QAAA;AAErB,MAAA,IAAI,OAAe,QAAA;AAEvB,MAAI,IAAI,UAAU;AACV,UAAA,WAAW,OAAO,IAAI,aAAa,WAAW,IAAI,SAAS,YAAY,IAAI,IAAI;AAErF,YAAQ,UAAU;AAAA,MAChB,KAAK;AAAA,MACL,KAAK;AACI,eAAA;AACP;AAAA,MACF,KAAK;AACI,eAAA;AACP;AAAA,MACF,KAAK;AACI,eAAA;AACP;AAAA,MACF;AACQ,cAAA,IAAI,UAAU,4BAA4B;AAAA,IACpD;AAAA,EACF;AAEO,SAAA;AACT;"}

39
node_modules/@tinyhttp/cookie/package.json generated vendored Normal file
View File

@@ -0,0 +1,39 @@
{
"name": "@tinyhttp/cookie",
"version": "2.1.1",
"type": "module",
"description": "HTTP cookie parser and serializer for Node.js",
"homepage": "https://github.com/tinyhttp/tinyhttp/tree/master/packages/cookie#readme",
"engines": {
"node": ">=12.20.0"
},
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
},
"repository": {
"type": "git",
"url": "https://github.com/tinyhttp/tinyhttp.git",
"directory": "packages/cookie"
},
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"keywords": [
"tinyhttp",
"node.js",
"web framework",
"web",
"backend",
"cookie"
],
"files": [
"dist"
],
"author": "v1rtl",
"license": "MIT",
"dependencies": {},
"scripts": {
"dev": "vite",
"build": "vite build"
}
}

21
node_modules/@tinyhttp/cors/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

73
node_modules/@tinyhttp/cors/README.md generated vendored Normal file
View File

@@ -0,0 +1,73 @@
<div align="center">
# @tinyhttp/cors
[![npm][npm-img]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Coverage][cov-img]][cov-url]
</div>
> A rewrite of [expressjs/cors](https://github.com/expressjs/cors) module.
HTTP cors header middleware.
## Install
```sh
pnpm i @tinyhttp/cors
```
## API
```ts
import { cors } from '@tinyhttp/cors'
```
### `cors(options)`
Returns the CORS middleware with the settings specified in the parameters
#### Options
- `origin`: Can be a string defining the `Access-Control-Allow-Origin` value, a boolean which if set to true sets the header to `'*'`, a Regex type, an array (for multiple origins) or a function which contains the request and response as parameters and must return the value for the `Access-Control-Allow-Origin` header
- `methods`: Array of method names which define the `Access-Control-Allow-Methods` header, default to all the most common methods (`GET`, `HEAD`, `PUT`, `PATCH`, `POST`, `DELETE`)
- `allowedHeaders`: Configures the `Access-Control-Allow-Headers` CORS header. Expects an array (ex: [`'Content-Type'`, `'Authorization'`]).
- `exposedHeaders`: Configures the `Access-Control-Expose-Headers` CORS header. If not specified, no custom headers are exposed
- `credentials`: Configures the `Access-Control-Allow-Credentials` CORS header. Set to true to pass the header, otherwise it is omitted.
- `maxAge`: Configures the `Access-Control-Max-Age` CORS header. Set to an integer to pass the header, otherwise it is omitted.
- `optionsSuccessStatus`: Provides a status code to use for successful OPTIONS requests, since some legacy browsers (IE11, various SmartTVs) choke on 204.
- `preflightContinue`: Set 204 and finish response if `true`, call `next` if false.
The default configuration is:
```json
{
"origin": "*",
"methods": ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
"optionsSuccessStatus": 204,
"preflightContinue": false
}
```
## Example
```ts
import { App } from '@tinyhttp/app'
import { cors } from '@tinyhttp/cors'
const app = new App()
app
.use(cors({ origin: 'https://myfantastic.site/' }))
.options('*', cors())
.get('/', (req, res) => {
res.send('The headers contained in my response are defined in the cors middleware')
})
.listen(3000)
```
[npm-url]: https://npmjs.com/package/@tinyhttp/cors
[github-actions]: https://github.com/tinyhttp/cors/actions
[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/cors/ci.yml?style=for-the-badge&logo=github&label=&color=hotpink
[cov-img]: https://img.shields.io/coveralls/github/tinyhttp/cors?style=for-the-badge&color=hotpink
[cov-url]: https://coveralls.io/github/tinyhttp/cors
[npm-img]: https://img.shields.io/npm/dt/@tinyhttp/cors?style=for-the-badge&color=hotpink

15
node_modules/@tinyhttp/cors/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import type { IncomingMessage as Request, ServerResponse as Response } from 'node:http';
export interface AccessControlOptions {
origin?: string | boolean | ((req: Request, res: Response) => string) | Iterable<string> | RegExp;
methods?: string[];
allowedHeaders?: string[];
exposedHeaders?: string[];
credentials?: boolean;
maxAge?: number;
optionsSuccessStatus?: number;
preflightContinue?: boolean;
}
/**
* CORS Middleware
*/
export declare const cors: (opts?: AccessControlOptions) => (req: Request, res: Response, next?: () => void) => void;

95
node_modules/@tinyhttp/cors/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
import { vary } from '@tinyhttp/vary';
const isIterable = (obj) => typeof obj[Symbol.iterator] === 'function';
const failOriginParam = () => {
throw new TypeError('No other objects allowed. Allowed types is array of strings or RegExp');
};
const getOriginHeaderHandler = (origin) => {
if (typeof origin === 'boolean') {
return origin
? (_, res) => {
res.setHeader('Access-Control-Allow-Origin', '*');
}
: () => undefined;
}
if (typeof origin === 'string') {
return (_, res) => {
res.setHeader('Access-Control-Allow-Origin', origin);
};
}
if (typeof origin === 'function') {
return (req, res) => {
vary(res, 'Origin');
res.setHeader('Access-Control-Allow-Origin', origin(req, res));
};
}
if (typeof origin !== 'object')
failOriginParam();
if (isIterable(origin)) {
const originArray = Array.from(origin);
if (originArray.some((element) => typeof element !== 'string'))
failOriginParam();
const originSet = new Set(origin);
if (originSet.has('*')) {
return (_, res) => {
res.setHeader('Access-Control-Allow-Origin', '*');
};
}
return (req, res) => {
vary(res, 'Origin');
if (req.headers.origin === undefined)
return;
if (!originSet.has(req.headers.origin))
return;
res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
};
}
if (origin instanceof RegExp) {
return (req, res) => {
vary(res, 'Origin');
if (req.headers.origin === undefined)
return;
if (!origin.test(req.headers.origin))
return;
res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
};
}
failOriginParam();
};
/**
* CORS Middleware
*/
export const cors = (opts = {}) => {
const { origin = '*', methods = ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'], allowedHeaders = ['content-type'], exposedHeaders, credentials, maxAge, optionsSuccessStatus = 204, preflightContinue = false } = opts;
const originHeaderHandler = getOriginHeaderHandler(origin);
return (req, res, next) => {
var _a, _b;
originHeaderHandler(req, res);
// Setting the Access-Control-Allow-Methods header from the methods array
res.setHeader('Access-Control-Allow-Methods', methods.join(', ').toUpperCase());
// Setting the Access-Control-Allow-Headers header
if (allowedHeaders)
res.setHeader('Access-Control-Allow-Headers', allowedHeaders);
// Setting the Access-Control-Expose-Headers header
if (exposedHeaders)
res.setHeader('Access-Control-Expose-Headers', exposedHeaders);
// Setting the Access-Control-Allow-Credentials header
if (credentials)
res.setHeader('Access-Control-Allow-Credentials', 'true');
// Setting the Access-Control-Max-Age header
if (maxAge)
res.setHeader('Access-Control-Max-Age', maxAge);
if (((_b = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toUpperCase) === null || _b === void 0 ? void 0 : _b.call(_a)) === 'OPTIONS') {
if (preflightContinue) {
next === null || next === void 0 ? void 0 : next();
}
else {
res.statusCode = optionsSuccessStatus;
res.setHeader('Content-Length', '0');
res.end();
}
}
else {
next === null || next === void 0 ? void 0 : next();
}
};
};

51
node_modules/@tinyhttp/cors/package.json generated vendored Normal file
View File

@@ -0,0 +1,51 @@
{
"name": "@tinyhttp/cors",
"version": "2.0.1",
"type": "module",
"description": "CORS middleware for modern Node.js ",
"homepage": "https://github.com/tinyhttp/cors#readme",
"repository": {
"type": "git",
"url": "https://github.com/tinyhttp/cors.git"
},
"engines": {
"node": ">=12.20 || 14.x || >=16"
},
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"keywords": [
"tinyhttp",
"node.js",
"web framework",
"web",
"backend"
],
"author": "v1rtl",
"license": "MIT",
"files": [
"dist"
],
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@tinyhttp/app": "2.2.4",
"@types/node": "^20.14.10",
"c8": "^10.1.2",
"husky": "^9.0.11",
"supertest-fetch": "^2.0.0",
"tsx": "^4.16.2",
"typescript": "~5.5.3"
},
"dependencies": {
"@tinyhttp/vary": "^0.1.3"
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"test": "tsx --test src/*.test.ts",
"cov": "c8 -r lcov pnpm test",
"lint": "biome lint .",
"format": "biome format .",
"check": "biome check ."
}
}

21
node_modules/@tinyhttp/encode-url/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

15
node_modules/@tinyhttp/encode-url/README.md generated vendored Normal file
View File

@@ -0,0 +1,15 @@
# @tinyhttp/encode-url
> [`encode-url`](https://github.com/pillarjs/encodeurl) rewrite in TypeScript.
Encode a URL to a percent-encoded form, excluding already-encoded sequences
## Install
```sh
pnpm i @tinyhttp/encode-url
```
## API
## Example

2
node_modules/@tinyhttp/encode-url/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare const encodeUrl: (url: string) => string;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,MAIvC,CAAA"}

10
node_modules/@tinyhttp/encode-url/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
const ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g;
const UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;
const UNMATCHED_SURROGATE_PAIR_REPLACE = "$1<>$2";
const encodeUrl = (url) => {
return String(url).replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE).replace(ENCODE_CHARS_REGEXP, encodeURI);
};
export {
encodeUrl
};
//# sourceMappingURL=index.js.map

1
node_modules/@tinyhttp/encode-url/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["const ENCODE_CHARS_REGEXP =\n /(?:[^\\x21\\x25\\x26-\\x3B\\x3D\\x3F-\\x5B\\x5D\\x5F\\x61-\\x7A\\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g\n\nconst UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF]([^\\uDC00-\\uDFFF]|$)/g\n\nconst UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\\uFFFD$2'\n\nexport const encodeUrl = (url: string): string => {\n return String(url)\n .replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE)\n .replace(ENCODE_CHARS_REGEXP, encodeURI)\n}\n"],"names":[],"mappings":"AAAA,MAAM,sBACJ;AAEF,MAAM,kCAAkC;AAExC,MAAM,mCAAmC;AAE5B,MAAA,YAAY,CAAC,QAAwB;AACzC,SAAA,OAAO,GAAG,EACd,QAAQ,iCAAiC,gCAAgC,EACzE,QAAQ,qBAAqB,SAAS;AAC3C;"}

34
node_modules/@tinyhttp/encode-url/package.json generated vendored Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "@tinyhttp/encode-url",
"version": "2.1.1",
"description": "encode-url rewrite in TypeScript",
"type": "module",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"homepage": "https://tinyhttp.v1rtl.site",
"repository": {
"type": "git",
"url": "https://github.com/tinyhttp/tinyhttp.git",
"directory": "packages/cors"
},
"keywords": [
"tinyhttp",
"node.js",
"web framework",
"web",
"backend",
"cors"
],
"engines": {
"node": ">=12.20.0"
},
"author": "v1rtl",
"license": "MIT",
"files": [
"dist"
],
"scripts": {
"dev": "vite",
"build": "vite build"
}
}

21
node_modules/@tinyhttp/etag/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
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.

Some files were not shown because too many files have changed in this diff Show More