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

satyaminfo_node_js_crud_mysql

v1.1.0

Published

CRUD API With Validation In Node JS

Downloads

12

Readme

satyaminfo CRUD in node.js useing mysql!

This package is use to create [CRUD API Operation] in node js with [API Validation], this package is easy to use and operate also you can modify table or fields as per your requirement using the following step, visit my website for my info satyaminfo.in

Install

# with npm
npm install satyaminfo_node_js_crud_mysql

# with npm 
npm install express mysql dotenv sequelize body-parser joi joi-objectid

Usage

Create a .env file in the root directory of your project. Add environment-specific variables on new lines in the form of NAME=VALUE. For example:

DB_HOST=localhost
DB_USER=root
DB_PASSWORD=s!mpl3
DB_NAME=demo_db

Create a config/config.js file in the root directory of your project.

Your config.js file like this


const mysql=require('mysql');
const dotenv=require('dotenv').config();
var con={
  host: process.env.DB_HOST,
  user:process.env.DB_USER,
  password:process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  dialect: "mysql",
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  }
};
var db_con=mysql.createConnection({
  host: process.env.DB_HOST,
  user:process.env.DB_USER,
  password:process.env.DB_PASSWORD,
  database: process.env.DB_NAME
});

module.exports.con=con;
module.exports.db_con=db_con;

Create a crud_request/guest.js file in the root directory of your project.

Your guest.js file is like this

const {mysqlCrudNode}=require('satyaminfo_node_js_crud_mysql');
const {db_con} = require('../config/config');

mysqlCrudNode({
    table_name:'guest',
    table_fields:{
        name:'STRING',
        email:'STRING',
        password:'TEXT',
        phone:'INTEGER'
        },
    valid_fields:{
        name:"required|min:2|max:10|alphanum",
        email:"email|required",
        password:"required",
        phone:"required"
    },con:db_con
});
$ node crud_request/guest.js

Create a server.js file in the root directory of your project. for Run API Use On postman

Your server.js file is like this

const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const userRouter = require('./routes/api');

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
 
// parse application/json
app.use(bodyParser.json())

app.use('/api', userRouter);
const port=8081
app.listen(port, console.log(`server is listen on port ${port}`)); 

Options

In this package 3 Options are there

  • table_name here is your table name
  • table_fields here is your table fields name list
  • valid_fields here is your table fields multiple vaidation list