db-config-generator
v1.0.0
Published
A Node.js utility to generate database configuration files with custom MongoDB connection strings
Maintainers
Readme
DB Config Generator
A Node.js utility to generate database configuration files with custom MongoDB connection strings.
Installation
npm install db-config-generatorUsage
const makeFiles = require('db-config-generator');
// Run the generator
makeFiles();What it does
This package helps you quickly set up MongoDB database configuration files by:
- Creating a
utilsdirectory in your project - Reading a template database configuration file
- Prompting you for your MongoDB connection string
- Generating a customized
db.jsfile with your connection string
Features
- Interactive command-line interface
- Automatic directory creation
- Template-based configuration generation
- MongoDB/Mongoose ready configuration
Example
When you run the package, it will:
- Ask for your MongoDB connection string
- Create a
utils/db.jsfile with your configuration - Replace the placeholder with your actual connection string
The generated file will look like:
const mongoose = require("mongoose");
const dotenv = require("dotenv");
dotenv.config();
function connectDB() {
mongoose
.connect(`your-mongodb-connection-string/uberCLONE`)
.then(() => console.log("connected to mongodb"))
.catch((err) => console.log(err));
}
module.exports = connectDB;Requirements
- Node.js >= 14.0.0
- MongoDB connection string
License
MIT
