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

backend-mocker-npm-package

v2.0.7

Published

A package for rapid backend development, providing CRUD API generation with customizable schema support for MongoDB and PostgreSQL.

Downloads

39

Readme


Welcome to Backend Mocker NPM Package 🚀

Backend Mocker

Hey there, fellow developer! Are you tired of spending hours setting up your backend infrastructure every time you start a new project? Say hello to Backend Mocker - your ultimate companion for rapid backend development!

🌟 Additional Features in Version 2.0:

  • Support for PostgreSQL: Now you can choose between MongoDB and PostgreSQL for your backend database.
  • Dynamic Table Name: Define your own table name for PostgreSQL schemas, giving you more flexibility in database management.
  • Custom Port: Set a custom port to run your backend server on, providing greater control over your development environment.
  • Improved Error Handling: Enhanced error messages to guide you through troubleshooting and debugging, ensuring a smoother development experience.

🌟 Features :

  • Easy Setup: Get your CRUD API up and running in the blink of an eye.
  • Customizable Schema: Shape your data just the way you want it. No more rigid structures!
  • Automatic ID Generation: Sit back and relax while we handle the IDs for you.
  • Robust Error Handling: Friendly error messages to guide you through the dark tunnels of debugging.
  • Built-in Counters: Counting made simple. Manage your data effortlessly.
  • Custom Port: Create a custom port to run the backend on. If not specified, the port will be automatically set to 3000.

Installation Made Easy 🛠️

Create a project directory and in that directory execute these below two commands in terminal

npm init -y
npm install backend-mocker-npm-package

Quick Setup in Seconds ⏱️

After downloading the package, create a .js file:

*- If using MongoDB:

// Code snippet for MongoDB setup
const BackendMocker = require("backend-mocker-npm-package");

// before pasting below line  install mongoose from your terminal(in project directory) by typing  npm install mongoose
const mongoose = require("mongoose");
const tableName = "name-it-as-you-want";

// Below is schema designed for mongodb
// your customSchema variable should compulsorily contain the  line for it to implement autoincremented feature .
// You can make changes in schema as you want (try googling or use chatgpt for help ).
// Just make sure that _id  lin is always present in schema 
 
  //_id: { type: Number, required: true },


const customSchema = new mongoose.Schema({
  _id: { type: Number, required: true },
  name: String,
  RollNo: String,
  Age: String,
  Course: String,
  Date: Date,
  PhoneNo: Number,
});

// set a custom port , optional
const customPort = 4000;

const mongoConnectionString = "your-mongo-db-string";

const back = new BackendMocker(
  mongoConnectionString,
  null,
  customSchema,
  tableName,
  customPort
);
back.startServer();

*- If using PostgreSQL:

// Code snippet for PostgreSQL setup
const BackendMocker = require("backend-mocker-npm-package");

// before pasting below line make sure you install sequelize by typing   npm install sequelize  in terminal in your project directory
const { DataTypes } = require("sequelize");

const tableName = "name-it-as-you-want";

// define as you want
const customSchema = {
  name: DataTypes.STRING,
  RollNo: DataTypes.STRING,
  Age: DataTypes.STRING,
  Course: DataTypes.STRING,
  Date: DataTypes.DATE,
  PhoneNo: DataTypes.STRING,
};

const customPort = 4000;

const postgresConnectionString =
  "postgresql://usernme:password@localhost:port/database";

const back = new BackendMocker(
  null,
  postgresConnectionString,
  customSchema,
  tableName,
  customPort
);
back.startServer();

//  now your backend is ready just click start

API Endpoints 📡

  • GET /get: Retrieve all data.
  • GET BY ID /get/:id: Retrieve single data tuple by id .
  • POST /new: Create new data.
  • PATCH /update/:id: Update data by ID.
  • DELETE /delete/:id: Delete data by ID.

💡 No Schema? Just Want to Test API for Frontend!

If no schema is provided, the app will create a default schema. ONLY FOR MONGODB

// Code snippet for default schema setup

const book = {
  title: String,
  author: String,
  publishedDate: Date,
};
// this will be automatically created if you donot provide a schema currently only supported for mongodb database

With Backend Mocker, you're not just building a backend - you're unleashing your creativity and powering your projects to new heights!

🚀 Ready to Launch?

Dive into the world of rapid backend development with Backend Mocker and watch your projects soar!

Got it! Here's the revised "Let's Connect" section:

🌐 Let's Connect!

Connect with me through:

Feel free to reach out for any questions, ideas, or just to chat! Contributions are welcome. Happy coding! 🎉