npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mongose-crud-templete

v1.0.0

Published

This project is an Express.js mongoose and folder setup template for building a backend server that performs CRUD (Create, Read, Update,Delete)operations using a MongoDB database.

Downloads

5

Readme

mongoose crud templete

npm

This project is an Express.js mongoose and folder setup  template for building a backend server that performs CRUD (Create, Read, Update,Delete)operations using a MongoDB database.

Installation

🖱 # run this command to setup 
 npm i mongoose crud templete
 npm i express cors bcrypt dotenv nodemon mongoose
🖱# Create the ".env" file and copy the "example .env" data to the .env file and replace the "URLS"
🖱# package.json file "dev": "nodemon server.js",
 npm run dev

🔑 Key Features:

⚙️ Database Connection:

mongodb atlas
or
mongodb compus
"Express.js Server:"
Sets up an "Express.js" server to handle HTTP requests on specified routes.
"CRUD operations:"
Routes are defined for basic "CRUD" operations on a hypothetical "Users" collection via Mongoose.
"Endpoints:"
GET /: Returns a welcome message indicating that the backend is operational.
GET /api/getAllData: A placeholder endpoint for fetching a list of users.
GET /getSingleData/:id: A placeholder endpoint for fetching details of a specific user by ID.
POST /api/create: A placeholder endpoint for creating a new user.
PUT/PATCH /api/updateData/:id: A placeholder endpoint to update a specific user by ID.
DELETE /api/idBaseDataDelete/:id: A placeholder endpoint for deleting a user by ID.
"Global Error Handling:"
Basic error handling is incorporated to catch and log any errors during database connection and server operation.
📋 Note : Ensure that a [.env file] set up, and replace the all Credentials.

Description:

optional

if(!userData){ 
         return res.status(404).json({msg: "User data not found"});
}

👇 মানে হচ্ছে যদি userData এর মধ্যে কোনো data আসেনি বা আগে থেকেই data নেই তাহলে json ফরম্যাটে একটা এরর দিবে। It means if there is no data in userData or there is no data already then it will give an error in json format.

controller:

req.body

👇 ক্লায়েন্ট সাইট থেকে যে ডাটা গুলো পাঠাবো সেই ডাটাগুলো req.body মধ্যে আসবে। আবার req.body এর ডাটা গুলো স্কিমা মধ্যে পাঠাবো। আবার স্কিমা সেই ডাটা গুলো ভ্যালিট কি না চেক করে mongodb এর কালেকশন এর মধ্যে পাঠাবে।

const hashPassword = await bcrypt.hash(req.body.password, 10)

👇 এই লাইনে, ব্যবহারকারীর পাসওয়ার্ডকে bcrypt হ্যাশিং এর মাধ্যমে হ্যাশ করা হয়। এটি কেয়ার পাসওয়ার্ড হ্যাশিং এর জন্য 10 রাউন্ড ব্যবহার করে।

  req.body.password = hashPassword 

এই লাইনে, হ্যাশিং করা পাসওয়ার্ডটি ব্যবহারকারীর পাসওয়ার্ড ফিল্ডে প্রতিস্থাপন করা হয়।

আপনি যেই api নিয়ে কাজ করবেন সেটা সেই controller folder গিয়ে কাজ করবেন। মানে যদি আপনার একটা api কে Delete, post, get, getSignData/: id, put /patch করতে লাগে/লাগতেছে তাহলে সেই কন্ট্রোলার ফোল্ডার এ গিয়ে একজায় Delete , post , get,getSignData/: id, put /patch এর কাজটি করবেন । এবং server.js এ গিয়ে

app.use("/api" , যেই controller  তা যে router  folder  require করেছি সেই  router  টা  এখানে  require  করে  দিবো। )

server এ একবার সেই api router app.use এ বসালে ( Delete , post , get, getSignData/: id , put /patch) এর সব কাজ করতে পারবে।

Contact:

Linkedin - Tomor-chandra-roy Email- [email protected]

Acknowledgments

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!