NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

// const express = require("express");
// const mongoose = require("mongoose"); // Import mongoose
// const app = express();
// const cors = require("cors");
// require("dotenv").config();
// const connectDB = require("./config/db");
// const PORT = process.env.PORT || 5000;

// // middlewares
// app.use(express.json());
// app.use(express.urlencoded({ extended: false }));
// app.use(express.static("public"));
// app.use('/api/items', require("./routes/items"));
// app.use('/api/payment', cors(), require("./routes/payment"));

// <<<<<<< HEAD
// // // connect to the mongodb database
// // connectDB();
// =======
// // connect to the mongodb database
// connectDB()
// >>>>>>> 72a9267b7a3b1df6d6f359a4523912063f0d70e8

// // app.listen(PORT, () => console.log("Server is running on port ", PORT));

// <<<<<<< HEAD
// // Assuming your model is defined in a separate file
// const Item = require("./models/itemsModel");

// // Create a new item document
// const newItem = new Item({
// name: "Sample Item",
// category: "Sample Category",
// color: "Sample Color",
// type: "Sample Type",
// description: "Sample Description",
// price: 100,
// size: ["Small", "Medium", "Large"],
// highlights: ["Highlight 1", "Highlight 2"],
// detail: "Sample Detail",
// image: ["image1.jpg", "image2.jpg"],
// });

// // Save the new item document to MongoDB
// newItem.save()
// .then((result) => {
// console.log("Item added successfully:", result);
// // Disconnect from MongoDB after insertion
// mongoose.disconnect();
// })
// .catch((error) => {
// console.error("Error adding item:", error);
// // Disconnect from MongoDB if an error occurs
// mongoose.disconnect();
// });
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const app = express();
const User=require("./models/User")

mongoose.connect('mongodb+srv://root:[email protected]/ecom', {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log('Connected to MongoDB');
})
.catch((error) => {
console.error('Error connecting to MongoDB:', error);
});

const session = require("express-session");
//config/objects used in sessions
const sessionConfig = {
secret: "thisisshiuldbeabettersecret!",
resave: false,
saveUninitialized: true,
cookie: {
//by default rahta then to
httpOnly: true,
//expiration dates
expires: Date.now() + 1000 * 60 * 60 * 24 * 7,
maxAge: 1000 * 60 * 60 * 24 * 7,
},
};
app.use(express.json());
app.use(cors());
const passport = require("passport");
const LocalStragery = require("passport-local");
//to use sessions
app.use(session(sessionConfig));
//to use passport
app.use(passport.initialize());
app.use(passport.session());
//hash kar dega password using 'PBKDf2' algorithm
passport.use(new LocalStragery(User.authenticate()));
//to store in sessions
passport.serializeUser(User.serializeUser());
//to remove from session while logout
passport.deserializeUser(User.deserializeUser());

const user_routes = require("./routes/User");
app.use("/api/user", user_routes);


const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});

// >>>>>>> 72a9267b7a3b1df6d6f359a4523912063f0d70e8
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.