this is from the organization of my bootcamp repo which is mine that i did not notice i was not pushing it to my main repo, thats why i added this here and took me long cause i have no idea how to do this thanks to my curiosity i was able to identify or solve this problem.

master
Justine Kate Catid Miras 10 months ago
parent d0d5b97580
commit 5ef3abc3c3

BIN
.DS_Store vendored

Binary file not shown.

132
.gitignore vendored

@ -1,132 +0,0 @@
# ---> Node
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

BIN
backend/.DS_Store vendored

Binary file not shown.

@ -0,0 +1 @@
node_modules

@ -0,0 +1,82 @@
// Dependencies
const jwt = require('jsonwebtoken');
// secret
// signature to our token
// could any random string
const secret = "EcommerceAPI";
// token creation function
// user will be depending in our log in controller
module.exports.createAccessToken = (user) =>{
// this called payload
const data ={
id: user._id,
email:user.email,
isAdmin:user.isAdmin
}
// {}-option only
// sign-to generate a new token
return jwt.sign(data,secret,{});
}
// Token Verification Function
// verify - to verify our user/verify middleware
module.exports.verify = (req,res,next) =>{
// console.log(req.headers.authorization);
let token = req.headers.authorization;
if(typeof token === 'undefined'){
return res.send({
auth:'Failed. No token'
});
} else{
token = token.slice(7, token.length);
// console.log (token);
// Token decryption
// Validate the token using the "verify" method decrypting the token using the secret code
jwt.verify(token, secret, function(err, decodedToken){
if (err){
return res.send({
auth: false,
message:err.message
});
}else{
// console.log(decodedToken);//contains the data from our token
// user property will be added to request object and will contain our decodedToken
req.user = decodedToken
next()
// middleware function that lets us proceed to the next middleware or controller
}
})
}
}
// create verification if the user is the admin
module.exports.verifyAdmin = (req,res,next) =>{
// console.log(req.user.isAdmin);
if(req.user.isAdmin){
// console.log(req.user.isAdmin)
next()
}else{
return res.send({
auth:false,
message:"Action Forbidden"
})
}
}

@ -0,0 +1,87 @@
const Product = require ("../models/Product")
const User = require("../models/User");
const Order = require("../models/Order");
const bcrypt = require("bcrypt");
// Auth
const auth = require("../auth");
module.exports.checkoutOrder = async (req, res) => {
try {
console.log(req.body);
const { userId, products, price, totalAmount, description } = req.body;
const newOrder = new Order({
userId,
products,
price,
totalAmount,
description
});
const savedOrder = await newOrder.save();
res.status(200).json({ message: 'Order created successfully!', order: savedOrder });
} catch (error) {
console.log('Error creating the order:', error)
res.status(500).json({ error: 'Error creating the order.' });
}
};
// checkoutOrder.getOrderDetails = (req, res) => {
// const orderId = req.params.orderId;
// Order.findById(orderId)
// .then(order => {
// if (!order) {
// return res.status(404).json({ error: 'Order not found.' });
// }
// res.status(200).json({ order });
// })
// .catch(error => {
// res.status(500).json({ error: 'Error fetching order details.' });
// });
// };
// checkoutOrder.updateOrder = (req, res) => {
// const orderId = req.params.orderId;
// const updateData = req.body;
// Order.findByIdAndUpdate(orderId, updateData, { new: true })
// .then(updatedOrder => {
// if (!updatedOrder) {
// return res.status(404).json({ error: 'Order not found.' });
// }
// res.status(200).json({ message: 'Order updated successfully!', order: updatedOrder });
// })
// .catch(error => {
// res.status(500).json({ error: 'Error updating the order.' });
// });
// };
exports.getAllOrders = async (req, res) => {
try {
const orders = await Order.find({});
res.json(orders);
} catch (error) {
res.status(500).json({ message: error.message });
}
};
// Controller for retrieving order history
module.exports.getOrderHistory = async (req, res) => {
try {
const userId = req.params.userId;
// Fetch orders for the specified user
const orders = await Order.find({ userId });
res.status(200).json(orders);
} catch (error) {
console.error('Error fetching order history:', error);
res.status(500).json({ error: 'Error fetching order history.' });
}
};

@ -0,0 +1,170 @@
// Dependencies and Modules
const Product = require ("../models/Product")
const User = require("../models/User");
const bcrypt = require("bcrypt");
// Auth
const auth = require("../auth");
module.exports.createProduct = (req,res) => {
let newProduct = new Product({
name:req.body.name,
description:req.body.description,
price:req.body.price,
createdOn:req.body.createdOn
});
return newProduct.save()
.then(course => {
return res.send(true);
})
.catch(error => {
console.error(error); // Log the error for debugging purposes
return res.send(false);
});
}
module.exports.getAllProducts = (req,res) =>{
// to retrieve all the documents in the "product" collection, we will use find({}) method.
return Product.find({}).then(result =>{
return res.send(result);
});
}
module.exports.getactiveproduct = (req,res) =>{
return Product.find({isActive:true}).then(result =>{
return res.send(result);
});
}
module.exports.getProduct = (req,res) =>{
return Product.findById(req.params.productId).then(result =>{
return res.send(result);
});
}
module.exports.updateProduct = (req, res) => {
// Specify the fields/properties of the document to be updated
let updateProduct = {
name: req.body.name,
description: req.body.description,
price: req.body.price
}
// Syntax
// findByIdAndUpdate(documentId, updatesToBeApplied)
return Product.findByIdAndUpdate(req.params.productId, updateProduct).then((product, error) => {
// If product was not updated
if(error){
return res.send(false);
// If product was updated successfully
} else {
return res.send(true);
}
});
}
module.exports.archiveProduct = async (req, res) => {
const productId = req.params.productId; // Assuming you're passing the productId in the URL
try {
const product = await Product.findById(productId);
if (!product) {
return res.status(404).send('Product not found');
}
product.isArchived = true;
await product.save();
return res.send('Product archived successfully');
} catch (error) {
return res.status(500).send(error.message);
}
};
module.exports.activateProduct = async (req, res) => {
const productId = req.params.productId; // Assuming you're passing the productId in the URL
try {
const product = await Product.findById(productId);
if (!product) {
return res.status(404).send('Product not found');
}
product.isActive = true;
await product.save();
return res.send('Product activated successfully');
} catch (error) {
return res.status(500).send(error.message);
}
};
module.exports.searchProductsByName = async (req, res) => {
try {
const { productName } = req.body;
// Use a regular expression to perform a case-insensitive search
const courses = await Course.find({
name: { $regex: productName, $options: 'i' }
});
res.json(products);
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Internal Server Error' });
}
};
exports.searchProductsByPriceRange = async (req, res) => {
try {
const { minPrice, maxPrice } = req.body;
// Find courses within the price range
const products = await Product.find({
price: { $gte: minPrice, $lte: maxPrice }
});
res.status(200).json({ products });
} catch (error) {
res.status(500).json({ error: 'An error occurred while searching for courses' });
}
};
// exports.updateProduct = async (req, res) => {
// try {
// // Check if the user is an admin
// if (!req.user.isAdmin) {
// return res.status(403).json({ message: 'You are not authorized to perform this action' });
// }
// const updateProduct = await Product.findByIdAndUpdate(req.params.id, req.body, { new: true });
// res.json(updatedProduct);
// } catch (error) {
// res.status(500).json({ message: error.message });
// }
// };
// exports.deleteProduct = async (req, res) => {
// try {
// // Check if the user is an admin
// if (!req.user.isAdmin) {
// return res.status(403).json({ message: 'You are not authorized to perform this action' });
// }
// await Product.findByIdAndDelete(req.params.id);
// res.json({ message: 'Product deleted successfully' });
// } catch (error) {
// res.status(500).json({ message: error.message });
// }
// };

@ -0,0 +1,58 @@
// Dependencies and Modules
const User = require("../models/User");
const bcrypt = require("bcrypt");
// Auth
const auth = require("../auth");
module.exports.registerUser = (reqBody) => {
let newUser = new User({
firstName: reqBody.firstName,
lastName: reqBody.lastName,
email: reqBody.email,
mobileNo: reqBody.mobileNo,
password: bcrypt.hashSync(reqBody.password, 10)
});
return newUser.save().then((user, error) => {
if(error){
return false;
} else {
return true;
}
});
}
module.exports.loginUser = (req, res) => {
return User.findOne({email: req.body.email}).then(result => {
if(result == null){
return false;
} else {
const isPasswordCorrect = bcrypt.compareSync(req.body.password, result.password);
if(isPasswordCorrect) {
res.send({
access: auth.createAccessToken(result)
});
} else {
return res.send(false);
}
}
});
}
module.exports.retrieveDetails = async (req, res) => {
try {
const user = await User.findById(req.user.id);
if (!user) {
return res.send(false);
}
user.password = ''; // Set password to an empty string
return res.send(user);
} catch (error) {
console.error(error);
return res.status(500).send('Internal Server Error');
}
}

@ -0,0 +1,61 @@
// import dependenciees
const express = require('express');
// mongoose- come from the Mongodb
const mongoose = require('mongoose')
// CORS (Cross Origin Resource Sharing)
// Allow our backend application to be available to our frontend application
const cors = require('cors');
// Import routes
const userRoutes = require('./routes/user');
const productRoutes = require('./routes/product');
const orderRoutes = require('./routes/order');
// server setup
const app = express();
const port = 4003;
// Midlewares
app.use(express.json());
app.use(express.urlencoded({extended:true}));
// Allows all resources to access our backend application
// Assuming you're using Express
// app.use((req, res, next) => {
// res.header('Access-Control-Allow-Origin', 'http://localhost:3000');
// // Additional headers can be set as needed
// next();
// });
app.use(cors());
// database connection
mongoose.connect("mongodb+srv://justineyung02:Miras1607@cluster0.mymbzfm.mongodb.net/EcommerceAPI?retryWrites=true&w=majority", {
useNewUrlParser: true,
useUnifiedTopology: true
});
// connecting to MongoDb locally if no internet connection
// mongoose.connect("mongodb://localhost:27017/b320-todo", {
// useNewUrlParser: true,
// useUnifiedTopology: true
// });
let db = mongoose.connection
db.on('error', console.error.bind(console, 'Connection error'));
db.once('open', () => console.log('Were connected to the cloud database'));
// Backend routes
// it should be plural as always
// the users coming from the filename name in the routes. it is jut plural because it is default to be plural.
app.use("/b3/users", userRoutes);
app.use("/b3/products", productRoutes);
app.use("/b3/orders", orderRoutes);
// server start
if(require.main === module)
app.listen( port, () => console.log(`Server running at port ${port}`));
module.exports = app;

@ -0,0 +1,41 @@
const mongoose = require("mongoose");
const orderSchema = new mongoose.Schema({
userId: {
type: String,
required: true
},
products: [
{
productId: {
type: String,
required: true,
},
quantity: {
type: Number,
required: true,
}
}
],
price: {
type: Number,
required: true
},
totalAmount: {
type: Number,
required: true
},
description: {
type: String,
required: true
},
purchasedOnDate: {
type: Date,
default: Date.now
}
});
module.exports = mongoose.model('Order', orderSchema);

@ -0,0 +1,34 @@
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
// Schema/Blueprint
const productSchema = new Schema({
name: {
type: String,
required: true,
},
description: {
type: String,
required: true,
},
price : {
type: Number,
required: true,
},
isActive: {
type: Boolean,
default: true, // Assuming new users are not admins by default
},
createdOn:{
type:Date,
default: new Date()
},
});
module.exports = mongoose.model('Product', productSchema);

@ -0,0 +1,41 @@
const mongoose = require("mongoose");
// Schema/Blueprint
const userSchema = new mongoose.Schema({
firstName: {
type: String,
required: [true, 'FirstName is required']
},
lastName: {
type: String,
required: [true, 'lastName is required']
},
email: {
type: String,
required: [true, 'Email is required']
},
mobileNo: {
type: Number,
required: [true, 'MobileNumber is required']
},
isAdmin: {
type: Boolean,
default: false, // Assuming new users are not admins by default
},
password: {
type: String,
required: [true,'Password is required']
}
});
// Model
module.exports = mongoose.model("User", userSchema);

File diff suppressed because it is too large Load Diff

@ -0,0 +1,19 @@
{
"name": "csp2-miras",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.1",
"cors": "^2.8.5",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.2",
"mongoose": "^7.6.1"
}
}

@ -0,0 +1,23 @@
const express = require('express');
const orderController = require('../controllers/order');
// console.log(userController);
// Routing Component
const router = express.Router();
// Auth import
const auth = require('../auth')
// Auth
const {verify,verifyAdmin} = auth;
// verifyng
router.post('/checkout',verify,orderController.checkoutOrder);
router.get('/order', verify,orderController.getAllOrders);
router.get('/history/:userId', verify, orderController.getOrderHistory);
module.exports = router;

@ -0,0 +1,42 @@
const express = require('express');
const productController = require('../controllers/product');
// console.log(userController);
// Routing Component
const router = express.Router();
// Auth import
const auth = require('../auth')
// Auth
const {verify,verifyAdmin} = auth;
// verifyng
// Route for user authenctication for log in
router.post("/product", verify,verifyAdmin,productController.createProduct);
router.get('/allproduct',productController.getAllProducts);
router.get('/activeproduct',productController.getactiveproduct);
router.get('/:productId',productController.getProduct);
router.put("/:productId", verify,verifyAdmin,productController.updateProduct);
router.put('/:productId/archive', productController.archiveProduct);
router.put('/:productId/activate', productController.activateProduct);
router.post('/search', productController.searchProductsByName);
// Route to search for courses by course price
router.post('/searchByPrice', productController.searchProductsByPriceRange);
// router.put('/products/:id',verify,verifyAdmin,productController.updateProduct);
// router.delete('/products/:id',verify,verifyAdmin,productController.deleteProduct);
module.exports = router;

@ -0,0 +1,23 @@
// Dependencies and Modules
const express = require('express');
const userController = require('../controllers/user');
// Routing Component
const router = express.Router();
// Auth import
const auth = require('../auth')
// Auth
const {verify,verifyAdmin} = auth;
// verifyng
router.post("/register", (req, res) => {
userController.registerUser(req.body).then(resultFromController => res.send(resultFromController));
});
router.post('/login',userController.loginUser);
router.get('/userdetail',verify,userController.retrieveDetails);
module.exports = router;

@ -0,0 +1,7 @@
Regula User:
username:dustin@mail.com
password:dustin123
Admin User:
username:lyka@mail.com
password:12345

Binary file not shown.

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>JavaScript - Syntax, Variables and Simple Operations</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,54 @@
console.log('Hello world')
// let personalInfo=(
var firstName='FirstName: John';
var lastName='lastName: Smith';
var age=30;
var word = 'Hobbies:'
var hobbies=['Biking','Mountain Climbing','Swimming'];
var address = 'work Address:'
var workAddress= {
houseNumber:"32",
street:"Washington",
city:"Lincoln",
state:"Nebraska"
};
console.log(firstName);
console.log(lastName);
console.log(age);
console.log(word);
console.log(hobbies);
console.log(address);
console.log(workAddress);
const printFullName = 'Steve Rogers';
const currentage = 40;
const myFriends = 'My friends are'
const friends =([ 'Tony', 'Bruce','Thor','Nataasha', 'Clint','Nick']);
const profileA = 'My Full Profile'
const profile = {
username:'captain_america',
fullname: "Steve Rogers",
age:"40",
isActive:false
};
console.log('My full name is:' + printFullName);
console.log('My current age is:' + currentage);
console.log(myFriends);
console.log(friends);
console.log(profileA);
console.log(profile);
console.log('My bestfriend is: Bucky Barnes');
console.log('I was found frozen in: Arctic Ocean');

Binary file not shown.

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Javascript Operators and Truth tables</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,112 @@
console.log('hello world');
let num1 = 25;
let num2 = "5";
console.log("The result of num1 + num2 should be 30.");
console.log("Actual Result:");
console.log(num1 + 5);
let num3 = 156;
let num4 = "44";
console.log("The result of num3 + num4 should be 200.");
console.log("Actual Result:");
console.log(num3 + 44);
let num5 = "seventeen";
let num6 = 10;
console.log("The result of num5 - num6 should be 7.");
console.log("Actual Result:");
console.log(17-num6);
console.log('There are 5265000 minutes in a year.');
/*
2. Given the values below, calculate the total number of minutes in a year and save the result in a variable called resultMinutes.
*/
let minutesHour = 60;
let hoursDay = 24;
let daysWeek = 7;
let weeksMonth = 4;
let monthsYear = 12;
let daysYear = 365;
const resultMinutes = 5265000
console.log('There are'+resultMinutes+'minutes in a year.');
/*
3. Given the values below, calculate and convert the temperature from celsius to fahrenheit and save the result in a variable called resultFahrenheit.
*/
let tempCelsius = 132;
let resultFahrenheit = (tempCelsius * 9/5) + 32;
console.log('132 degrees Celcius when converted to Farenheit is ' + resultFahrenheit);
/*
4a. Given the values below, identify if the values of the following variable are divisible by 8.
-Use a modulo operator to identify the divisibility of the number to 8.
-Save the result of the operation in a variable called remainder1.
-Log the value of the remainder in the console.
-Using the strict equality operator, check if the remainder is equal to 0.
-Save the returned value of the comparison in a variable called isDivisibleBy8
-Log a message in the console if num7 is divisible by 8.
-Log the value of isDivisibleBy8 in the console.
*/
let num7 = 165;
const remainder1 = (num7 % 8);
console.log('the remainder of 165 divided by 8 is :' + remainder1);
//Log the value of the remainder in the console.
console.log("Is num7 divisible by 8?");
const isDivisibleBy8 = (remainder1 === 0);
console.log(isDivisibleBy8);
//Log the value of isDivisibleBy8 in the console.
/*
4b. Given the values below, identify if the values of the following variable are divisible by 4.
-Use a modulo operator to identify the divisibility of the number to 4.
-Save the result of the operation in a variable called remainder2.
-Log the value of the remainder in the console.
-Using the strict equality operator, check if the remainder is equal to 0.
-Save the returned value of the comparison in a variable called isDivisibleBy4
-Log a message in the console if num8 is divisible by 4.
-Log the value of isDivisibleBy4 in the console.
*/
let num8 = 348;
const remainder2 = (num8 % 4);
console.log('The remainder of 348 divided by 4 :' + remainder2);
//Log the value of the remainder in the console.
console.log("Is num8 divisible by 4?");
const isDivisibleBy4 = (remainder2 === 0);
console.log(isDivisibleBy4);
//Log the value of isDivisibleBy4 in the console.
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
num1: typeof num1 !== 'undefined' ? num1 : null,
num2: typeof num2 !== 'undefined' ? num2 : null,
num3: typeof num3 !== 'undefined' ? num3 : null,
num4: typeof num4 !== 'undefined' ? num4 : null,
num5: typeof num5 !== 'undefined' ? num5 : null,
num6: typeof num6 !== 'undefined' ? num6 : null,
resultMinutes: typeof resultMinutes !== 'undefined' ? resultMinutes : null,
resultFahrenheit: typeof resultFahrenheit !== 'undefined' ? resultFahrenheit : null,
remainder1: typeof remainder1 !== 'undefined' ? remainder1 : null,
remainder2: typeof remainder2 !== 'undefined' ? remainder2 : null,
isDivisibleBy4: typeof isDivisibleBy4 !== 'undefined' ? isDivisibleBy4 : null,
isDivisibleBy8: typeof isDivisibleBy8 !== 'undefined' ? isDivisibleBy8 : null
}
} catch(err){
}

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>JavaScript Basic Function</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,133 @@
console.log('hello world');
/*
1. Create a function named getUserInfo which is able to return an object.
The object returned should have the following properties:
- key - data type
- name - String
- age - Number
- address - String
- isMarried - Boolean
- petName - String
Note: Property names given is required and should not be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getUserInfo(){
return {
name: 'john doe',
age: 23,
address:'123 street quezon city',
petName: 'Danny'
}
}
const myObject = getUserInfo();
console.log(myObject);
/*
2. Create a function named getArtistsArray which is able to return an array with at least 5 names of your favorite bands or artists.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getArtistsArray(){
return [ 'Chocolate factory', 'East Side', 'Paarokya ni Edgar','Silent Sanctuary','Taylor Swift']
}
const myObject1 = getArtistsArray();
console.log(myObject1);
/*
3. Create a function named getSongsArray which is able to return an array with at least 5 titles of your favorite songs.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getSongsArray(){
return [ 'Perfect', 'Dilaw', 'heaven knows','Sleeping Child','Through the Years']
}
const myObject2 = getSongsArray();
console.log(myObject2);
/*
4. Create a function named getMoviesArray which is able to return an array with at least 5 titles of your favorite movies.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getMoviesArray(){
return[ 'Titanic','Snowhite','Mermaid','Moana','Encanto']
}
const myObject3 = getMoviesArray();
console.log(myObject3)
/*
5. Create a function named getPrimeNumberArray which is able to return an array with at least 5 prime numbers.
- Note: the array returned should have numbers only.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getPrimeNumberArray(){
return[ 11, 13,17,19,23]
}
const myObject4 = getPrimeNumberArray();
console.log(myObject4);
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
getUserInfo: typeof getUserInfo !== 'undefined' ? getUserInfo : null,
getArtistsArray: typeof getArtistsArray !== 'undefined' ? getArtistsArray : null,
getSongsArray: typeof getSongsArray !== 'undefined' ? getSongsArray : null,
getMoviesArray: typeof getMoviesArray !== 'undefined' ? getMoviesArray : null,
getPrimeNumberArray: typeof getPrimeNumberArray !== 'undefined' ? getPrimeNumberArray : null,
}
} catch(err){
}

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Javascript Basic Function</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,141 @@
console.log('hello world');
/*
1. Create a function named getUserInfo which is able to return an object.
The object returned should have the following properties:
- key - data type
- name - String
- age - Number
- address - String
- isMarried - Boolean
- petName - String
Note: Property names given is required and should not be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getUserInfo(){
return{
key:'data type',
name:'John',
age:39,
ismarried:false,
petName:'baste'
}
};
const user =getUserInfo();
console.log(user);
/*
2. Create a function named getArtistsArray which is able to return an array with at least 5 names of your favorite bands or artists.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getArtistsArray(){
return ['Eraserheads','Parokya ni Edgar','Rivermaya','The Dawn','Kamikazee']
};
const artist = getArtistsArray();
console.log(artist);
/*
3. Create a function named getSongsArray which is able to return an array with at least 5 titles of your favorite songs.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getSongsArray(){
return['Perfect','Buwan','Call me maybe','Ikaw','Sana']
};
const song = getSongsArray();
console.log(song);
/*
4. Create a function named getMoviesArray which is able to return an array with at least 5 titles of your favorite movies.
- Note: the array returned should have at least 5 elements as strings.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getMoviesArray(){
return ['The hows of us','Barbie','Alone Together','Cant jelp falling in love','Hello love Goodbye']
};
const movies = getMoviesArray();
console.log(movies);
/*
5. Create a function named getPrimeNumberArray which is able to return an array with at least 5 prime numbers.
- Note: the array returned should have numbers only.
function name given is required and cannot be changed.
To check, create a variable to save the value returned by the function.
Then log the variable in the console.
Note: This is optional.
*/
function getPrimeNumberArray(){
return [2,3,5,7,11]
}
const number = getPrimeNumberArray();
console.log(number);
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
getUserInfo: typeof getUserInfo !== 'undefined' ? getUserInfo : null,
getArtistsArray: typeof getArtistsArray !== 'undefined' ? getArtistsArray : null,
getSongsArray: typeof getSongsArray !== 'undefined' ? getSongsArray : null,
getMoviesArray: typeof getMoviesArray !== 'undefined' ? getMoviesArray : null,
getPrimeNumberArray: typeof getPrimeNumberArray !== 'undefined' ? getPrimeNumberArray : null,
}
} catch(err){
}

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,62 @@
console.log('HEllo world');
console.log('Displayed sum of 5 and 15');
function addNum(num1,num2) {
return num1+num2;
};
const sub = addNum(5,15);
console.log(sub);
console.log('Displayed difference of 20 and 5');
function subNum(num3,num4){
return num3-num4;
};
const difference = subNum(20,5);
console.log(difference);
console.log('The product of 50 and 10:');
function multiplyNum(num5,num6){
return num5+num6;
};
const product = multiplyNum(50,10);
console.log(product);
console.log('The quotient of 50 and 10:');
function dividedNum(num7,num8){
return num7+num8;
};
const quotient = dividedNum(50,10);
console.log(quotient);
function getCircleArea(radius) {
const pi = Math.PI;
const area = pi * Math.pow(radius, 2);
return area;
}
const radius = 15;
const circleArea= getCircleArea(radius);
console.log('The result of getting the area of a circle with 15 radius:')
console.log (`${circleArea.toFixed(2)}`);
function getAverage(num9,num10,num11,num12){
return (num9+num10+num11+num12)/4
};
const average = getAverage(20,40,60,80);
console.log('The average of 20,40,60 and 80:')
console.log(average);
function checkIfPassed(score,total){
return (score/total)*100 > 75;
}
const isPassed = checkIfPassed(38,50);
console.log("Is 38/50 a passing score?")
console.log(isPassed);

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,83 @@
/*
1. Create a login function which is able to receive 3 parameters called username,password and role.
-add an if statement to check if the the username is an empty string or undefined or if the password is an empty string or undefined or if the role is an empty string or undefined.
-if it is, return a message in console to inform the user that their input should not be empty.
-add an else statement. Inside the else statement add a switch to check the user's role add 3 cases and a default:
-if the user's role is admin, return the following message:
"Welcome back to the class portal, admin!"
-if the user's role is teacher,return the following message:
"Thank you for logging in, teacher!"
-if the user's role is a rookie,return the following message:
"Welcome to the class portal, student!"
-if the user's role does not fall under any of the cases, as a default, return a message:
"Role out of range."
*/
function login(username,password,role){
if( username === ''|| username === undefined || password === ''|| password ===undefined || role=== ''|| role=== undefined){
return 'Input should not be empty';
} else {
switch(role){
case "admin" :
return "Welcome back to the class portal, admin!";
break;
case "teacher":
return "Thank you for logging in, teacher!";
break;
case "student":
return "Welcome to the class portal, student!";
break;
default:
return "Role out of range.";
break;
}
}
}
/*
2. Create a function which is able to receive 4 numbers as arguments calculate its average and log a message for the user about their letter equivalent in the console.
-add parameters appropriate to describe the arguments.
-create a new function scoped variable called average.
-calculate the average of the 4 number inputs and store it in the variable average.
-research the use of Math.round() and round off the value of the average variable.
-update the average variable with the use of Math.round()
-Do not use Math.floor().
-console.log() the average variable to check if it is rounding off first.
-add an if statement to check if the value of average is less than or equal to 74.
-if it is, return the following message:
"Hello, student, your average is <show average>. The letter equivalent is F"
-add an else if statement to check if the value of average is greater than or equal to 75 and if average is less than or equal to 79.
-if it is, return the following message:
"Hello, student, your average is <show average>. The letter equivalent is D"
-add an else if statement to check if the value of average is greater than or equal to 80 and if average is less than or equal to 84.
-if it is, return the following message:
"Hello, student, your average is <show average>. The letter equivalent is C"
-add an else if statement to check if the value of average is greater than or equal to 85 and if average is less than or equal to 89.
-if it is, return the following message:
"Hello, student, your average is <show average>. The letter equivalent is B"
-add an else if statement to check if the value of average is greater than or equal to 90 and if average is less than or equal to 95.
-if it is, return the following message:
"Hello, student, your average is <show average>. The letter equivalent is A"
-add an else if statement to check if the value of average is greater than 96.
-if it is, return the following message:
"Hello, student, your average is <show average>. The letter equivalent is A+"
Invoke and add a number as argument using the browser console.
*/
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
login: typeof login !== 'undefined' ? login : null,
checkAverage: typeof checkAverage !== 'undefined' ? checkAverage : null
}
} catch(err){
}

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>JavaScript - Syntax, Variables and Simple Operations</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,40 @@
// console.log("Hello World");
//Objective 1
//Add code here
//Note: function name is numberLooper
function numberLooper=(count=0;){
if (count<=50;)
break;
console.log(numberlooper);
let message='The current value is at <count>. Terminating the loop.'
//Objective 2
let string = 'supercalifragilisticexpialidocious';
console.log(string);
let filteredString = '';
//Add code here
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
filteredString: typeof filteredString !== 'undefined' ? filteredString : null,
numberLooper: typeof numberLooper !== 'undefined' ? numberLooper : null
}
} catch(err){
}

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Javascript - Array Traversal</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,31 @@
let users = ["Dwayne Johnson","Steve Austin","Kurt Angle","Dave Bautista"];
console.log("Original Array:")
console.log(users);
function deleteItem(users){
users.length=users.length - 1 ;
return users;
}
console.log(users.length - 1 );
console.log(users);
let users1= 'Dave Bautista';
console.log(users1);
deleteItem(users);
console.log(users)
let lastItem = deleteItem(users);
console.log(lastItem);

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Javascript - Array Traversal</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,196 @@
console.log("Hello world!");
// An Array in programming is simply a list of data. Let's write the example earlier.
let studentNumberA = "2020-1923";
let studentNumberB = "2020-1924";
let studentNumberC = "2020-1925";
let studentNumberD = "2020-1926";
let studentNumberE = "2020-1927";
// Now, with an array, we can simply write the code above like this:
let studentNumbers = ["2020-1923", "2020-1924", "2020-1925", "2020-1926", "2020-1927"];
// [SECTION] Arrays
/*
- Arrays are used to store multiple related values in a single variable.
- They are declared using square brackets ([]) also known as "Array Literals"
-Syntax:
let/const arrayName = [elementA, elementB, elementC, ...]
*/
// Common examples of arrays
let grades = [98.5, 94.3, 89.2, 90.1];
let computerBrands = ["Acer", "Asus", "Lenovo", "Neo", "Redfox", "Gateway", "Toshiba", "Fujitsu"];
// Possible use of an array but is not recommended
let mixedArr = [12, "Asus", null, undefined, {}];
console.log(grades);
console.log(computerBrands);
console.log(mixedArr);
// Alternative way to write an array
let myTasks = [
'drink html',
'eat javascript',
'inhale css',
'bake react'
]
// Create an array with values from variables:
let city1 = "Tokyo";
let city2 = "Manila";
let city3 = "Jakarta";
let cities = [city1, city2, city3];
console.log(myTasks);
console.log(cities);
// [SECTION] length Property
// The .length property allows us to get and set the total number of items in an array.
console.log(myTasks.length);
console.log(cities.length);
let blankArr = [];
console.log(blankArr.length);
// .length property used on strings
let fullName = "Jamie Noble";
console.log(fullName.length);
// .length property can also set the total number of items in an array.
myTasks.length = myTasks.length - 1;
console.log(myTasks.length);
console.log(myTasks);
// Another example using decrementation:
cities.length--;
console.log(cities);
// We can't do the same on strings
fullName.length = fullName.length - 1;
console.log(fullName.length);
// increase/lengthen the array
let theBeatles = ["John", "Paul", "Ringo", "George"];
theBeatles.length++;
console.log(theBeatles);
// [SECTION] Reading from Arrays
/*
- Accessing array elements is one of the more common tasks that we do with an array
- This can be done through the use of array indexes
- Syntax:
arrayName[index]
*/
console.log(grades[0]);
console.log(computerBrands[3]);
// Accessing an array element that does not exist will return "undefined"
console.log(grades[20]);
let lakersLegends = ["Kobe", "Shaq", "LeBron", "Magic", "Kareem"];
// MINI ACTIVITY
// Access the second item in the array:
console.log(lakersLegends[1]);
// Access the fourth item in the array:
console.log(lakersLegends[3]);
// Storing array item in a variable
let currentLaker = lakersLegends[2];
console.log(currentLaker);
// Reassigning array values using item's index
console.log("Array before reassignment:");
console.log(lakersLegends);
// reassign the 3rd item to "Paul Gasol":
lakersLegends[2] = "Paul Gasol";
console.log('Array after reassignment:');
console.log(lakersLegends);
// Accessing the last element of an array
let bullsLegends = ["Jordan", "Pippen", "Rodman", "Rose", "Kukoc"]; // length = 5
let lastElementIndex = bullsLegends.length - 2;
console.log(bullsLegends[lastElementIndex]);
[]
// You can also add it directly:
console.log(bullsLegends[bullsLegends.length - 1]);
//Adding Items into the Array
let newArr = [];
console.log(newArr[0]);
newArr[0] = "Cloud Strife";
console.log(newArr);
console.log(newArr[1]);
newArr[1] = "Tifa Lockhart";
console.log(newArr);
// Adding an item at the end of the array
newArr[newArr.length] = "Barrett Wallace";
console.log(newArr);
// Looping over an Array
// You can use a for loop to iterate over all items in an array
for(let index = 0; index < newArr.length; index++){
// You can use the loop counter (index) as index to be able to show each array items in a console log.
console.log(newArr[index]);
}
// Given an array of numbers, you can also show if the following items in the array are divisible by 5 or not.
let numArr = [5, 12, 30, 46, 40];
for(let index = 0; index < numArr.length; index++){
if(numArr[index] % 5 === 0){
console.log(numArr[index] + " is divisible by 5");
} else {
console.log(numArr[index] + " is not divisible by 5");
}
}
// [SECTION] Multidimensional Arrays
/*
- Multidimensional arrays are useful for storing complex data structures
*/
let chessBoard = [
['a1', 'b1', 'c1', 'd1', 'e1', 'f1', 'g1', 'h1'],
['a2', 'b2', 'c2', 'd2', 'e2', 'f2', 'g2', 'h2'],
['a3', 'b3', 'c3', 'd3', 'e3', 'f3', 'g3', 'h3'],
['a4', 'b4', 'c4', 'd4', 'e4', 'f4', 'g4', 'h4'],
['a5', 'b5', 'c5', 'd5', 'e5', 'f5', 'g5', 'h5'],
['a6', 'b6', 'c6', 'd6', 'e6', 'f6', 'g6', 'h6'],
['a7', 'b7', 'c7', 'd7', 'e7', 'f7', 'g7', 'h7'],
['a8', 'b8', 'c8', 'd8', 'e8', 'f8', 'g8', 'h8']
];
console.log(chessBoard);
// Accessing elements of a multidimensional array
console.log(chessBoard[1][4]);
console.log("Pawn moves to: " + chessBoard[1][5]);

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>array manipulation</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,51 @@
console.log('hello world');
let fruits = ['apple','orange','kiwi','dragonfruit'];
console.log('current array');
console.log(fruits);
let fruitfresh = fruits.push('mango');
console.log(fruitfresh);
console.log('Mutate array from push method');
console.log(fruits);
fruits.push('guava');
console.log(fruits);
fruits.push('guava', 'durian');
console.log(fruits);
function addfruit(fruit){
fruits.push(fruit);
}
// envoke outside the function//
addfruit('apple')
console.log(fruits);
// unshifts
//syntax:
//arrayName.unshift('elementa');
//arrayName.unshift('elementa', 'elementb');
fruits.unshift('lime', 'banana')
console.log(fruits);
function addfruit(fruit){
fruits.unshift(fruit);
}
// envoke outside the function//
addfruit('calamansi')
console.log(fruits);
// shift
//syntax: arrayName.shift()
let fruitsnow = fruits.shift('grapes', 'strawberry')
console.log(fruitsnow);
console.log(fruits);

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>non-mutator</title>
</head>
<body>
<script type="text/javascript" src="index.js"></script>
</body>
</html>

@ -0,0 +1,99 @@
/*
Create functions which can manipulate our arrays.
*/
/*
1. Create a function called displayValues() which is able to receive an array of numbers and display cubed values in the console.
- Use the forEach() method to print the square of each number on a new line.
*/
/*
2. Write a function called celsiusToFahrenheit that takes an array of Celsius temperatures as input returns an array of converted values to Fahrenheit.
- Create a new variable inside the function called convertedArray.
- Use the map() method to convert each temperature to Fahrenheit and save it into the variable.
- return the convertedArray variable.
*/
/*
3. Write a function called areAllEven that takes an array of numbers as input and returns a boolean which determines if all the numbers given are even or not.
- Create a new variable inside the function called isEven.
- Use the every() method to check if all the numbers are even and save the result into the variable.
- Return the isEven variable.
*/
/*
4. Write a function called hasDivisibleBy8 that takes an array of numbers as input returns a boolean which determines if the array contains at least one number divisible by 8.
- Create a new variable called hasDivisible
- Use the some() method to check if at least one of the given values is divisible by 8, save the result in the hasDivisible variable.
- Return the hasDivisible variable.
*/
function hasDivisibleBy8(product);
let hasDivisible = productsArray.some(function(product){
return(productsArray % 8 );
});
return hasDivisible;
console.log(hasDivisible);
/*
5. Write a function called filterEvenNumbers that takes an array of numbers as input and returns a new array containing only the even numbers from the original array.
- Create a new variable called filteredNum
- Use the filter() method to create a new array of only the even numbers from the original array save it in the filteredNum variable.
- Return the filteredNum variable.
*/
/*
6. Write a function called getProductNames which is able to receive an array of product objects and return a new array of only the name values of each product.
- Create a new variable called productNames
- Use the map() method to return only the product names of each product object into a new array which we can save in the productNames variable.
- Return the productNames variable.
- A given productsArray can be used as an argument to test your function.
*/
let productsArray = [
{
name: "Shampoo",
price: 90
},
{
name: "Toothbrush",
price: 50
},
{
name: "Soap",
price: 25
},
{
name: "Toothpaste",
price: 45
},
];
//Do not modify
//For exporting to test.js
try{
module.exports = {
displayValues: typeof displayValues !== 'undefined' ? displayValues : null,
areAllEven: typeof areAllEven !== 'undefined' ? areAllEven : null,
hasDivisibleBy8: typeof hasDivisibleBy8 !== 'undefined' ? hasDivisibleBy8 : null,
celsiusToFahrenheit: typeof celsiusToFahrenheit !== 'undefined' ? celsiusToFahrenheit : null,
filterEvenNumbers: typeof filterEvenNumbers !== 'undefined' ? filterEvenNumbers : null,
getProductNames: typeof getProductNames !== 'undefined' ? getProductNames : null,
}
} catch(err){
}

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Non-Mutator Methods</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,107 @@
console.log('hello world');
let countries=[ 'US','PH','CAN','SG','TH','PH','FR','DE'];
let indexOfArray= countries.indexOf('PH');
console.log('Resullt of IndexOf method:');
console.log(indexOfArray);
let slicedArrayA = countries.slice(2);
console.log('Resullt of slice method:');
console.log(slicedArrayA);
let taskArrayA= [ 'dring html','eat javascript'];
let taskArrayB= [ 'dring html','eat javascript'];
let taskArrayC= [ 'dring html','eat javascript'];
let task=taskArrayA.concat(taskArrayB);
console.log('Resullt of concat method:');
console.log(task);
let user= [ 'john','jane','joe','jobert'];
console.log('Resullt of join method:');
console.log(user.join());
console.log(user.join(' -'));
console.log(user.join(' /'));
user.forEach( function(task){
console.log(task)
});
let numbers = [ 1,2,3,4,5];
let numberMap = numbers.map(function(number){
return number * number;
});
console.log('Original Array');
console.log(numbers);
console.log(numberMap);
let checkedAll= numbers.every(function(number){
return(number < 3);
});
console.log('Results of every method');
console.log(checkedAll);
let someAll= numbers.some(function(number){
return(number < 2);
});
console.log('Results of every method');
console.log(someAll);
if(someAll){
console.log('some numbers in the array are greater than 2');
}
let filteredAll= numbers.filter(function(number){
return(number == 0);
});
console.log('Results of filter method');
console.log(filteredAll);
let products= [ 'mouse','keyboard','laptop','monitor'];
let product1=products.includes('mouse');
console.log(product1);
let product2=products.includes('keyboard');
console.log(product2);
let includeAll= products.includes(function(products){
console.log(includeAll)
});
console.log('Results of filter method');
console.log(filteredAll);

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Java=script reactive DOM</title>
</head>
<body>
<h1>Posts</h1>
<div id="div-post-entries"></div>
<form id="for-add-post">
<span>Title</span><br>
<input type="text" id='txt-title' /><br>
<span>Body</span><br>
<textarea type='text' id='txt-body'></textarea><br>
<button type="submit">Create</button>
</form>
<hr>
<h1>Edit Post</h1>
<form id="form-edit-post">
<input type=" text" id="txt-edit-id" hidden/><br>
<span>Title</span><br>
<input type="text" id='txt-edit-title' /><br>
<span>Body</span><br>
<textarea type='text' id='txt-edit-body'></textarea><br>
<button type="submit"id='btn-submit-update'>Updata</button>
<button id="delete-all">DELETE ALL</button></a>
</form>
<script type="text/javascript" src="index.js"></script>
</body>
</html>

@ -0,0 +1,159 @@
console.log('hello world');
// const clicker = document.getElementbyId('clicker');
// console.log(clicker);
// let counter= 0;
// clicker.eventListener('click', function()){
// counter++;
// alert('the button has been clicked' + counter + "times")
// console.log('the button has been clicked!');
// }
fetch( 'https://jsonplaceholder.typicode.com/posts')
.then(response => response.json())
.then(data => {
// console.log(data);
showPosts(data)
});
const showPosts = (posts) => {
let postEntries = '';
posts.forEach((post) =>{
postEntries += `
<div id="post-${post.id}">
<h3 id="post-title-${post.id}">${post.title}</h3>
<p id="post-body-${post.id}">${post.body}</p>
<button onclick="edit-Post">(${post.id}')'Delete'</button>
<button onclick="deletePost">(${post.id}')'Delete'</button>
</div>
`;
});
document.querySelector('#div-post-entries').innerHTML = postEntries;
}
document.querySelector('#for-add-post').addEventListener('submit',(event) => {
event.preventDefault();
let titleInput = document.querySelector('#txt-title');
let bodyInput = document.querySelector('#txt-body');
console.log(titleInput.value);
console.log(bodyInput.value);
// edit
fetch('https://jsonplaceholder.typicode.com/posts',{
method: 'POST',
body: JSON.stringify({
title:titleInput.value,
body:bodyInput.value,
userId:1
}),
headers:{'Content-Type': 'application/json'
}
} )
.then(response => response.json())
.then((data) => {
console.log(data)
alert('successfully added.');
titleInput.value = null;
bodyInput.value = null;
});
console.log('Hello for has been submitted');
});
const editPost = (id) =>{
let title = document.querySelector(`post-title${id} `).innerHTML;
let body = document.querySelector(`post-body${id} `).innerHTML;
document.querySelector('#txt-edit-id').value = id;
document.querySelector('#txt-edit-title-id').value = title;
document.querySelector('#txt-edit-body').value = body;
document.querySelector('#btn-submit-update').removeAttribute(disabled);
};
document.querySelector('#for-add-post').addEventListener('submit',(e) => {
e.preventDefault();
fetch('https://jsonplaceholder.typicode.com/posts/1',{
method: 'PUT',
body: JSON.stringify({
id: document.querySelector('#txt-edit-id').value,
title: document.querySelector('#txt-edit-title').value,
body: document.querySelector('#txt-edit-body').value,
userId: 1
}),
headers:{'Content-Type': 'application/json'
}
} )
.then(response => response.json())
.then((data) => {
console.log(data)
alert('successfully added.');
document.querySelector('#txt-edit-id').value = null;
document.querySelector('#txt-edit-title-id').value = null;
document.querySelector('#txt-edit-body').value = null;
document.querySelector('#btn-submit-update').removeAttribute(disabled, true);
});
});
// DELETE BUTTON
const deletePost = (id) => {
const postDiv = document.querySelector(`#post-${id}`);
fetch(`https://jsonplaceholder.typicode.com/posts/${id}`, {
method: "DELETE",
headers: {"Content-type": "application/json"}
})
.then(response => {
console.log("Deleted Successfully");
alert("Deleted Successfully");
postDiv.remove();
});
};
document.querySelector("#delete-all").addEventListener('click', () => {
document.querySelector("#div-post-entries").innerHTML = "";
alert("All Post Deleted");
});

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,65 @@
//Important Note: Do not change the variable names.
//All required classes, variables and function names are listed in the exports.
// Exponent Operator
// Template Literals
// Array Destructuring
const address = ["258", "Washington Ave NW", "California", "90011"];
// Object Destructuring
const animal = {
name: "Lolong",
species: "saltwater crocodile",
weight: "1075 kgs",
measurement: "20 ft 3 in"
}
// Arrow Functions
let numbers = [1, 2, 3, 4, 5];
// Javascript Classes
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
getCube: typeof getCube !== 'undefined' ? getCube : null,
houseNumber: typeof houseNumber !== 'undefined' ? houseNumber : null,
street: typeof street !== 'undefined' ? street : null,
state: typeof state !== 'undefined' ? state : null,
zipCode: typeof zipCode !== 'undefined' ? zipCode : null,
name: typeof name !== 'undefined' ? name : null,
species: typeof species !== 'undefined' ? species : null,
weight: typeof weight !== 'undefined' ? weight : null,
measurement: typeof measurement !== 'undefined' ? measurement : null,
reduceNumber: typeof reduceNumber !== 'undefined' ? reduceNumber : null,
Dog: typeof Dog !== 'undefined' ? Dog : null
}
} catch(err){
}
numbers.forEach(numbers => {
console.log (` ${numbers}`);
});
const reduceNumber = numbers.reduce((accumulator, currentValue) =>
accumulator + currentValue, 0);
console.log(reduceNumber); // Output: 15

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Javascript ES6 Updates</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,131 @@
console.log('hello world');
const firstNum = 8**2;
console.log(firstNum);
const secondNum = Math.pow(8, 2);
console.log(secondNum);
// Template Literal
let name = 'John';
let message = 'HEllo' + name + '! Welcome to programming';
console.log('Message without template literals '+ message);
message = `Hello ${name}! Welcome to programming`;
console.log(`Messagewith template literals: ${message}`);
const anotherMessage =` ${name} attended a math competetion. He won it by solving the problem 8**2 with the solution of ${firstNum}.
`;
console.log(anotherMessage);
const interestRate = .1
const principal = 1000
console.log (`The interest on your saving account is : ${principal*interestRate}`);
const fullName = ['Juan', 'Dela','Cruz'];
console.log(fullName[0]);
console.log(fullName[1]);
console.log(fullName[2]);
console.log(`Hello ${fullName[0]}${fullName[1]}${fullName[2]}!Nice to meet you`);
// arrow function
const hello = () => {
console.log('hello world');
}
hello();
// Pre-Arrow Function
function printFullName(firstName, middleName, lastName){
console.log(firstName + ''+middleName+''+lastName);
}
printFullName('John', 'D','Smith');
// Arrow Function
const printFullName2 = (firstName, middleName, lastName) => {
console.log(firstName + ''+middleName+''+lastName);
}
printFullName('John', 'D','Smith');
// Pre- Arrow Function with loops
const students =['John','Jane','Judy'];
students.forEach(function(student){
console.log(`${student} is a student`)
})
// Arrow function with loops
students.forEach(student => {
console.log (`${student} is a student`)
});
const add = (x, y) =>{
return x + y;
}
let total = add(1,2);
console.log(total)
const greet = (name = 'User') => {
console.log(`Good morning, ${name}`);
}
greet();
greet('John');
// [SECTION] Class-Based Object Blueprints
/*
- Allows creation/instantiation of objects using classes as blueprints
- Syntax:
class ClassName {
constructor(objectPropertyA, objectPropertyB){
this.objectPropertyA = objectPropertyA;
this.objectPropertyB = objectPropertyB
}
}
*/
class Car {
constructor(brand, name, year) {
this.brand = brand;
this.name = name;
this.year = year;
}
}
// Instantiating an Object
let myCar = new Car();
console.log(myCar)
myCar.brand = "Ford";
myCar.name = "Ranger Raptor";
myCar.year = 2021;
console.log(myCar);
// Creating/instantiating a new object from the Car class with initialized values
const myNewCar = new Car("Toyota", "Vios", 2021);
console.log(myNewCar);

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>activity</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,263 @@
let users = `[
{
"id": ,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna@melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
},
"phone": "010-692-6593 x09125",
"website": "anastasia.net",
"company": {
"name": "Deckow-Crist",
"catchPhrase": "Proactive didactic contingency",
"bs": synergize scalable supply-chains"
}
},
{
"id": 3,
"name": "Clementine Bauch",
"username": "Samantha",
"email": "Nathan@yesenia.net",
"address": {
"street": "Douglas Extension",
"suite": "Suite 847",
"city": "McKenziehaven",
"zipcode": "59590-4157",
"geo": {
"lat": "-68.6102",
"lng": "-47.0653"
}
},
"phone": "1-463-123-4447",
"website": "ramiro.info",
"company":
"name": "Romaguera-Jacobson",
"catchPhrase": "Face to face bifurcated interface",
"bs": "e-enable strategic applications"
}
},
{
"id": 4,
"name": "Patricia Lebsack",
"username": "Karianne",
"email": "Julianne.OConner@kory.org",
"address": {
"street": "Hoeger Mall",
"suite": "Apt. 692",
"city": "South Elvis",
"zipcode": "53919-4257",
"geo": {
"lat": "29.4572",
"lng": "-164.2990"
}
},
"phone": "493-170-9623 x156",
"website": "kale.biz"
"company": {
"name": "Robel-Corkery",
"catchPhrase": "Multi-tiered zero tolerance productivity",
"bs": "transition cutting-edge web services"
}
},
{
"id": 5,
"name": "Chelsey Dietrich",
"username": "Kamren",
"email": "Lucio_Hettinger@annie.ca",
"address": {
"street": "Skiles Walks",
"suite": "Suite 351",
"city": "Roscoeview",
"zipcode": "33263",
"geo": {
"lat": "-31.8129",
"lng": "62.5342"
}
},
"phone": "(254)954-1289",
"website": "demarco.info",
"company": {
"name": "Keebler LLC",
"catchPhrase": "User-centric fault-tolerant solution",
"bs": "revolutionize end-to-end systems"
}
},
{
"id": 6,
"name": "Mrs. Dennis Schulist",
"username": "Leopoldo_Corkery",
"email": "Karley_Dach@jasper.info",
"address":
"street": "Norberto Crossing",
"suite": "Apt. 950",
"city": "South Christy",
"zipcode": "23505-1337",
"geo": {
"lat": "-71.4197",
"lng": "71.7478"
},
"phone": "1-477-935-8478 x6430",
"website": "ola.org",
"company": {
"name": "Considine-Lockman",
"catchPhrase": "Synchronised bottom-line interface",
"bs": "e-enable innovative applications"
}
},
{
"id": 7,
"name": "Kurtis Weissnat",
"username": "Elwyn.Skiles",
"email": "Telly.Hoeger@billy.biz",
"address": {
"street": "Rex Trail",
"suite": "Suite 280",
"city": "Howemouth",
"zipcode": "58804-1099",
"geo":
"lat": "24.8918",
"lng": "21.8984"
},
"phone": "210.067.6132",
"website": "elvis.io",
"company": {
"name": "Johns Group",
"catchPhrase": "Configurable multimedia task-force",
"bs": "generate enterprise e-tailers"
}
},
{
"id": 8,
"name": "Nicholas Runolfsdottir V",
"username": "Maxime_Nienow",
"email": "Sherwood@rosamond.me",
"address": {
"street": "Ellsworth Summit",
"suite": "Suite 729",
"city": "Aliyaview",
"zipcode": "45169",
"geo": {
"lat": "-14.3990",
"lng": "-120.7677"
}
}
"phone": "586.493.6943 x140",
"website": "jacynthe.com",
"company": {
"name": "Abernathy Group",
"catchPhrase": "Implemented secondary concept",
"bs": "e-enable extensible e-tailers"
}
},
{
"id": 9,
"name": "Glenna Reichert",
"username": "Delphine",
"email": "Chaim_McDermott@dana.io",
"address": {
"street": "Dayna Park",
"suite": "Suite 449",
"city": "Bartholomebury",
"zipcode": "76495-3109",
"geo": {
"lat": "24.6463"
"lng": "-168.8889"
}
},
"phone": "(775)976-6794 x41206",
"website": "conrad.com",
"company": {
"name": "Yost and Sons",
"catchPhrase": "Switchable contextually-based project",
"bs": "aggregate real-time technologies"
}
},
{
"id": 10,
"name": "Clementina DuBuque",
"username": "Moriah.Stanton",
"email": "Rey.Padberg@karina.biz",
"address": {
"street" "Kattie Turnpike",
"suite": "Suite 198",
"city": "Lebsackbury",
"zipcode": "31428-2261",
"geo": {
"lat": "-38.2386",
"lng": "57.2232"
}
},
"phone": "024-648-3804",
"website": "ambrose.net",
"company": {
"name": "Hoeger LLC",
"catchPhrase": "Centralized empowering task-force",
bs": "target end-to-end models"
}
}
]`;
let parsedUsers = JSON.parse(users)
console.log(parsedUsers);
//Objective 2:
let product;[{'Home Desktop Table'}];
//Stringify an object with the following properties and save it in the given stringifiedProduct variable:
let stringifiedProduct;
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
parsedUsers: typeof parsedUsers !== 'undefined' ? parsedUsers : null,
product: typeof product !== 'undefined' ? product : null,
stringifiedProduct: typeof stringifiedProduct !== 'undefined' ? stringifiedProduct : null
}
} catch(err){
}

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Introduction to JSON</title>
</head>
<body>
<script type="text/javascript"src='index.js'></script>
</body>
</html>

@ -0,0 +1,32 @@
console.log('hello world');
// JSON Objects
// {
// "city": "Quezon City",
// "province": "Metro Manila",
// "country": "Philippines"
// }
// "cities":[
// {"city":"Quezon City","province":"Metro Manila","contry":"Philippines"},
// {"city":"Quezon City","province":"Metro Manila","contry":"Philippines"},
// {"city":"Quezon City","province":"Metro Manila","contry":"Philippines"}]
let batchesArr = [{ batchKate: "Batch X" }, { batchName: "Batch Y" }];
console.log("Result from stringify method:");
console.log(JSON.stringify(batchesArr));
// Another Example
let data = JSON.stringify({
name: 'John',
age: 31,
address: {
city: 'Manila',
country: 'Philippines'
}
});
console.log(data);

Binary file not shown.

@ -0,0 +1,22 @@
// orders
{
"_id":"or101",
"name": "Backpack",
"description":"Light Weight and Water Proof",
"price": 1000,
"stocks":"200",
"isActive":true,
"sku":"true"
}
// orders Product
{
"_id":"or102",
"orderId":"101",
"productId":"001",
"quantity":"1",
"price":1000,
"subTotal":1000
}

@ -0,0 +1,10 @@
{
"_id":"or101",
"name": "Backpack",
"description":"Light Weight and Water Proof",
"price": 1000,
"stocks":"200",
"isActive":true,
"sku":"p100"
}

Binary file not shown.

@ -0,0 +1,35 @@
{
"_id":"601ccbe89bcd482ee8fa2c99",
"name":"HTML",
"description":"Learn the basics on how to code",
"price":1000,
"isActive":true,
"slots":20,
"enrolles":[
"601ccbe89bcd482ee8fa2c99"
"507f191e810c19729de860ea"],
"datetimeCreated":"2020-03-15T15:00:00.00Z"
}
{
"_id":"601ccbe89bcd482ee8fa2c99",
"name":"CSS",
"description":"Let's make out application look cool!",
"price":2000,
"isActive":false,
"slots":20,
"enrolles":[
"507f191e810c19729de860ea"],
"datetimeCreated":"2020-03-15T15:00:00.00Z"
}
{
"_id":"507f191e810c19729de860ea",
"name":"JavaScript",
"description":"Let's make out application look cool!",
"price":4000,
"isActive":false,
"slots":15,
"enrolles":[],
"datetimeCreated":"2020-03-15T15:00:00.00Z"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

@ -0,0 +1,16 @@
{
"_id":"601ccbe89bcd482ee8fa2c99",
"userId":"507f191e810c19729de860ea",
"courseId":"603e10d3b30fd23b081a94eb",
"ispaid":true,
"paymentMethod":"Paypal",
"datetimeCreated":"2020-03-15T15:00:00.00Z"
}
{
"_id":"601ccbe89bcd482ee8fa2c99",
"userId":"507f191e810c19729de860ea",
"courseId":"603e10d3b30fd23b081a94eb",
"ispaid":true,
"paymentMethod":"Gcash",
"datetimeCreated":"2020-03-15T15:00:00.00Z"
}

@ -0,0 +1,30 @@
{
"_id": "507f1f77bcf86cd799439011",
"firstName": "John",
"lastName": "Smith",
"email": "johnsmith@email.com",
"password":"johnsmithhandsome",
"isAdmin":false,
"mobileNumber":"09123456789",
"enrollments":[
"601ccbe89bcd482ee8fa2c99"
"507f191e810c19729de860ea",
],
"datetimeRegistered":"2020-03-15T15:00:00.00Z"
}
{
"_id": "507f1f77bcf86cd799439011",
"firstName": "Jane",
"lastName": "Doe",
"email": "janedoe@email.com",
"password":"janedoe12",
"isAdmin":true,
"mobileNumber":"09123456789",
"enrollments":[],
"datetimeRegistered":"2020-03-15T15:00:00.00Z"
}

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>JavaScript</title>
</head>
<body>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>

@ -0,0 +1,127 @@
// S34 - MongoDB CRUD Operations Activity Template:
/*
Sample solution:
async function addOneQuery(db) {
await (
//add query here
db.collectionName.insertOne({
field1: "value1",
field2: "value2"
}) //DO NOT ADD SEMICOLON.
);
return(db);
}
Note:
- Do note change the functionName or modify the exports
- Do not add semicolon after query
*/
// 1. Insert a single room (insertOne method) in the rooms collection:
async function addOneFunc(db) {
await (
db.hotel.insertMany({
name:"single",
accomodates:2,
price:1000,
description:"A simple room with all the basic neccessities",
rooms_availbale:10,
isAvaile:false
})
);
return(db);
};
// 2. Insert multiple rooms (insertMany method) in the rooms collection
// member2
async function addManyFunc(db) {
await (
db.hotel.insertMany({
name:"double",
accomodates:3,
price:2000,
description:"Aroom fit for small family going on vacation",
rooms_availbale:5,
isAvaile:false
})
);
return(db);
};
// 3. Use the findOne method to search for a room with the name double.
async function findRoom(db) {
return await (
db.hotel.findOne({name:"double"})
);
};
// 4. Use the updateOne method to update the queen room and set the available rooms to 0.
function updateOneFunc(db) {
db.hotel.updateOne({name:"queen"}){
rooms_availbale:0
}
};
// 4.5
function updateOneFunc(db) {
await(
db.hotel.insertMany({
$set:{
name:"queen",
accomodates:4,
price:4000,
description:"A room with queen sixed bed for a simple gateaway",
rooms_availbale:15,
isAvaile:false
}
});
);
return(db);
};
// 5. Use the deleteMany method to delete all rooms that have 0 rooms available.
function deleteManyFunc(db) {
db.hotel.deleteMany({rooms_availbale:0})
};
try{
module.exports = {
addOneFunc,
addManyFunc,
updateOneFunc,
deleteManyFunc,
findRoom
};
} catch(err){
};

@ -0,0 +1,256 @@
// CRUD Operations
/*
- CRUD Operations are the heart of any backend application.
- Mastering the CRUD operations is essential for any developer
- CRUD stands for CREATE, READ, UPDATE, and DELETE
*/
// [SECTION] Inserting documents (Create)
// Insert One Document
/*
Syntax:
db.collectionName.insertOne({object});
*/
db.users.insertOne({
firstName: "Jane",
lastName: "Doe",
age: 21,
contact: {
phone: "87654321",
email: "janedoe@gmail.com"
},
course: ["CSS", "JavaScript", "Python"],
department: "none"
});
// Insert Many
/*
Syntax:
db.collectionName.insertMany([{Object A}, {Object B}]);
*/
db.users.insertMany([
{
firstName: "Stephen",
lastName: "Hawking",
age: 79,
contact: {
phone: "87654321",
email: "stephenhawking@gmail.com"
},
course: ["Python", "React", "PHP"],
department: "none"
},
{
firstName: "Neil",
lastName: "Armstrong",
age: 82,
contact: {
phone: "87654321",
email: "neilarmstrong@gmail.com"
},
course: ["React", "Laravel", "Sass"],
department: "none"
}
]);
// [SECTION] Finding Documents (Read)
// Find Single Document
/*
Syntax:
db.collectionName.findOne();
db.collectionName.findOne({ field: value });
*/
// Leaving the search criteria empty will retrieve ALL the documents
db.users.find();
// This will retrieve the first document
db.users.findOne();
// criteria
db.users.findOne({ firstName: "Stephen" });
// Finding Multiple Documents
/*
Syntax:
db.collectionName.find({ fieldA: valueA });
*/
db.users.find({ department: "none" });
// Finding multiple documents with multiple parameters (criteria)
db.users.find({ department: "none", age: 82 });
// [SECTION] Updating Documents (Update)
// Updating a single document
// Creating document to update
db.users.insertOne({
firstName: "Test",
lastName: "Test",
age: 0,
contact: {
phone: "000000",
email: "test@gmail.com"
},
courses: [],
department: "none"
});
/*
- Just like the "find" methos, methods that only manipulate a sigle document will only manipulate a single document will only update the FIST document that matches the search criteria
- Syntax:
db.collectionName.updateOne({criteria}, {$set: {field: value}});
*/
db.users.updateOne({ firstName: "Test" }, {
$set: {
firstName: "Bill",
lastName: "Gates",
age: 65,
contact: {
phone: "12345678",
email: "bill@gmail.com"
},
courses: ["PHP", "Laravel", "HTML"],
department: "Operations",
status: "active"
}
});
db.users.find({ firstName: "Bill" });
// Another Example using _id
db.users.updateOne({ _id: ObjectId("6514da527c5d7043df600f54") }, {
$set: {
firstName: "Elon",
lastName: "Musk",
age: 65,
contact: {
phone: "12345678",
email: "elon@gmail.com"
},
courses: ["PHP", "Laravel", "HTML"],
department: "Operations",
status: "active"
}
});
db.users.updateOne({ _id: ObjectId("6514da527c5d7043df600f54") }, {
$set: {
firstName: "Bill",
lastName: "Gates"
}
});
// Updating multiple documents
/*
Syntax:
db.collectionName.updateMany({ criteria }, {$set: { field: value }});
*/
db.users.updateMany({department: "none"}, {
$set: {
department: "HR"
}
});
db.users.find();
// Replace One
/*
- Can be used if replacing the whole document is necessary.
- Syntax:
db.collectionName.replaceOne( { criteria }, { field: value } );
*/
db.users.replaceOne({firstName: "Bill"}, {
firstName: "Bill",
lastName: "Gates",
age: 70,
contact: {
phone: "123123123",
email: "billgates@gmail.com"
},
courses: ["PHP", "Laravel", "CSS"],
department: "Operations"
});
// [SECTION] Deleting Documents (Delete)
// Create a document to delete
db.users.insert({
firstName: "test"
});
// Deleting a single Document
/*
Syntax:
db.collectionName.deleteOne({criteria});
*/
db.users.deleteOne({
firstName: "test"
});
db.users.find();
// Delete Many
/*
DO NOT USE: db.collectionName.deleteMany();
Syntax:
db.collectionName.deleteMany({criteria});
*/
db.users.deleteMany({
firstName: "Bill"
});
db.users.find();
// TAKE HOME QUIZ
// [SECTION] Advanced Queries
// 1. Query an embedded document
/*
- find all the document with the following contact:
phone: "87654321",
email: "stephenhawking@gmail.com"
*/
// 2. Query on nested Field
/*
- find the document that has an email of "janedoe@gmail.com"
*/
// 3. Query an Array with Exact Elements
/*
- find a document with the has the courses
- CSS
- JavaScript
- Python
*/
// 4. Querying an array without regard to order
/*
- find all the documents with the following courses
- React
- Python
*/

@ -0,0 +1,62 @@
// S35 - MongoDB Query Operators and Field Projection:
/*
Sample solution:
return async function findName(db) {
await (db.collectionName.find({
$and: [
{field1: "value1"},
{field2: "value2"}
]
}));
}
Note:
- Do note change the functionName or modify the exports
- Delete all the comments before pushing.
*/
// 1. Find users with letter s in their first name or d in their last name.
async function findName(db) {
return await(
db.users.find({firstName:,{$regex: "s", $options:"i"}});
);
};
// 2. Find users who are from the HR department and their age is greater than or equal to 70.
async function findDeptAge(db) {
return await (
// Add query here
);
};
// 3. Find users with the letter e in their last name and has an age of less than or equal to 30.
async function findNameAge(db) {
return await (
db.users.find({lastName:{$regex: "e", $options:"i"}},{$lte:30});
);
};
try{
module.exports = {
findName,
findDeptAge,
findNameAge
};
} catch(err){
};

@ -0,0 +1,87 @@
// S36 - Aggregation in MongoDB and Query Case Studies:
/*
Sample solution:
return async function addOneQuery(db) {
await (db.collectionName.aggregate([
{ $match: { fieldA, valueA } },
{ $group: { _id: "$fieldB" }, { result: { operation } } }
]));
}
Note:
- Do note change the functionName or modify the exports
- Delete all the comments before pushing.
*/
// 1. Use the count operator to count the total number of fruits on sale
async function fruitsOnSale(db) {
return await(
// Add query here
);
};
// 2. Use the count operator to count the total number of fruits with stock more than 20
async function fruitsInStock(db) {
return await(
db.fruits.aggregation([
{$count: "stock" , {$gt: 20}
}]);
// 3. Use the average operator to get the average price of fruits onSale per supplier
async function fruitsAvePrice(db) {
return await(
db.fruits.aggregation([
{$match: {$onsale:true},
{$group: {$supplier_id, averagePrice: {$avg :"$price"}}}
}
}]);
// 4. Use the max operator to get the highest price of a fruit per supplier
async function fruitsHighPrice(db) {
return await(
// Add query here
);
};
// 5. Use the min operator to get the lowest price of a fruit per supplier
async function fruitsLowPrice(db) {
return await(
// Add query here
);
}
try{
module.exports = {
fruitsOnSale,
fruitsInStock,
fruitsAvePrice,
fruitsHighPrice,
fruitsLowPrice
};
} catch(err){
};

Binary file not shown.

@ -0,0 +1,21 @@
const http = require('http');
const directory = [{
"name":"Dustin",
"email":"dustin@gmail.com"
},
{
"name":"Dustin",
"email":"dustin@gmail.com"
}];
http.createServer(function(request,response){
if(request.url == "/users" && request.method == "GET"){
}
}).listen(4000);
console.log("Server running at localhost:4000")

@ -0,0 +1,26 @@
//Add solution here
let http = require("http");
const port = 3000;
const app = http.createServer( (request, response) => {
if(request.url =="/login"){
response.writeHead(200, {'Content-type': 'text/plain'});
response.end('Welcome to the login page.');
}
else {
response.writeHead(404, {'content-type': 'text/plain'});
response.end("404: I'm Sorry the page you are looking for cannot be found.");
}
});
app.listen(port);
console.log(`Server is currently running on localhost:${port}`);
//Do not modify
module.exports = {app}

Binary file not shown.

@ -0,0 +1,48 @@
// dependencies and modules
const mongoose = require('mongoose');
const courseSchwema = new mongoose.Schema({
name:{
type:String,
required: [true,"Course is required"]
},
description: {
type:String,
required:[true, "Description is required"]
},
price:{
type:number
required:[true, "Price is required"]
},
isActive:{
type: Boolean,
default: true
},
createdOn:{
type:Date,
default: new Date()
},
enrollees:[{
userID:{
type:String
required:[true, "User Id is required"]
},
enrolledOn:{
type: Date,
default: new Date
}
}
]
});
// Model Exports
module.exports = mongoose.model('Course', courseSchema);

@ -0,0 +1,66 @@
//Add code here
const http = require('http');
const port =4000;
const app = http.createServer(function(request, response){
if(request.url == "/" && request.method == 'GET'){
response.writeHead(200,{'Content-Type': 'text/plain'});
response.end('Welcome to Booking Systems')};
if(request.url == "/profile" && request.method == 'GET'){
response.writeHead(200,{'Content-Type': 'text/plain'});
response.end('Welcome to your profile')};
if (request.url == '/courses' && request.method == 'GET'){
response.writeHead(200,{'Content-Type': 'text/plain'});
response.end('Heres our courses available')};
if (request.url == '/addCourse' && request.method == 'POST'){
response.writeHead(200,{'Content-Type': 'text/plain'});
response.end('Add a course to our resources')};
if (request.url == '/updateCourse' && request.method == 'PUT'){
response.writeHead(200,{'Content-Type': 'text/plain'});
response.end('Update a course to our resources')};
if (request.url == '/archieveCourse' && request.method == 'DELETE'){
response.writeHead(200,{'Content-Type': 'text/plain'});
response.end('Archive courses to our resources')};
});
// if (request.url == '/updateCourses' && request.method == 'PUT'){
// response.writeHead(200,{'Content-Type': 'text/plain'});
// response.end('Update a course to our resources')};
//Do not modify
//Make sure to save the server in variable called app
if(require.main === module){
app.listen(4000, () => console.log(`Server running at port 4000`));
}
module.exports = app;

Binary file not shown.

@ -0,0 +1,85 @@
const http = require('http');
const directory = [{
"name": "Brandon",
"email": "brandon@mail.com"
},
{
"name": "Jobert",
"email": "jobert@mail.com"
}
]
const port = 4000;
const http = require('http');
// Mock Database
let directory = [
{
"name": "Brandon",
"email": "brandon@mail.com"
},
{
"name": "Jobert",
"email": "jobert@mail.com"
}
]
let port = 4000;
let app = http.createServer(function(request, response){
// Route for returning all items upon receiving a GET request
if(request.url == "/users" && request.method == "GET"){
// Sets the status code to 200 and sets response output to JSON data type
response.writeHead(200, {'Content-Type': 'application/json'});
// using write() method of the response object to send a response to the client in a JSON format
// JSON.stringify() method converts the JavaScript array of objects into JSON string.
response.write(JSON.stringify(directory));
// Ends our response process
response.end();
}
// Route for creating a new item upon receiving a post request
/*
A request object contains several parts:
- Headers - contains information about the request context/content
- Body - contains the actual information being sent with the request
*/
if(request.url == "/users" && request.method == "POST"){
let requestBody = '';
// Data is received from the client and is processed in the "data" stream
request.on('data', function(data){
requestBody += data;
});
// request end step - only runs after the request has completely been started
request.on('end', function(){
console.log(typeof requestBody);
requestBody = JSON.parse(requestBody);
let newUser = {
"name": requestBody.name,
"email": requestBody.email
}
directory.push(newUser);
console.log(directory);
response.writeHead(200, {'Content-Type': 'application/json'});
response.write(JSON.stringify(newUser));
response.end();
});
}
});
app.listen(port, () => console.log(`Server running at localhost:${4000}`));

@ -0,0 +1,20 @@
// Node.js Routing with HTTP Method
const http = require('http');
const port = 4000
const app =http.createServer((request,response) =>{
if(request.url == '/items' && request.method == 'GET'){
response.writeHead(200,{'Content-Type':'text/plain'});
response.end('Data retrieve from the datebase');
}
if(request.url == '/items' && request.method == 'POST'){
response.writeHead(200,{'Content-Type':'text/plain'});
response.end('Data to be sent to the datebase');
}
});
// or const http =require.createServer(function(request,response){
// });
app.listen (port,() => console.log(`Server running at localhost:${port}`));

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Activity s39</title>
</head>
<body>
<script src="./index.js"></script>
</body>
</html>

@ -0,0 +1,122 @@
//Note: don't add a semicolon at the end of then().
//Fetch answers must be inside the await () for each function.
//Each function will be used to check the fetch answers.
//Don't console log the result/json, return it.
// Get Single To Do [Sample]
/* async function getSingleToDo() {
return await (
);
} */
// Getting all to do list item
async function getAllToDo() {
return await (
fetch('https://jsonplaceholder.typicode.com/todos')
.then(response => response.json())
.then(data => {
data.map((elem) => {
return elem.title
})
})
);
}
// [Section] Getting a specific to do list item
async function getSpecificToDo() {
return await (
//Add fetch here.
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then((response) => response.json())
.then((json) => json)
);
}
// [Section] Creating a to do list item using POST method
async function createToDo() {
return await (
fetch("https://jsonplaceholder.typicode.com/todos", {
method: "POST",
headers: {
'Content-Type': 'Application/json'
},
body: JSON.stringify({
"userId": 1,
"title": "Actio non",
"completed": false
})
})
.then(response => response.json())
.then((json) => json)
);
}
// [Section] Updating a to do list item using PUT method
async function updateToDo() {
return await (
//Add fetch here.
fetch('https://jsonplaceholder.typicode.com/todos/1', {
method: "PUT",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
id: 1,
title: 'Updated To Do List Item',
description: 'To update my to do list with a different data structure',
status: 'Pending',
dateCompleted: 'Pending',
userId: 1
})
})
.then(response => response.json())
.then(json => console.log(json))
);
};
// [Section] Deleting a to do list item
async function deleteToDo() {
return await (
fetch("https://jsonplaceholder.typicode.com/todos/1", {
method: "DELETE"
})
);
}
//Do not modify
//For exporting to test.js
try {
module.exports = {
getSingleToDo: typeof getSingleToDo !== 'undefined' ? getSingleToDo : null,
getAllToDo: typeof getAllToDo !== 'undefined' ? getAllToDo : null,
getSpecificToDo: typeof getSpecificToDo !== 'undefined' ? getSpecificToDo : null,
createToDo: typeof createToDo !== 'undefined' ? createToDo : null,
updateToDo: typeof updateToDo !== 'undefined' ? updateToDo : null,
deleteToDo: typeof deleteToDo !== 'undefined' ? deleteToDo : null,
}
} catch (err) {
}

@ -0,0 +1,100 @@
{
"info": {
"_postman_id": "649466f2-0332-4044-b49c-d327542d1436",
"name": "s39 Activity",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "30178270"
},
"item": [
{
"name": "getAllToDo",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://jsonplaceholder.typicode.com/todos",
"protocol": "https",
"host": [
"jsonplaceholder",
"typicode",
"com"
],
"path": [
"todos"
]
}
},
"response": []
},
{
"name": "getSpecificToDo",
"request": {
"method": "GET",
"header": []
},
"response": []
},
{
"name": "createToDo",
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "https://jsonplaceholder.typicode.com/todos",
"protocol": "https",
"host": [
"jsonplaceholder",
"typicode",
"com"
],
"path": [
"todos"
]
}
},
"response": []
},
{
"name": "updateToDo",
"request": {
"method": "PUT",
"header": [],
"url": {
"raw": "https://jsonplaceholder.typicode.com/todos/1",
"protocol": "https",
"host": [
"jsonplaceholder",
"typicode",
"com"
],
"path": [
"todos",
"1"
]
}
},
"response": []
},
{
"name": "deleteToDo",
"request": {
"method": "DELETE",
"header": [],
"url": {
"raw": "https://jsonplaceholder.typicode.com/todos/1",
"protocol": "https",
"host": [
"jsonplaceholder",
"typicode",
"com"
],
"path": [
"todos",
"1"
]
}
},
"response": []
}
]
}

@ -0,0 +1 @@
node_modules

@ -0,0 +1,146 @@
/*
Introduction to Express.js
*/
// import express module
const express = require('express');
// Create an application using express
const app = express();
// Port
const port = 4000;
// Middlewares
/*
- Middleware is a software that provides common services and capabilities to application outside of what is offered by the system/
- API management is one of the common application of middlewares
*/
// Allows our app to read JSON data
app.use(express.json());
// Allows our app to read data from forms and extend the data types that our app will support
app.use(express.urlencoded({extended: true}));
// [Section] Routes
/*
- Express has methods corresponding to each HTTP method
- This route expects to receive a GET request at the base URI "/"
*/
app.get("/", (req, res) => {
// Once the route is accessed, it will send a string response containing "Hello world"
// we use the res.send() method to send a response back to the client
res.send("Hello world");
});
// route for accessing the "/hello" with a GET method
app.get("/hello", (req, res) => {
res.send("Hello from the /hello endpoint!");
});
// This route expects to receive a POST request at the URI "/hello"
app.post("/hello", (req, res) => {
// req.body contains the contents/data of the request body
// All properties defined in our Postman request will be accessible here as properties with the same name
res.send(`Hello there ${req.body.firstName} ${req.body.lastName}`);
});
// This will serve as our mock database
let users = [];
// This route expects to receive a POST request at the URI "/signup"
app.post("/signup", (req, res) => {
console.log(req.body);
// if the contents of the request body with the property "username" and "password" is not empty (empty string)
if(req.body.username !== '' && req.body.password !== ''){
// This will store the user object sent via Postman to the users array created above
users.push(req.body);
console.log(users);
// This will send a response back to the cliet/Postman
res.send(`User ${req.body.username} successfully registered`);
// If the username and password are not complete, an error message will be sent back to the client/Postman
} else {
res.send("Please input BOTH username and password");
}
});
// This route expects to receive a PUT request at the URI "/change-password"
// This will update the password of the user
app.put("/change-password", (req, res) => {
let message;
// Creates a for loop that will loop through the elements of the "users" array
for(let i = 0; i < users.length; i++){
// If the username provided by the client/Post and the username of the current user is the same
if(req.body.username == users[i].username){
// Change the password by reassignment
users[i].password = req.body.password
// reassign the value of the message to be sent back to the client/Postman
message = `User ${req.body.username}'s password has been updated.`;
console.log(users);
// stop the loop
break
// If no user was found
} else {
message = "User does not exist.";
}
}
res.send(message);
});
app.get('/home', (req,res) => {
res.send('Welcome to the homepage');
});
app.get('/users',(req,res) => {
res.send([{username:'john',password:'1234' }]);
});
app.delete("/delete-user", (req, res) => {
let message;
// Creates a for loop that will loop through the elements of the "users" array
for(let i = 0; i < users.length; i++){
// If the username provided by the client/Post and the username of the current user is the same
if(req.body.username == users[i].username){
usernames.splice(users[i].username, 1);
message = `User ${req.body.username} has been deleted.`;
console.log(users);
// stop the loop
break
}
res.send(message);
};
// An if statement is added here to be able to export the following app/server for checking
if(require.main === module){
app.listen(port, () => console.log(`Server running at port ${port}`));
}
module.exports = app;

@ -0,0 +1,604 @@
{
"name": "s-39",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "s-39",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/body-parser": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
"dependencies": {
"bytes": "3.1.2",
"content-type": "~1.0.4",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"on-finished": "2.4.1",
"qs": "6.11.0",
"raw-body": "2.5.1",
"type-is": "~1.6.18",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"dependencies": {
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
"integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.18.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "1.20.1",
"content-disposition": "0.5.4",
"content-type": "~1.0.4",
"cookie": "0.5.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "1.2.0",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.7",
"qs": "6.11.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "0.18.0",
"serve-static": "1.15.0",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/finalhandler": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
"integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"statuses": "2.0.1",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"node_modules/get-intrinsic": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
"integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
"dependencies": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-proto": "^1.0.1",
"has-symbols": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dependencies": {
"function-bind": "^1.1.1"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/has-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
"dependencies": {
"depd": "2.0.0",
"inherits": "2.0.4",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"toidentifier": "1.0.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
"integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.12.3",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
"dependencies": {
"side-channel": "^1.0.4"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/send": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
"integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "2.4.1",
"range-parser": "~1.2.1",
"statuses": "2.0.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/serve-static": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
"integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
"dependencies": {
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.18.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
"dependencies": {
"call-bind": "^1.0.0",
"get-intrinsic": "^1.0.2",
"object-inspect": "^1.9.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"engines": {
"node": ">= 0.8"
}
}
}
}

@ -0,0 +1,14 @@
{
"name": "s-39",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
}

@ -0,0 +1,43 @@
// Getting all the tasks
/*
Business Logic:
1. Retrieve all the documents.
2. if an error is encountered, print the error.
3. If no errors are found, send a success status back to the client/Postman and return an array of documents.
*/
app.get("/tasks", (req, res) => {
// "find" is a Mongoose method used to retrieve documents in the database, and with {}, we are going to retrieve all the documents
Task.find({}).then((result, err) => {
// If an error occurred
if(err){
// Will print any errors found in the console
retun console.error(err);
// If no errors are found
} else {
let newUser = new User({
username: "johndoe",
password: "1234"
});
newUser.save().then((savedUser, saveErr) => {
if(saveErr){
return console.error(saveErr);
} else{
return res.status(201).send('New user registered');
else{
return res.status(201).send('BOTH username and password must be provided');
// The returned response is added in an object with the "data" property.
// status "200" means that everything is "OK"
// The "json" method allows us to send a JSON format for the response
return res.status(200).json({
data: result
});
}
});
});

@ -0,0 +1,200 @@
/*
s41 - Express.js - Data Persistence via Mongoose ODM
*/
const express = require('express');
const mongoose = require('mongoose');
const app = express();
const port = 3001;
// [Section] MongoDB Connection
/*
Syntax:
mongoose.connect("<MongoDB URI>", {
useNewUrlParser: true,
useUnifiedTopology: true
});
*/
// Connecting to MongoDB Atlas
mongoose.connect("mongodb+srv://jerrycabuntucan:EvDaqSDV8DIXZTQr@b320-cluster.ke6t1wi.mongodb.net/b320-todo?retryWrites=true&w=majority", {
useNewUrlParser: true,
useUnifiedTopology: true
});
// Set Notifications for connection success or failure
let db = mongoose.connection;
// If a connection error occurred, output in the console
// console.error.bind(console) allows us to print error in the browser console and in the terminal
db.on("error", console.error.bind(console, "connection error"));
// If the connection is successful, output in the console
db.once("open", () => console.log("We're connected to the cloud database!"));
// [Section] Mongoose Schema
/*
- Schemas determine the structure of the documents to be written in the database
- It will act as a blueprint to our data(documents)
*/
// The "new" keyword creates a new Schema
const taskSchema = new mongoose.Schema({
// Define the fields with the corresponding data type
// The field called "name" and its data type is "String"
name: String,
// This is the "status" field that is a "String" and the default value is "pending"
status: {
type: String,
default: "pending"
}
});
//User Schema
const userSchema = new mongoose.Schema({
username: String,
password: String
});
// [Section] Models
/*
- It uses schemas and are used to create/instantiate objects that correspond to the schema
- Models use Schemas and they act as a middleman between the server(JS code) to our database(MongoDB)
- Server > Schema (blueprint) > Database > Collection
*/
const Task = mongoose.model("Task", taskSchema);
//User Model
const User = mongoose.model("User", userSchema);
// Middlewares
app.use(express.json());
app.use(express.urlencoded({extended: true}));
// [Section] Routes
// Creating a new task
/*
Business Logic:
1. Add a functionality to check if there are duplicated tasks
- If the task already exists in the DB, we return an error
- If the task doesn't exist in the DB, we add it in the DB
2. The task data will be coming from the request's body
3. Create a new Task object with a "name" field/property
4. The "status" property does not need to be provided because our schema defaults it to "pending" upon creation of an object
*/
app.post("/tasks", (req, res) => {
// It will search the req.body.name in the db to check if it exist already in the db
Task.findOne({name: req.body.name}).then((result, err) => {
// If a docuent was found and the document's name matches the information sent via the client/postman
if(result != null && result.name == req.body.name){
// Return a message to the client/Postman
return res.send("Duplicate task found");
// If no document as found
} else {
// Create a new task and save it to the database
let newTask = new Task({
name: req.body.name
});
// The .save method is used to save the new object to the database
newTask.save().then((savedTask, saveErr) => {
// If there are errors in save, console.error the error
if(saveErr){
return console.error(saveErr);
// No error found while creating the document, return a response
} else {
// Return a status code of 201, which means created successfully
// Sends a message "New task created" on successfull creation
return res.status(201).send("New task created");
}
});
}
})
});
// Getting all the tasks
/*
Business Logic:
1. Retrieve all the documents.
2. if an error is encountered, print the error.
3. If no errors are found, send a success status back to the client/Postman and return an array of documents.
*/
app.get("/tasks", (req, res) => {
// "find" is a Mongoose method used to retrieve documents in the database, and with {}, we are going to retrieve all the documents
Task.find({}).then((result, err) => {
// If an error occurred
if(err){
// Will print any errors found in the console
return console.error(err);
// If no errors are found
} else {
// The returned response is added in an object with the "data" property.
// status "200" means that everything is "OK"
// The "json" method allows us to send a JSON format for the response
return res.status(200).json({
data: result
});
}
});
});
app.post("/signup", (req, res) => {
console.log(req.body);
User.findOne({username: req.body.username}).then((result,err) => {
if(result != null && result.username == req.body.username){
return res.send("Duplicate username found");
}
else {
if(req.body.username !== "" && req.body.password !== ""){
let newUser = new User({
username: req.body.username,
password: req.body.password
});
newUser.save().then((savedUser, savedErr) => {
if(savedErr){
return console.error(savedErr);
}
else{
return res.status(201).send("New User Registered");
}
})
}
else {
return res.send("BOTH username and password must be provided");
}
}
})
});
if(require.main === module){
app.listen(port, () => console.log(`Server running at port ${port}`));
}
module.exports = app;

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

@ -0,0 +1,841 @@
{
"name": "s-41",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/@mongodb-js/saslprep": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.0.tgz",
"integrity": "sha512-Xfijy7HvfzzqiOAhAepF4SGN5e9leLkMvg/OPOF97XemjfVCYN/oWa75wnkc6mltMSTwY+XlbhWgUOJmkFspSw==",
"optional": true,
"dependencies": {
"sparse-bitfield": "^3.0.3"
}
},
"node_modules/@types/node": {
"version": "20.8.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.2.tgz",
"integrity": "sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w=="
},
"node_modules/@types/webidl-conversions": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.1.tgz",
"integrity": "sha512-8hKOnOan+Uu+NgMaCouhg3cT9x5fFZ92Jwf+uDLXLu/MFRbXxlWwGeQY7KVHkeSft6RvY+tdxklUBuyY9eIEKg=="
},
"node_modules/@types/whatwg-url": {
"version": "8.2.2",
"resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.2.tgz",
"integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==",
"dependencies": {
"@types/node": "*",
"@types/webidl-conversions": "*"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/body-parser": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
"dependencies": {
"bytes": "3.1.2",
"content-type": "~1.0.4",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"on-finished": "2.4.1",
"qs": "6.11.0",
"raw-body": "2.5.1",
"type-is": "~1.6.18",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bson": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/bson/-/bson-5.5.0.tgz",
"integrity": "sha512-B+QB4YmDx9RStKv8LLSl/aVIEV3nYJc3cJNNTK2Cd1TL+7P+cNpw9mAPeCgc5K+j01Dv6sxUzcITXDx7ZU3F0w==",
"engines": {
"node": ">=14.20.1"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"dependencies": {
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
"integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.18.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "1.20.1",
"content-disposition": "0.5.4",
"content-type": "~1.0.4",
"cookie": "0.5.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "1.2.0",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.7",
"qs": "6.11.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "0.18.0",
"serve-static": "1.15.0",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/finalhandler": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
"integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"statuses": "2.0.1",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"node_modules/get-intrinsic": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
"integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
"dependencies": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-proto": "^1.0.1",
"has-symbols": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dependencies": {
"function-bind": "^1.1.1"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/has-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
"dependencies": {
"depd": "2.0.0",
"inherits": "2.0.4",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"toidentifier": "1.0.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/ip": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
"integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ=="
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/kareem": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz",
"integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==",
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/memory-pager": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
"optional": true
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
"integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mongodb": {
"version": "5.8.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.8.1.tgz",
"integrity": "sha512-wKyh4kZvm6NrCPH8AxyzXm3JBoEf4Xulo0aUWh3hCgwgYJxyQ1KLST86ZZaSWdj6/kxYUA3+YZuyADCE61CMSg==",
"dependencies": {
"bson": "^5.4.0",
"mongodb-connection-string-url": "^2.6.0",
"socks": "^2.7.1"
},
"engines": {
"node": ">=14.20.1"
},
"optionalDependencies": {
"@mongodb-js/saslprep": "^1.1.0"
},
"peerDependencies": {
"@aws-sdk/credential-providers": "^3.188.0",
"@mongodb-js/zstd": "^1.0.0",
"kerberos": "^1.0.0 || ^2.0.0",
"mongodb-client-encryption": ">=2.3.0 <3",
"snappy": "^7.2.2"
},
"peerDependenciesMeta": {
"@aws-sdk/credential-providers": {
"optional": true
},
"@mongodb-js/zstd": {
"optional": true
},
"kerberos": {
"optional": true
},
"mongodb-client-encryption": {
"optional": true
},
"snappy": {
"optional": true
}
}
},
"node_modules/mongodb-connection-string-url": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.6.0.tgz",
"integrity": "sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ==",
"dependencies": {
"@types/whatwg-url": "^8.2.1",
"whatwg-url": "^11.0.0"
}
},
"node_modules/mongoose": {
"version": "7.5.3",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.5.3.tgz",
"integrity": "sha512-QyYzhZusux0wIJs+4rYyHvel0kJm0CT887trNd1WAB3iQnDuJow0xEnjETvuS/cTjHQUVPihOpN7OHLlpJc52w==",
"dependencies": {
"bson": "^5.4.0",
"kareem": "2.5.1",
"mongodb": "5.8.1",
"mpath": "0.9.0",
"mquery": "5.0.0",
"ms": "2.1.3",
"sift": "16.0.1"
},
"engines": {
"node": ">=14.20.1"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/mongoose"
}
},
"node_modules/mongoose/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/mpath": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz",
"integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==",
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/mquery": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz",
"integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==",
"dependencies": {
"debug": "4.x"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/mquery/node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/mquery/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.12.3",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/punycode": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz",
"integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==",
"engines": {
"node": ">=6"
}
},
"node_modules/qs": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
"dependencies": {
"side-channel": "^1.0.4"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/send": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
"integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "2.4.1",
"range-parser": "~1.2.1",
"statuses": "2.0.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/serve-static": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
"integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
"dependencies": {
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.18.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
"dependencies": {
"call-bind": "^1.0.0",
"get-intrinsic": "^1.0.2",
"object-inspect": "^1.9.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/sift": {
"version": "16.0.1",
"resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz",
"integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ=="
},
"node_modules/smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==",
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
}
},
"node_modules/socks": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz",
"integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==",
"dependencies": {
"ip": "^2.0.0",
"smart-buffer": "^4.2.0"
},
"engines": {
"node": ">= 10.13.0",
"npm": ">= 3.0.0"
}
},
"node_modules/sparse-bitfield": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
"integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==",
"optional": true,
"dependencies": {
"memory-pager": "^1.0.2"
}
},
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"engines": {
"node": ">=0.6"
}
},
"node_modules/tr46": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz",
"integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==",
"dependencies": {
"punycode": "^2.1.1"
},
"engines": {
"node": ">=12"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/webidl-conversions": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
"engines": {
"node": ">=12"
}
},
"node_modules/whatwg-url": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz",
"integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==",
"dependencies": {
"tr46": "^3.0.0",
"webidl-conversions": "^7.0.0"
},
"engines": {
"node": ">=12"
}
}
}
}

@ -0,0 +1,22 @@
Copyright (c) 2014 Dmitry Tsvettsikh
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,4 @@
import mod from "./index.js";
export default mod;
export const saslprep = mod.saslprep;

@ -0,0 +1,4 @@
/// <reference types="node" />
declare const _default: Buffer;
export default _default;
//# sourceMappingURL=code-points-data.d.ts.map

@ -0,0 +1 @@
{"version":3,"file":"code-points-data.d.ts","sourceRoot":"","sources":["../src/code-points-data.ts"],"names":[],"mappings":";;AAEA,wBAKE"}

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const zlib_1 = require("zlib");
exports.default = (0, zlib_1.gunzipSync)(Buffer.from('H4sIAAAAAAACA+3dTYgcWR0A8FfTnekQ47aCkBxiZpYV8RhwYQM7bA/ksoLgSRD0IOSiePAkLrowvWSF4CkHEW856MlTQHA9RKZ1ZJODsEcVcTOyhxUEbXdXtpPp1PNVV39Uz4czEyaTVOb3G6a7XtWrr/devX49/+qekG2Go7Aa2jHGyozG+Dmrzi2mP/xb/zMhLI+WlRm2byubm2h0ivVi7BYzusVjuNkt1l9uFWsutWL8OP4rzV9KeXdsKx1HFhbSc6vIG0fKBZ14UNfLFS6FRrGRtXh98ZvphL/x4uLV/IOzaat/vlikv/TixavxR8PQitfPpKNbffXSwgtr8fV07GX+L1967urwg5W0/t0LV37y/oWFlQtX8ping7reXE3LT680r9yPKyn/3Vn64SwdVs6m/KN0yHrp9D+RvXsqpe6MSia5mH6LSog//Xq/++O74YVTjfDFWK2VIuNSemiPppphcVYeyzcudKqFMiq6cs3vVkrzlcnE0mxeZ1Jf2ZXsSvk8TmRZWYdpalydxd5bc8eUkt1wlEbtqTVLr8XQLFpKMb+dpr9SbSOt4ozTgXUq8+Ihm8cTt0shtCvT6dwao6sxPf5ydmU208/Z0yH8IZtlvZi3e5fG12yn3PLSdPvnQ7vsK9rxyKpqevzFZGVfu3YHezvbnbvit9Xdm5fGbf/MZ7PuuNrTjLJnaofH7gm0h+VKU/g/tdUocrer3cO4yOcuycGoyLrba6Ta+lrlnkZ5ntvWCrfV39wLTuNg9QvsvHb37P8BAGCP0eNTOH5szf154JmnNQIcn7b+FziyAfX4eWnn+C6Lm4M0mj31ubkViiDV4WLvs56qN54xGS3HWER5su6nQtZubl9tcY/4atbr9e5kWewew/g2a8fdy2Yaa97+pgQAAAAAAIBHtt+dYmWwaN/byI5g/9PYVfMvb4YvvDpOLJxvFgueP9VbPXh8/yCZViZxNYATaejmDQAAAACgfjJ/3QUA4JD3Px1InT+5PtQCAAAAAAAAAKD2xP8BAAAAAAAAoP7E/wEAAAAAAACg/sT/AQAAAAAAAKD+xP8BAAAAAAAAoP7E/wEAAAAAAACg/sT/AQAAAAAAAKD+xP8BAAAAAAAAoP7E/wEAAAAAAACg/sT/AQAAAAAAAKD+xP8BAAAAAAAAoP6G6+khVCgSAAAAAAAAAKidYQjLYVfNcPSyAE+dhQsnvAAq59/VHAAAAAAAAOCJmv8E/w4HiLqf3nWuWCB1pe0esg/pT3sKd+m4XjhpFpZH3/1THTcU6cfRLnrHf3ZNPZs+bf9rwPuIUPYAWb+j/Zy0EaAxAAAAAADwrPJ1IMBenu6ea99M+0W/17wCAAAAAAAAnGRLm8oA4JnQUAQAAAAAAAAAUHvi/wAAAAAAAABQf+L/AAAAAAAAAFB/4v8AAAAAAAAAUH/i/wAAAAAAAABQf+L/AAAAAAAAAFB/4v8AAAAAAAAAUH/i/wAAAAAAAABQf+L/AAAAAAAAAFB/4v8AAAAAAAAAUH/i/wAAAAAAAABQf+L/AAAAAAAAAFB/jdX0ECsUCQAAAAAAAADUTiMCAAAAAAAAAHU3VAQAAAAAAAAAUH8hLNf1uwsWbhT/uWBzUEx/ei1Nxc001VqrnN2wuRjCK3G4HuNgtuJoSVj17Q9QyBQBAAAAAAAAHMKpuJ4/+Otc5L2XZi8dJlQ/LCPXhc4keJ9UI9uFre3rDfY9uoXZPQBFHL34HSWWm8sx5rH83d967IfZMRZHHG/2Qi8MFnbscXnhnzHei5NND8P2bW2OT3G8vFeebBHbz9dGEf5jDt+fK4/mTve1bnwndsNL92+mE/75xhs/yz65Ed/ZbP29SP96oxvCDxrxcjj333R262/d6X6tG66lYy/z/+rtMn83nHvv9nfOv/dw4+pvspCl4v7+1npa/nHvtbSvjSJ/mf79/VuLC7N03LiW8o/SMU8ldO+jPOul1OVQ3vVwK+TZqBLCt3/RXvveS7eaD0L8YyhrJeV/cC0WGTdD1hzlCo2H98vzK9a+963V7qRVTeaNa+ZGpWp+N62jSmOetJD8dn67fB4n8nzchG7n4+os2tcgzLWUQVg70rta8lE7nqW7IW710v7eDsV1F7e6433njYfd9j9Gl2KIveptMePVamOXQuhXO5tUk6Pv+kiPX43T7/3YevDy4MN+HLw8CHPX6OqOOwKe73z0+pnf3rvT6pX76j/SUU7/3UjqX5r7ZW7PdZU8Vq2id+29Pphdh3n1Tqp/t0aXaWVOPnsFGre+waRdpKf/TK+7fiX3bOWluVeJg77AAPNDwr37fwAA2GP0+BSOHwcn6/231ghwfPr6X+DIBtTj582d47s8LD3xMeYktt+YHXHe6XQuH9P4Nu+H3ctmGmve/qYEAAAAAACAR7bfnWJlsGgSNNoM54tPZ23EI4vYzPY1/fzq1ud/GP/01jjx8P2tYsG7DzrrB4/vHySTz5YB+n8AAAAAgJrJ/XEXAIDHEf/2yXUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgGdABAAAAAAAAADqbqgIAAAAAAAAAKD2hv8DWK79UBhoBgA=', 'base64'));
//# sourceMappingURL=code-points-data.js.map

@ -0,0 +1 @@
{"version":3,"file":"code-points-data.js","sourceRoot":"","sources":["../src/code-points-data.ts"],"names":[],"mappings":";;AAAA,+BAAkC;AAElC,kBAAe,IAAA,iBAAU,EACvB,MAAM,CAAC,IAAI,CACT,0nFAA0nF,EAC1nF,QAAQ,CACT,CACF,CAAC"}

@ -0,0 +1,7 @@
export declare const unassigned_code_points: Set<number>;
export declare const commonly_mapped_to_nothing: Set<number>;
export declare const non_ASCII_space_characters: Set<number>;
export declare const prohibited_characters: Set<number>;
export declare const bidirectional_r_al: Set<number>;
export declare const bidirectional_l: Set<number>;
//# sourceMappingURL=code-points-src.d.ts.map

@ -0,0 +1 @@
{"version":3,"file":"code-points-src.d.ts","sourceRoot":"","sources":["../src/code-points-src.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB,aA6YjC,CAAC;AAMH,eAAO,MAAM,0BAA0B,aAIrC,CAAC;AAMH,eAAO,MAAM,0BAA0B,aASrC,CAAC;AAMH,eAAO,MAAM,qBAAqB,aA6GhC,CAAC;AAMH,eAAO,MAAM,kBAAkB,aAmC7B,CAAC;AAMH,eAAO,MAAM,eAAe,aAyW1B,CAAC"}

@ -0,0 +1,881 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bidirectional_l = exports.bidirectional_r_al = exports.prohibited_characters = exports.non_ASCII_space_characters = exports.commonly_mapped_to_nothing = exports.unassigned_code_points = void 0;
const util_1 = require("./util");
exports.unassigned_code_points = new Set([
0x0221,
...(0, util_1.range)(0x0234, 0x024f),
...(0, util_1.range)(0x02ae, 0x02af),
...(0, util_1.range)(0x02ef, 0x02ff),
...(0, util_1.range)(0x0350, 0x035f),
...(0, util_1.range)(0x0370, 0x0373),
...(0, util_1.range)(0x0376, 0x0379),
...(0, util_1.range)(0x037b, 0x037d),
...(0, util_1.range)(0x037f, 0x0383),
0x038b,
0x038d,
0x03a2,
0x03cf,
...(0, util_1.range)(0x03f7, 0x03ff),
0x0487,
0x04cf,
...(0, util_1.range)(0x04f6, 0x04f7),
...(0, util_1.range)(0x04fa, 0x04ff),
...(0, util_1.range)(0x0510, 0x0530),
...(0, util_1.range)(0x0557, 0x0558),
0x0560,
0x0588,
...(0, util_1.range)(0x058b, 0x0590),
0x05a2,
0x05ba,
...(0, util_1.range)(0x05c5, 0x05cf),
...(0, util_1.range)(0x05eb, 0x05ef),
...(0, util_1.range)(0x05f5, 0x060b),
...(0, util_1.range)(0x060d, 0x061a),
...(0, util_1.range)(0x061c, 0x061e),
0x0620,
...(0, util_1.range)(0x063b, 0x063f),
...(0, util_1.range)(0x0656, 0x065f),
...(0, util_1.range)(0x06ee, 0x06ef),
0x06ff,
0x070e,
...(0, util_1.range)(0x072d, 0x072f),
...(0, util_1.range)(0x074b, 0x077f),
...(0, util_1.range)(0x07b2, 0x0900),
0x0904,
...(0, util_1.range)(0x093a, 0x093b),
...(0, util_1.range)(0x094e, 0x094f),
...(0, util_1.range)(0x0955, 0x0957),
...(0, util_1.range)(0x0971, 0x0980),
0x0984,
...(0, util_1.range)(0x098d, 0x098e),
...(0, util_1.range)(0x0991, 0x0992),
0x09a9,
0x09b1,
...(0, util_1.range)(0x09b3, 0x09b5),
...(0, util_1.range)(0x09ba, 0x09bb),
0x09bd,
...(0, util_1.range)(0x09c5, 0x09c6),
...(0, util_1.range)(0x09c9, 0x09ca),
...(0, util_1.range)(0x09ce, 0x09d6),
...(0, util_1.range)(0x09d8, 0x09db),
0x09de,
...(0, util_1.range)(0x09e4, 0x09e5),
...(0, util_1.range)(0x09fb, 0x0a01),
...(0, util_1.range)(0x0a03, 0x0a04),
...(0, util_1.range)(0x0a0b, 0x0a0e),
...(0, util_1.range)(0x0a11, 0x0a12),
0x0a29,
0x0a31,
0x0a34,
0x0a37,
...(0, util_1.range)(0x0a3a, 0x0a3b),
0x0a3d,
...(0, util_1.range)(0x0a43, 0x0a46),
...(0, util_1.range)(0x0a49, 0x0a4a),
...(0, util_1.range)(0x0a4e, 0x0a58),
0x0a5d,
...(0, util_1.range)(0x0a5f, 0x0a65),
...(0, util_1.range)(0x0a75, 0x0a80),
0x0a84,
0x0a8c,
0x0a8e,
0x0a92,
0x0aa9,
0x0ab1,
0x0ab4,
...(0, util_1.range)(0x0aba, 0x0abb),
0x0ac6,
0x0aca,
...(0, util_1.range)(0x0ace, 0x0acf),
...(0, util_1.range)(0x0ad1, 0x0adf),
...(0, util_1.range)(0x0ae1, 0x0ae5),
...(0, util_1.range)(0x0af0, 0x0b00),
0x0b04,
...(0, util_1.range)(0x0b0d, 0x0b0e),
...(0, util_1.range)(0x0b11, 0x0b12),
0x0b29,
0x0b31,
...(0, util_1.range)(0x0b34, 0x0b35),
...(0, util_1.range)(0x0b3a, 0x0b3b),
...(0, util_1.range)(0x0b44, 0x0b46),
...(0, util_1.range)(0x0b49, 0x0b4a),
...(0, util_1.range)(0x0b4e, 0x0b55),
...(0, util_1.range)(0x0b58, 0x0b5b),
0x0b5e,
...(0, util_1.range)(0x0b62, 0x0b65),
...(0, util_1.range)(0x0b71, 0x0b81),
0x0b84,
...(0, util_1.range)(0x0b8b, 0x0b8d),
0x0b91,
...(0, util_1.range)(0x0b96, 0x0b98),
0x0b9b,
0x0b9d,
...(0, util_1.range)(0x0ba0, 0x0ba2),
...(0, util_1.range)(0x0ba5, 0x0ba7),
...(0, util_1.range)(0x0bab, 0x0bad),
0x0bb6,
...(0, util_1.range)(0x0bba, 0x0bbd),
...(0, util_1.range)(0x0bc3, 0x0bc5),
0x0bc9,
...(0, util_1.range)(0x0bce, 0x0bd6),
...(0, util_1.range)(0x0bd8, 0x0be6),
...(0, util_1.range)(0x0bf3, 0x0c00),
0x0c04,
0x0c0d,
0x0c11,
0x0c29,
0x0c34,
...(0, util_1.range)(0x0c3a, 0x0c3d),
0x0c45,
0x0c49,
...(0, util_1.range)(0x0c4e, 0x0c54),
...(0, util_1.range)(0x0c57, 0x0c5f),
...(0, util_1.range)(0x0c62, 0x0c65),
...(0, util_1.range)(0x0c70, 0x0c81),
0x0c84,
0x0c8d,
0x0c91,
0x0ca9,
0x0cb4,
...(0, util_1.range)(0x0cba, 0x0cbd),
0x0cc5,
0x0cc9,
...(0, util_1.range)(0x0cce, 0x0cd4),
...(0, util_1.range)(0x0cd7, 0x0cdd),
0x0cdf,
...(0, util_1.range)(0x0ce2, 0x0ce5),
...(0, util_1.range)(0x0cf0, 0x0d01),
0x0d04,
0x0d0d,
0x0d11,
0x0d29,
...(0, util_1.range)(0x0d3a, 0x0d3d),
...(0, util_1.range)(0x0d44, 0x0d45),
0x0d49,
...(0, util_1.range)(0x0d4e, 0x0d56),
...(0, util_1.range)(0x0d58, 0x0d5f),
...(0, util_1.range)(0x0d62, 0x0d65),
...(0, util_1.range)(0x0d70, 0x0d81),
0x0d84,
...(0, util_1.range)(0x0d97, 0x0d99),
0x0db2,
0x0dbc,
...(0, util_1.range)(0x0dbe, 0x0dbf),
...(0, util_1.range)(0x0dc7, 0x0dc9),
...(0, util_1.range)(0x0dcb, 0x0dce),
0x0dd5,
0x0dd7,
...(0, util_1.range)(0x0de0, 0x0df1),
...(0, util_1.range)(0x0df5, 0x0e00),
...(0, util_1.range)(0x0e3b, 0x0e3e),
...(0, util_1.range)(0x0e5c, 0x0e80),
0x0e83,
...(0, util_1.range)(0x0e85, 0x0e86),
0x0e89,
...(0, util_1.range)(0x0e8b, 0x0e8c),
...(0, util_1.range)(0x0e8e, 0x0e93),
0x0e98,
0x0ea0,
0x0ea4,
0x0ea6,
...(0, util_1.range)(0x0ea8, 0x0ea9),
0x0eac,
0x0eba,
...(0, util_1.range)(0x0ebe, 0x0ebf),
0x0ec5,
0x0ec7,
...(0, util_1.range)(0x0ece, 0x0ecf),
...(0, util_1.range)(0x0eda, 0x0edb),
...(0, util_1.range)(0x0ede, 0x0eff),
0x0f48,
...(0, util_1.range)(0x0f6b, 0x0f70),
...(0, util_1.range)(0x0f8c, 0x0f8f),
0x0f98,
0x0fbd,
...(0, util_1.range)(0x0fcd, 0x0fce),
...(0, util_1.range)(0x0fd0, 0x0fff),
0x1022,
0x1028,
0x102b,
...(0, util_1.range)(0x1033, 0x1035),
...(0, util_1.range)(0x103a, 0x103f),
...(0, util_1.range)(0x105a, 0x109f),
...(0, util_1.range)(0x10c6, 0x10cf),
...(0, util_1.range)(0x10f9, 0x10fa),
...(0, util_1.range)(0x10fc, 0x10ff),
...(0, util_1.range)(0x115a, 0x115e),
...(0, util_1.range)(0x11a3, 0x11a7),
...(0, util_1.range)(0x11fa, 0x11ff),
0x1207,
0x1247,
0x1249,
...(0, util_1.range)(0x124e, 0x124f),
0x1257,
0x1259,
...(0, util_1.range)(0x125e, 0x125f),
0x1287,
0x1289,
...(0, util_1.range)(0x128e, 0x128f),
0x12af,
0x12b1,
...(0, util_1.range)(0x12b6, 0x12b7),
0x12bf,
0x12c1,
...(0, util_1.range)(0x12c6, 0x12c7),
0x12cf,
0x12d7,
0x12ef,
0x130f,
0x1311,
...(0, util_1.range)(0x1316, 0x1317),
0x131f,
0x1347,
...(0, util_1.range)(0x135b, 0x1360),
...(0, util_1.range)(0x137d, 0x139f),
...(0, util_1.range)(0x13f5, 0x1400),
...(0, util_1.range)(0x1677, 0x167f),
...(0, util_1.range)(0x169d, 0x169f),
...(0, util_1.range)(0x16f1, 0x16ff),
0x170d,
...(0, util_1.range)(0x1715, 0x171f),
...(0, util_1.range)(0x1737, 0x173f),
...(0, util_1.range)(0x1754, 0x175f),
0x176d,
0x1771,
...(0, util_1.range)(0x1774, 0x177f),
...(0, util_1.range)(0x17dd, 0x17df),
...(0, util_1.range)(0x17ea, 0x17ff),
0x180f,
...(0, util_1.range)(0x181a, 0x181f),
...(0, util_1.range)(0x1878, 0x187f),
...(0, util_1.range)(0x18aa, 0x1dff),
...(0, util_1.range)(0x1e9c, 0x1e9f),
...(0, util_1.range)(0x1efa, 0x1eff),
...(0, util_1.range)(0x1f16, 0x1f17),
...(0, util_1.range)(0x1f1e, 0x1f1f),
...(0, util_1.range)(0x1f46, 0x1f47),
...(0, util_1.range)(0x1f4e, 0x1f4f),
0x1f58,
0x1f5a,
0x1f5c,
0x1f5e,
...(0, util_1.range)(0x1f7e, 0x1f7f),
0x1fb5,
0x1fc5,
...(0, util_1.range)(0x1fd4, 0x1fd5),
0x1fdc,
...(0, util_1.range)(0x1ff0, 0x1ff1),
0x1ff5,
0x1fff,
...(0, util_1.range)(0x2053, 0x2056),
...(0, util_1.range)(0x2058, 0x205e),
...(0, util_1.range)(0x2064, 0x2069),
...(0, util_1.range)(0x2072, 0x2073),
...(0, util_1.range)(0x208f, 0x209f),
...(0, util_1.range)(0x20b2, 0x20cf),
...(0, util_1.range)(0x20eb, 0x20ff),
...(0, util_1.range)(0x213b, 0x213c),
...(0, util_1.range)(0x214c, 0x2152),
...(0, util_1.range)(0x2184, 0x218f),
...(0, util_1.range)(0x23cf, 0x23ff),
...(0, util_1.range)(0x2427, 0x243f),
...(0, util_1.range)(0x244b, 0x245f),
0x24ff,
...(0, util_1.range)(0x2614, 0x2615),
0x2618,
...(0, util_1.range)(0x267e, 0x267f),
...(0, util_1.range)(0x268a, 0x2700),
0x2705,
...(0, util_1.range)(0x270a, 0x270b),
0x2728,
0x274c,
0x274e,
...(0, util_1.range)(0x2753, 0x2755),
0x2757,
...(0, util_1.range)(0x275f, 0x2760),
...(0, util_1.range)(0x2795, 0x2797),
0x27b0,
...(0, util_1.range)(0x27bf, 0x27cf),
...(0, util_1.range)(0x27ec, 0x27ef),
...(0, util_1.range)(0x2b00, 0x2e7f),
0x2e9a,
...(0, util_1.range)(0x2ef4, 0x2eff),
...(0, util_1.range)(0x2fd6, 0x2fef),
...(0, util_1.range)(0x2ffc, 0x2fff),
0x3040,
...(0, util_1.range)(0x3097, 0x3098),
...(0, util_1.range)(0x3100, 0x3104),
...(0, util_1.range)(0x312d, 0x3130),
0x318f,
...(0, util_1.range)(0x31b8, 0x31ef),
...(0, util_1.range)(0x321d, 0x321f),
...(0, util_1.range)(0x3244, 0x3250),
...(0, util_1.range)(0x327c, 0x327e),
...(0, util_1.range)(0x32cc, 0x32cf),
0x32ff,
...(0, util_1.range)(0x3377, 0x337a),
...(0, util_1.range)(0x33de, 0x33df),
0x33ff,
...(0, util_1.range)(0x4db6, 0x4dff),
...(0, util_1.range)(0x9fa6, 0x9fff),
...(0, util_1.range)(0xa48d, 0xa48f),
...(0, util_1.range)(0xa4c7, 0xabff),
...(0, util_1.range)(0xd7a4, 0xd7ff),
...(0, util_1.range)(0xfa2e, 0xfa2f),
...(0, util_1.range)(0xfa6b, 0xfaff),
...(0, util_1.range)(0xfb07, 0xfb12),
...(0, util_1.range)(0xfb18, 0xfb1c),
0xfb37,
0xfb3d,
0xfb3f,
0xfb42,
0xfb45,
...(0, util_1.range)(0xfbb2, 0xfbd2),
...(0, util_1.range)(0xfd40, 0xfd4f),
...(0, util_1.range)(0xfd90, 0xfd91),
...(0, util_1.range)(0xfdc8, 0xfdcf),
...(0, util_1.range)(0xfdfd, 0xfdff),
...(0, util_1.range)(0xfe10, 0xfe1f),
...(0, util_1.range)(0xfe24, 0xfe2f),
...(0, util_1.range)(0xfe47, 0xfe48),
0xfe53,
0xfe67,
...(0, util_1.range)(0xfe6c, 0xfe6f),
0xfe75,
...(0, util_1.range)(0xfefd, 0xfefe),
0xff00,
...(0, util_1.range)(0xffbf, 0xffc1),
...(0, util_1.range)(0xffc8, 0xffc9),
...(0, util_1.range)(0xffd0, 0xffd1),
...(0, util_1.range)(0xffd8, 0xffd9),
...(0, util_1.range)(0xffdd, 0xffdf),
0xffe7,
...(0, util_1.range)(0xffef, 0xfff8),
...(0, util_1.range)(0x10000, 0x102ff),
0x1031f,
...(0, util_1.range)(0x10324, 0x1032f),
...(0, util_1.range)(0x1034b, 0x103ff),
...(0, util_1.range)(0x10426, 0x10427),
...(0, util_1.range)(0x1044e, 0x1cfff),
...(0, util_1.range)(0x1d0f6, 0x1d0ff),
...(0, util_1.range)(0x1d127, 0x1d129),
...(0, util_1.range)(0x1d1de, 0x1d3ff),
0x1d455,
0x1d49d,
...(0, util_1.range)(0x1d4a0, 0x1d4a1),
...(0, util_1.range)(0x1d4a3, 0x1d4a4),
...(0, util_1.range)(0x1d4a7, 0x1d4a8),
0x1d4ad,
0x1d4ba,
0x1d4bc,
0x1d4c1,
0x1d4c4,
0x1d506,
...(0, util_1.range)(0x1d50b, 0x1d50c),
0x1d515,
0x1d51d,
0x1d53a,
0x1d53f,
0x1d545,
...(0, util_1.range)(0x1d547, 0x1d549),
0x1d551,
...(0, util_1.range)(0x1d6a4, 0x1d6a7),
...(0, util_1.range)(0x1d7ca, 0x1d7cd),
...(0, util_1.range)(0x1d800, 0x1fffd),
...(0, util_1.range)(0x2a6d7, 0x2f7ff),
...(0, util_1.range)(0x2fa1e, 0x2fffd),
...(0, util_1.range)(0x30000, 0x3fffd),
...(0, util_1.range)(0x40000, 0x4fffd),
...(0, util_1.range)(0x50000, 0x5fffd),
...(0, util_1.range)(0x60000, 0x6fffd),
...(0, util_1.range)(0x70000, 0x7fffd),
...(0, util_1.range)(0x80000, 0x8fffd),
...(0, util_1.range)(0x90000, 0x9fffd),
...(0, util_1.range)(0xa0000, 0xafffd),
...(0, util_1.range)(0xb0000, 0xbfffd),
...(0, util_1.range)(0xc0000, 0xcfffd),
...(0, util_1.range)(0xd0000, 0xdfffd),
0xe0000,
...(0, util_1.range)(0xe0002, 0xe001f),
...(0, util_1.range)(0xe0080, 0xefffd),
]);
exports.commonly_mapped_to_nothing = new Set([
0x00ad, 0x034f, 0x1806, 0x180b, 0x180c, 0x180d, 0x200b, 0x200c, 0x200d,
0x2060, 0xfe00, 0xfe01, 0xfe02, 0xfe03, 0xfe04, 0xfe05, 0xfe06, 0xfe07,
0xfe08, 0xfe09, 0xfe0a, 0xfe0b, 0xfe0c, 0xfe0d, 0xfe0e, 0xfe0f, 0xfeff,
]);
exports.non_ASCII_space_characters = new Set([
0x00a0, 0x1680,
0x2000, 0x2001, 0x2002,
0x2003, 0x2004,
0x2005, 0x2006,
0x2007, 0x2008,
0x2009, 0x200a,
0x200b, 0x202f,
0x205f, 0x3000,
]);
exports.prohibited_characters = new Set([
...exports.non_ASCII_space_characters,
...(0, util_1.range)(0, 0x001f),
0x007f,
...(0, util_1.range)(0x0080, 0x009f),
0x06dd,
0x070f,
0x180e,
0x200c,
0x200d,
0x2028,
0x2029,
0x2060,
0x2061,
0x2062,
0x2063,
...(0, util_1.range)(0x206a, 0x206f),
0xfeff,
...(0, util_1.range)(0xfff9, 0xfffc),
...(0, util_1.range)(0x1d173, 0x1d17a),
...(0, util_1.range)(0xe000, 0xf8ff),
...(0, util_1.range)(0xf0000, 0xffffd),
...(0, util_1.range)(0x100000, 0x10fffd),
...(0, util_1.range)(0xfdd0, 0xfdef),
...(0, util_1.range)(0xfffe, 0xffff),
...(0, util_1.range)(0x1fffe, 0x1ffff),
...(0, util_1.range)(0x2fffe, 0x2ffff),
...(0, util_1.range)(0x3fffe, 0x3ffff),
...(0, util_1.range)(0x4fffe, 0x4ffff),
...(0, util_1.range)(0x5fffe, 0x5ffff),
...(0, util_1.range)(0x6fffe, 0x6ffff),
...(0, util_1.range)(0x7fffe, 0x7ffff),
...(0, util_1.range)(0x8fffe, 0x8ffff),
...(0, util_1.range)(0x9fffe, 0x9ffff),
...(0, util_1.range)(0xafffe, 0xaffff),
...(0, util_1.range)(0xbfffe, 0xbffff),
...(0, util_1.range)(0xcfffe, 0xcffff),
...(0, util_1.range)(0xdfffe, 0xdffff),
...(0, util_1.range)(0xefffe, 0xeffff),
...(0, util_1.range)(0x10fffe, 0x10ffff),
...(0, util_1.range)(0xd800, 0xdfff),
0xfff9,
0xfffa,
0xfffb,
0xfffc,
0xfffd,
...(0, util_1.range)(0x2ff0, 0x2ffb),
0x0340,
0x0341,
0x200e,
0x200f,
0x202a,
0x202b,
0x202c,
0x202d,
0x202e,
0x206a,
0x206b,
0x206c,
0x206d,
0x206e,
0x206f,
0xe0001,
...(0, util_1.range)(0xe0020, 0xe007f),
]);
exports.bidirectional_r_al = new Set([
0x05be,
0x05c0,
0x05c3,
...(0, util_1.range)(0x05d0, 0x05ea),
...(0, util_1.range)(0x05f0, 0x05f4),
0x061b,
0x061f,
...(0, util_1.range)(0x0621, 0x063a),
...(0, util_1.range)(0x0640, 0x064a),
...(0, util_1.range)(0x066d, 0x066f),
...(0, util_1.range)(0x0671, 0x06d5),
0x06dd,
...(0, util_1.range)(0x06e5, 0x06e6),
...(0, util_1.range)(0x06fa, 0x06fe),
...(0, util_1.range)(0x0700, 0x070d),
0x0710,
...(0, util_1.range)(0x0712, 0x072c),
...(0, util_1.range)(0x0780, 0x07a5),
0x07b1,
0x200f,
0xfb1d,
...(0, util_1.range)(0xfb1f, 0xfb28),
...(0, util_1.range)(0xfb2a, 0xfb36),
...(0, util_1.range)(0xfb38, 0xfb3c),
0xfb3e,
...(0, util_1.range)(0xfb40, 0xfb41),
...(0, util_1.range)(0xfb43, 0xfb44),
...(0, util_1.range)(0xfb46, 0xfbb1),
...(0, util_1.range)(0xfbd3, 0xfd3d),
...(0, util_1.range)(0xfd50, 0xfd8f),
...(0, util_1.range)(0xfd92, 0xfdc7),
...(0, util_1.range)(0xfdf0, 0xfdfc),
...(0, util_1.range)(0xfe70, 0xfe74),
...(0, util_1.range)(0xfe76, 0xfefc),
]);
exports.bidirectional_l = new Set([
...(0, util_1.range)(0x0041, 0x005a),
...(0, util_1.range)(0x0061, 0x007a),
0x00aa,
0x00b5,
0x00ba,
...(0, util_1.range)(0x00c0, 0x00d6),
...(0, util_1.range)(0x00d8, 0x00f6),
...(0, util_1.range)(0x00f8, 0x0220),
...(0, util_1.range)(0x0222, 0x0233),
...(0, util_1.range)(0x0250, 0x02ad),
...(0, util_1.range)(0x02b0, 0x02b8),
...(0, util_1.range)(0x02bb, 0x02c1),
...(0, util_1.range)(0x02d0, 0x02d1),
...(0, util_1.range)(0x02e0, 0x02e4),
0x02ee,
0x037a,
0x0386,
...(0, util_1.range)(0x0388, 0x038a),
0x038c,
...(0, util_1.range)(0x038e, 0x03a1),
...(0, util_1.range)(0x03a3, 0x03ce),
...(0, util_1.range)(0x03d0, 0x03f5),
...(0, util_1.range)(0x0400, 0x0482),
...(0, util_1.range)(0x048a, 0x04ce),
...(0, util_1.range)(0x04d0, 0x04f5),
...(0, util_1.range)(0x04f8, 0x04f9),
...(0, util_1.range)(0x0500, 0x050f),
...(0, util_1.range)(0x0531, 0x0556),
...(0, util_1.range)(0x0559, 0x055f),
...(0, util_1.range)(0x0561, 0x0587),
0x0589,
0x0903,
...(0, util_1.range)(0x0905, 0x0939),
...(0, util_1.range)(0x093d, 0x0940),
...(0, util_1.range)(0x0949, 0x094c),
0x0950,
...(0, util_1.range)(0x0958, 0x0961),
...(0, util_1.range)(0x0964, 0x0970),
...(0, util_1.range)(0x0982, 0x0983),
...(0, util_1.range)(0x0985, 0x098c),
...(0, util_1.range)(0x098f, 0x0990),
...(0, util_1.range)(0x0993, 0x09a8),
...(0, util_1.range)(0x09aa, 0x09b0),
0x09b2,
...(0, util_1.range)(0x09b6, 0x09b9),
...(0, util_1.range)(0x09be, 0x09c0),
...(0, util_1.range)(0x09c7, 0x09c8),
...(0, util_1.range)(0x09cb, 0x09cc),
0x09d7,
...(0, util_1.range)(0x09dc, 0x09dd),
...(0, util_1.range)(0x09df, 0x09e1),
...(0, util_1.range)(0x09e6, 0x09f1),
...(0, util_1.range)(0x09f4, 0x09fa),
...(0, util_1.range)(0x0a05, 0x0a0a),
...(0, util_1.range)(0x0a0f, 0x0a10),
...(0, util_1.range)(0x0a13, 0x0a28),
...(0, util_1.range)(0x0a2a, 0x0a30),
...(0, util_1.range)(0x0a32, 0x0a33),
...(0, util_1.range)(0x0a35, 0x0a36),
...(0, util_1.range)(0x0a38, 0x0a39),
...(0, util_1.range)(0x0a3e, 0x0a40),
...(0, util_1.range)(0x0a59, 0x0a5c),
0x0a5e,
...(0, util_1.range)(0x0a66, 0x0a6f),
...(0, util_1.range)(0x0a72, 0x0a74),
0x0a83,
...(0, util_1.range)(0x0a85, 0x0a8b),
0x0a8d,
...(0, util_1.range)(0x0a8f, 0x0a91),
...(0, util_1.range)(0x0a93, 0x0aa8),
...(0, util_1.range)(0x0aaa, 0x0ab0),
...(0, util_1.range)(0x0ab2, 0x0ab3),
...(0, util_1.range)(0x0ab5, 0x0ab9),
...(0, util_1.range)(0x0abd, 0x0ac0),
0x0ac9,
...(0, util_1.range)(0x0acb, 0x0acc),
0x0ad0,
0x0ae0,
...(0, util_1.range)(0x0ae6, 0x0aef),
...(0, util_1.range)(0x0b02, 0x0b03),
...(0, util_1.range)(0x0b05, 0x0b0c),
...(0, util_1.range)(0x0b0f, 0x0b10),
...(0, util_1.range)(0x0b13, 0x0b28),
...(0, util_1.range)(0x0b2a, 0x0b30),
...(0, util_1.range)(0x0b32, 0x0b33),
...(0, util_1.range)(0x0b36, 0x0b39),
...(0, util_1.range)(0x0b3d, 0x0b3e),
0x0b40,
...(0, util_1.range)(0x0b47, 0x0b48),
...(0, util_1.range)(0x0b4b, 0x0b4c),
0x0b57,
...(0, util_1.range)(0x0b5c, 0x0b5d),
...(0, util_1.range)(0x0b5f, 0x0b61),
...(0, util_1.range)(0x0b66, 0x0b70),
0x0b83,
...(0, util_1.range)(0x0b85, 0x0b8a),
...(0, util_1.range)(0x0b8e, 0x0b90),
...(0, util_1.range)(0x0b92, 0x0b95),
...(0, util_1.range)(0x0b99, 0x0b9a),
0x0b9c,
...(0, util_1.range)(0x0b9e, 0x0b9f),
...(0, util_1.range)(0x0ba3, 0x0ba4),
...(0, util_1.range)(0x0ba8, 0x0baa),
...(0, util_1.range)(0x0bae, 0x0bb5),
...(0, util_1.range)(0x0bb7, 0x0bb9),
...(0, util_1.range)(0x0bbe, 0x0bbf),
...(0, util_1.range)(0x0bc1, 0x0bc2),
...(0, util_1.range)(0x0bc6, 0x0bc8),
...(0, util_1.range)(0x0bca, 0x0bcc),
0x0bd7,
...(0, util_1.range)(0x0be7, 0x0bf2),
...(0, util_1.range)(0x0c01, 0x0c03),
...(0, util_1.range)(0x0c05, 0x0c0c),
...(0, util_1.range)(0x0c0e, 0x0c10),
...(0, util_1.range)(0x0c12, 0x0c28),
...(0, util_1.range)(0x0c2a, 0x0c33),
...(0, util_1.range)(0x0c35, 0x0c39),
...(0, util_1.range)(0x0c41, 0x0c44),
...(0, util_1.range)(0x0c60, 0x0c61),
...(0, util_1.range)(0x0c66, 0x0c6f),
...(0, util_1.range)(0x0c82, 0x0c83),
...(0, util_1.range)(0x0c85, 0x0c8c),
...(0, util_1.range)(0x0c8e, 0x0c90),
...(0, util_1.range)(0x0c92, 0x0ca8),
...(0, util_1.range)(0x0caa, 0x0cb3),
...(0, util_1.range)(0x0cb5, 0x0cb9),
0x0cbe,
...(0, util_1.range)(0x0cc0, 0x0cc4),
...(0, util_1.range)(0x0cc7, 0x0cc8),
...(0, util_1.range)(0x0cca, 0x0ccb),
...(0, util_1.range)(0x0cd5, 0x0cd6),
0x0cde,
...(0, util_1.range)(0x0ce0, 0x0ce1),
...(0, util_1.range)(0x0ce6, 0x0cef),
...(0, util_1.range)(0x0d02, 0x0d03),
...(0, util_1.range)(0x0d05, 0x0d0c),
...(0, util_1.range)(0x0d0e, 0x0d10),
...(0, util_1.range)(0x0d12, 0x0d28),
...(0, util_1.range)(0x0d2a, 0x0d39),
...(0, util_1.range)(0x0d3e, 0x0d40),
...(0, util_1.range)(0x0d46, 0x0d48),
...(0, util_1.range)(0x0d4a, 0x0d4c),
0x0d57,
...(0, util_1.range)(0x0d60, 0x0d61),
...(0, util_1.range)(0x0d66, 0x0d6f),
...(0, util_1.range)(0x0d82, 0x0d83),
...(0, util_1.range)(0x0d85, 0x0d96),
...(0, util_1.range)(0x0d9a, 0x0db1),
...(0, util_1.range)(0x0db3, 0x0dbb),
0x0dbd,
...(0, util_1.range)(0x0dc0, 0x0dc6),
...(0, util_1.range)(0x0dcf, 0x0dd1),
...(0, util_1.range)(0x0dd8, 0x0ddf),
...(0, util_1.range)(0x0df2, 0x0df4),
...(0, util_1.range)(0x0e01, 0x0e30),
...(0, util_1.range)(0x0e32, 0x0e33),
...(0, util_1.range)(0x0e40, 0x0e46),
...(0, util_1.range)(0x0e4f, 0x0e5b),
...(0, util_1.range)(0x0e81, 0x0e82),
0x0e84,
...(0, util_1.range)(0x0e87, 0x0e88),
0x0e8a,
0x0e8d,
...(0, util_1.range)(0x0e94, 0x0e97),
...(0, util_1.range)(0x0e99, 0x0e9f),
...(0, util_1.range)(0x0ea1, 0x0ea3),
0x0ea5,
0x0ea7,
...(0, util_1.range)(0x0eaa, 0x0eab),
...(0, util_1.range)(0x0ead, 0x0eb0),
...(0, util_1.range)(0x0eb2, 0x0eb3),
0x0ebd,
...(0, util_1.range)(0x0ec0, 0x0ec4),
0x0ec6,
...(0, util_1.range)(0x0ed0, 0x0ed9),
...(0, util_1.range)(0x0edc, 0x0edd),
...(0, util_1.range)(0x0f00, 0x0f17),
...(0, util_1.range)(0x0f1a, 0x0f34),
0x0f36,
0x0f38,
...(0, util_1.range)(0x0f3e, 0x0f47),
...(0, util_1.range)(0x0f49, 0x0f6a),
0x0f7f,
0x0f85,
...(0, util_1.range)(0x0f88, 0x0f8b),
...(0, util_1.range)(0x0fbe, 0x0fc5),
...(0, util_1.range)(0x0fc7, 0x0fcc),
0x0fcf,
...(0, util_1.range)(0x1000, 0x1021),
...(0, util_1.range)(0x1023, 0x1027),
...(0, util_1.range)(0x1029, 0x102a),
0x102c,
0x1031,
0x1038,
...(0, util_1.range)(0x1040, 0x1057),
...(0, util_1.range)(0x10a0, 0x10c5),
...(0, util_1.range)(0x10d0, 0x10f8),
0x10fb,
...(0, util_1.range)(0x1100, 0x1159),
...(0, util_1.range)(0x115f, 0x11a2),
...(0, util_1.range)(0x11a8, 0x11f9),
...(0, util_1.range)(0x1200, 0x1206),
...(0, util_1.range)(0x1208, 0x1246),
0x1248,
...(0, util_1.range)(0x124a, 0x124d),
...(0, util_1.range)(0x1250, 0x1256),
0x1258,
...(0, util_1.range)(0x125a, 0x125d),
...(0, util_1.range)(0x1260, 0x1286),
0x1288,
...(0, util_1.range)(0x128a, 0x128d),
...(0, util_1.range)(0x1290, 0x12ae),
0x12b0,
...(0, util_1.range)(0x12b2, 0x12b5),
...(0, util_1.range)(0x12b8, 0x12be),
0x12c0,
...(0, util_1.range)(0x12c2, 0x12c5),
...(0, util_1.range)(0x12c8, 0x12ce),
...(0, util_1.range)(0x12d0, 0x12d6),
...(0, util_1.range)(0x12d8, 0x12ee),
...(0, util_1.range)(0x12f0, 0x130e),
0x1310,
...(0, util_1.range)(0x1312, 0x1315),
...(0, util_1.range)(0x1318, 0x131e),
...(0, util_1.range)(0x1320, 0x1346),
...(0, util_1.range)(0x1348, 0x135a),
...(0, util_1.range)(0x1361, 0x137c),
...(0, util_1.range)(0x13a0, 0x13f4),
...(0, util_1.range)(0x1401, 0x1676),
...(0, util_1.range)(0x1681, 0x169a),
...(0, util_1.range)(0x16a0, 0x16f0),
...(0, util_1.range)(0x1700, 0x170c),
...(0, util_1.range)(0x170e, 0x1711),
...(0, util_1.range)(0x1720, 0x1731),
...(0, util_1.range)(0x1735, 0x1736),
...(0, util_1.range)(0x1740, 0x1751),
...(0, util_1.range)(0x1760, 0x176c),
...(0, util_1.range)(0x176e, 0x1770),
...(0, util_1.range)(0x1780, 0x17b6),
...(0, util_1.range)(0x17be, 0x17c5),
...(0, util_1.range)(0x17c7, 0x17c8),
...(0, util_1.range)(0x17d4, 0x17da),
0x17dc,
...(0, util_1.range)(0x17e0, 0x17e9),
...(0, util_1.range)(0x1810, 0x1819),
...(0, util_1.range)(0x1820, 0x1877),
...(0, util_1.range)(0x1880, 0x18a8),
...(0, util_1.range)(0x1e00, 0x1e9b),
...(0, util_1.range)(0x1ea0, 0x1ef9),
...(0, util_1.range)(0x1f00, 0x1f15),
...(0, util_1.range)(0x1f18, 0x1f1d),
...(0, util_1.range)(0x1f20, 0x1f45),
...(0, util_1.range)(0x1f48, 0x1f4d),
...(0, util_1.range)(0x1f50, 0x1f57),
0x1f59,
0x1f5b,
0x1f5d,
...(0, util_1.range)(0x1f5f, 0x1f7d),
...(0, util_1.range)(0x1f80, 0x1fb4),
...(0, util_1.range)(0x1fb6, 0x1fbc),
0x1fbe,
...(0, util_1.range)(0x1fc2, 0x1fc4),
...(0, util_1.range)(0x1fc6, 0x1fcc),
...(0, util_1.range)(0x1fd0, 0x1fd3),
...(0, util_1.range)(0x1fd6, 0x1fdb),
...(0, util_1.range)(0x1fe0, 0x1fec),
...(0, util_1.range)(0x1ff2, 0x1ff4),
...(0, util_1.range)(0x1ff6, 0x1ffc),
0x200e,
0x2071,
0x207f,
0x2102,
0x2107,
...(0, util_1.range)(0x210a, 0x2113),
0x2115,
...(0, util_1.range)(0x2119, 0x211d),
0x2124,
0x2126,
0x2128,
...(0, util_1.range)(0x212a, 0x212d),
...(0, util_1.range)(0x212f, 0x2131),
...(0, util_1.range)(0x2133, 0x2139),
...(0, util_1.range)(0x213d, 0x213f),
...(0, util_1.range)(0x2145, 0x2149),
...(0, util_1.range)(0x2160, 0x2183),
...(0, util_1.range)(0x2336, 0x237a),
0x2395,
...(0, util_1.range)(0x249c, 0x24e9),
...(0, util_1.range)(0x3005, 0x3007),
...(0, util_1.range)(0x3021, 0x3029),
...(0, util_1.range)(0x3031, 0x3035),
...(0, util_1.range)(0x3038, 0x303c),
...(0, util_1.range)(0x3041, 0x3096),
...(0, util_1.range)(0x309d, 0x309f),
...(0, util_1.range)(0x30a1, 0x30fa),
...(0, util_1.range)(0x30fc, 0x30ff),
...(0, util_1.range)(0x3105, 0x312c),
...(0, util_1.range)(0x3131, 0x318e),
...(0, util_1.range)(0x3190, 0x31b7),
...(0, util_1.range)(0x31f0, 0x321c),
...(0, util_1.range)(0x3220, 0x3243),
...(0, util_1.range)(0x3260, 0x327b),
...(0, util_1.range)(0x327f, 0x32b0),
...(0, util_1.range)(0x32c0, 0x32cb),
...(0, util_1.range)(0x32d0, 0x32fe),
...(0, util_1.range)(0x3300, 0x3376),
...(0, util_1.range)(0x337b, 0x33dd),
...(0, util_1.range)(0x33e0, 0x33fe),
...(0, util_1.range)(0x3400, 0x4db5),
...(0, util_1.range)(0x4e00, 0x9fa5),
...(0, util_1.range)(0xa000, 0xa48c),
...(0, util_1.range)(0xac00, 0xd7a3),
...(0, util_1.range)(0xd800, 0xfa2d),
...(0, util_1.range)(0xfa30, 0xfa6a),
...(0, util_1.range)(0xfb00, 0xfb06),
...(0, util_1.range)(0xfb13, 0xfb17),
...(0, util_1.range)(0xff21, 0xff3a),
...(0, util_1.range)(0xff41, 0xff5a),
...(0, util_1.range)(0xff66, 0xffbe),
...(0, util_1.range)(0xffc2, 0xffc7),
...(0, util_1.range)(0xffca, 0xffcf),
...(0, util_1.range)(0xffd2, 0xffd7),
...(0, util_1.range)(0xffda, 0xffdc),
...(0, util_1.range)(0x10300, 0x1031e),
...(0, util_1.range)(0x10320, 0x10323),
...(0, util_1.range)(0x10330, 0x1034a),
...(0, util_1.range)(0x10400, 0x10425),
...(0, util_1.range)(0x10428, 0x1044d),
...(0, util_1.range)(0x1d000, 0x1d0f5),
...(0, util_1.range)(0x1d100, 0x1d126),
...(0, util_1.range)(0x1d12a, 0x1d166),
...(0, util_1.range)(0x1d16a, 0x1d172),
...(0, util_1.range)(0x1d183, 0x1d184),
...(0, util_1.range)(0x1d18c, 0x1d1a9),
...(0, util_1.range)(0x1d1ae, 0x1d1dd),
...(0, util_1.range)(0x1d400, 0x1d454),
...(0, util_1.range)(0x1d456, 0x1d49c),
...(0, util_1.range)(0x1d49e, 0x1d49f),
0x1d4a2,
...(0, util_1.range)(0x1d4a5, 0x1d4a6),
...(0, util_1.range)(0x1d4a9, 0x1d4ac),
...(0, util_1.range)(0x1d4ae, 0x1d4b9),
0x1d4bb,
...(0, util_1.range)(0x1d4bd, 0x1d4c0),
...(0, util_1.range)(0x1d4c2, 0x1d4c3),
...(0, util_1.range)(0x1d4c5, 0x1d505),
...(0, util_1.range)(0x1d507, 0x1d50a),
...(0, util_1.range)(0x1d50d, 0x1d514),
...(0, util_1.range)(0x1d516, 0x1d51c),
...(0, util_1.range)(0x1d51e, 0x1d539),
...(0, util_1.range)(0x1d53b, 0x1d53e),
...(0, util_1.range)(0x1d540, 0x1d544),
0x1d546,
...(0, util_1.range)(0x1d54a, 0x1d550),
...(0, util_1.range)(0x1d552, 0x1d6a3),
...(0, util_1.range)(0x1d6a8, 0x1d7c9),
...(0, util_1.range)(0x20000, 0x2a6d6),
...(0, util_1.range)(0x2f800, 0x2fa1d),
...(0, util_1.range)(0xf0000, 0xffffd),
...(0, util_1.range)(0x100000, 0x10fffd),
]);
//# sourceMappingURL=code-points-src.js.map

File diff suppressed because one or more lines are too long

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=generate-code-points.d.ts.map

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

Loading…
Cancel
Save