Coder Social home page Coder Social logo

ullaskunder3 / meriadb-nodejs-restapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4 KB

This project is a simple REST API that allows you to manage user records. It is built using Node.js and MariaDB. You can create, retrieve, update, and delete user data using the provided endpoints.

JavaScript 100.00%
crud-api db expressjs mariadb thunderclient vscode

meriadb-nodejs-restapi's Introduction

User REST API

This API allows you to perform CRUD operations (Create, Read, Update, Delete) on user records stored in a MariaDB database.

Base URL

http://localhost:3000

Resources

User

Represents a user record in the database.

Attributes

  • id (integer): The unique identifier of the user.
  • name (string): The name of the user.
  • email (string): The email address of the user.

Endpoints

Create a User

Create a new user record.

  • URL: /data

  • Method: POST

  • Request Body:

    {
      "name": "ullas kunder",
      "email": "[email protected]"
    }
  • Response:

    • Status: 201 Created
    • Body:
      {
        "message": "Record created successfully"
      }

Get All Users

Retrieve all user records.

  • URL: /data
  • Method: GET
  • Response:

Update a User

Update an existing user record.

  • URL: /data/:id

  • Method: PUT

  • Request Body:

    {
      "name": "Updated Name",
      "email": "[email protected]"
    }
  • Response:

    • Status: 200 OK
    • Body:
      {
        "message": "Record updated successfully"
      }

Delete a User

Delete an existing user record.

  • URL: /data/:id
  • Method: DELETE
  • Response:
    • Status: 200 OK
    • Body:
      {
        "message": "Record deleted successfully"
      }

Make sure rename .env-local to .env and replace current info with your db credientials

If you are using Thunder Client, you can find the API collection provided in the project files.

make sure background db service is up and running

mysql -u root -p

Once you are logged in to the MariaDB server, execute the following command to display the list of existing databases:

show databases;

Create a new database named user_restapi by executing the following command:

create database user_restapi;

After creating the database, switch to the newly created database using the following command:

MariaDB [(none)]> use user_restapi

Creating the app_user Table

Database changed
MariaDB [user_restapi]> CREATE TABLE app_user(
-> id INT PRIMARY KEY AUTO_INCREMENT,
-> name VARCHAR(255) NOT NULL,
-> email VARCHAR(255) NOT NULL
-> );
Query OK, 0 rows affected (0.040 sec)

MariaDB [user_restapi]>
CREATE TABLE app_user (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(255) NOT NULL,
  email VARCHAR(255) NOT NULL
);

meriadb-nodejs-restapi's People

Contributors

ullaskunder3 avatar

Watchers

 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.