Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-backpack

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-backpack - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

15

example.md

@@ -38,17 +38,2 @@ ```

// Define a route for the "hello world" message
app.get("/subject", async (req, res) => {
try {
// Create a new message document
const newMessage = new Message({ message: "Hello world!" });
await newMessage.save();
// Return the message document as JSON
res.json(newMessage);
} catch (err) {
console.error(err);
res.status(500).json({ message: "Internal server error" });
}
});
// Start the Express app

@@ -55,0 +40,0 @@ const port = process.env.PORT || 3000;

2

package.json
{
"name": "mongoose-backpack",
"version": "0.2.1",
"version": "0.2.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -53,15 +53,43 @@ ```

const express = require("express");
const router = express.Router();
const User = require("../models/user");
const authRoutes = require("./moduleRoute/auth");
const mongoose = require("mongoose");
const { mongooseRouteName } = require("mongoose-backpack");
// auth routes
router.use("/", authRoutes);
// Create a new Express app
const app = express();
// Mount the router for the "people" route
router.use("/people", mongooseRouteName("people", User));
// Connect to the MongoDB Atlas cluster
mongoose
.connect(
"mongodb+srv://fluxe0074:fluxe0074@cluster1.48j1fuf.mongodb.net/test",
{
useNewUrlParser: true,
useUnifiedTopology: true,
}
)
.then(() => {
console.log("Connected to MongoDB Atlas");
})
.catch((err) => {
console.error("Error connecting to MongoDB Atlas", err);
});
module.exports = router;
// Define a schema for the "message" collection
const messageSchema = new mongoose.Schema({
name: { type: String, required: true },
message: { type: String, required: true },
image: { type: String, required: false },
file: { type: String, required: false },
});
// Create a model for the "message" collection
const Message = mongoose.model("Message", messageSchema);
app.use("/", mongooseRouteName("people", Message));
// Start the Express app
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Server started on port ${port}`);
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc