Jake235 Posted March 11, 2022 Share Posted March 11, 2022 (edited) Hi, my website is a trial website. This is what my code is, it should give you an idea of what I want to do. Question is, is it possible, am I going about it the wrong way, do I need to only use JSON-T? I have been able to connect to mongodb on my own with localhost, but, I would love to be able to make an application myself with squarespace and cut out the middle-ware. Question is, does that require a lot more sophistication? Something like this works in the local host. //jshint esversion:6 let url = 'https://lavender-ellipse-xay2.squarespace.com'; let express = require('express'); const app = express(); const path = require('path'); const https = require('https'); app.set('view engine', 'ejs'); let fs = require('fs'); const parser = require('body-parser'); const parsing = parser.urlencoded({ extended: true }); //squarespace-server https://trombone-oboe-e8lm.squarespace.com/ --auth //<password> /* const mongoose = require('mongoose'); const username = "<username>"; const password = "<password>"; const cluster = "<clusterName>"; const uri = '<urlName/database>'; const dbname= "sample_airbnb"; const sqserver = mongoose.connect(`<mongo+srv setup>/myFirstDatabase`); const citySchema = new mongoose.Schema({ name:{ type: String, required: [1, "Please check your data entry, no name specified"] //You can use 1 or true for the required option }, rating: { type: Number, min: 1, max: 10 }, review: String, return_policy: String, price_of_rent: Number }); const City = mongoose.model('City', citySchema); const Rockville = new City({ name: "Rockville", rating: 8, review: "Really good city! I liked it", return_policy: "", price_of_rent: 666 }); */ //Rockville.save(); /*Person.deleteMany({name: "Lex"}, (err) => { if (err) { console.log(err); } else{ console.log("Successfully updated the item.!"); } //End of the Update });*/ //To delete many //fruit.save(); // /*Fruit.updateOne({_id:"6222a7bbe41fe2584ceee236" }, {name: "Peach"}, (err) => { if (err){ console.log(err); } else { console.log("You have successfully updated the document!"); } }); console.log("Saved the fruit"); Fruit.deleteMany({name: "apple"}, (err) => { if (err){ console.log(err); } else { console.log("Successfuly deleted the items!!"); } }) const banana = new Fruit({ name: "banana", rating: 8, review: "pretty great fruit! I love it." }); /*Fruit.insertMany([], (err) => { if (err) { console.log(err);} else{ console.log("Successfully save dall the fruits to the DB!"); } } ); */ /* Fruit.find((err, fruits) => { if (err){ console.log(err); } else{ fruits.forEach((fruit) => { console.log(fruit.name); }) // mongoose.connection.close(); } }); const apple = new Fruit({ name: "apple", rating: 8, review: "pretty great fruit! I love it." }); //Rockville.save(); //console.log("Saved the fruit") */ //Trying to use the express server for an app Get. app.use(express.static(__dirname + 'public')); app.get('/', (req, res) => { res.write("Hi!!!"); }); app.listen(process.env.port ||, (err)=> { if (err){ console.log(err); } else { console.log("Successful"); } }); Edited March 11, 2022 by Jake235 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment