Code Monkey home page Code Monkey logo

faker-data-api's Introduction

FakerJS Backend

This is a backend server for generating fake data using the FakerJS library. It allows you to generate SQL insert statements for a given table, with a specified number of rows and columns.

Usage

To use the server, simply run npm install and then npm start in your terminal. By default, the server will listen on port 5000. You can change the port by setting the PORT environment variable to a different value.

Step 1


Once the server is running, you can send a POST request to http://localhost:5000/ with the following JSON body:

{
    "tableName": "example",
    "numberOfRows": 55,
    "columns": [
        { "name": "id", "type": "int", "constraint": "primary key"},
        { "name": "first name", "type": "first_name", "constraint": "not null"},
        { "name": "email", "type": "email", "constraint": "unique"}
    ]   
}

This will generate a file named insertExample.sql in the server's output directory, containing SQL insert statements for the specified table and columns. The server will respond with a JSON object containing a URL to the generated file:

{
    "url": "http://localhost:5000/file/insertExample.sql"
}

Note that for column constraints, you should put spaces between each keyword. For example, length=255 will not work, but length = 255 will. Similarly, check in('hello','world') should be written as check in ( 'hello' , 'world' ).

Cleanup

Currently, you will need to manually delete the generated files from the output directory after downloading or copying them.I'm working on adding automatic cleanup functionality in a future release.

Default Port

By default, the server uses port 5000. Other ports you can use for this kind of application include 8000, 8080, or 9000. However, you can choose any port that is not already in use on your system.

faker-data-api's People

Contributors

rickaprincy avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.