Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

localbased

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

localbased

Localbased is an intuitive no-code tool designed to assist developers, particularly frontend engineers, in quickly setting up a REST API for communicating with databases on their local machines. It aims to simplify the process of creating a backend server

  • 1.3.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

localbased

Localbased is an intuitive no-code tool designed to assist developers, particularly frontend engineers, in quickly setting up a REST API for communicating with databases on their local machines. It aims to simplify the process of creating a backend server and accessing dynamic data, enabling frontend developers to create full-stack side projects without the need to worry about building a REST API or handling database interactions.

Installation

npm i -g localbased

Initialization

In your current working directory run localbased start --port [port] this command starts the server on the specified port else the server runs on a default port of 2048.

E.g

localbased start --port 4000 this command starts the server on the specified port 4000

localbased start this command starts the server on the default port 2048

Endpoints

1. Create

  • Description: Creates a record in the database.

  • Endpoint: /:collectionName/create

  • Method: POST

  • Request Body:

    {
      ...data
    }
    
  • Sample Request: POST /users/create

    {
      "name": "owoade anuoluwapo",
      "email": "owoade@once.com",
      "password": "manager"
    }
    
  • Sample Response

    {
        "status": "success",
        "response": {
            "collectionName": "users",
            "data": {
                "_id": "51130271-1839-492b-b50b-1cca2ff19aa2",
                "name": "owoade anuoluwapo",
                "email": "owoade@once.com",
                "password": "manager",
                "timestamps": {
                    "createdAt": "2024-01-15T00:22:49.430Z",
                    "updatedAt": "2024-01-15T00:22:49.430Z"
                }
            }
        }
    }
    

2. Get All

  • Description: Retrieves all records in a collection.
  • Endpoint: /:collectionName/get/all
  • Method: GET
  • Query parameters:
ParameterTypeDescription
pagenumberThis enables pagination of data, facilitating the retrieval of specific subsets for more efficient handling of large datasets. The default value is 1.
limitnumberThis refers to the amount of to be returned per request. The default value is 50.
orderstringThis is the order in which the result will be returned and can either be of value a which denotes ascending order or d descending order. The default value is a
  • Sample Request: GET /users/get/all?order=a&limit=3&page=1

  • Sample Response

    {
    "status": "success",
    "response": {
        "collectionName": "users",
        "count": 359,
        "data": [
            {
                "_id": "cb405221-2266-4d87-9939-ded1fbd3eab7",
                "username": "Mary",
                "password": "kemi",
                "timestamps": {
                    "createdAt": 1705267312054
                }
            },
            {
                "_id": "a4bd932a-1f8e-4ff8-84c5-95e800326e1c",
                "username": "Mary",
                "password": "kemi",
                "timestamps": {
                    "createdAt": 1705267325168
                }
            }
        ]
    }
    }
    

3. Get one

  • Description: Gets one record from the database.
  • Endpoint: /:collectionName/get/single/:id
  • Method: GET
  • Route parameters:
ParameterTypeDescription
idstringThis is the of the record to be fetched.
  • Sample Request: GET /user/get/single/cc6443a8-7633-45d4-b6a1-4335c3c59f81

  • Sample Response

     {
      "status": "success",
      "response": {
          "collectionName": "users",
          "data": {
              "_id": "cc6443a8-7633-45d4-b6a1-4335c3c59f81",
              "name": "owoade anuoluwapo",
              "password": "manager",
              "timestamps": {
                  "createdAt": "2024-01-14T22:55:53.010Z",
                  "updatedAt": "2024-01-14T23:16:22.222Z"
              },
              "is_admin": true
          }
      }
    }
    

4. Update

  • Description: Updates a record in the database.

  • Endpoint: /:collectionName/update/:id

  • Method: PATCH

  • Request Body:

    {
      "update": {
        ...updates
      }
    }
    
  • Sample Request: PATCH /user/update/cc6443a8-7633-45d4-b6a1-4335c3c59f81

    {
      "update": {
       "is_admin": true
      }
    }
    
  • Sample Response

     {
      "status": "success",
      "response": {
          "collectionName": "users",
          "data": {
              "_id": "cc6443a8-7633-45d4-b6a1-4335c3c59f81",
              "name": "owoade anuoluwapo",
              "password": "manager",
              "timestamps": {
                  "createdAt": "2024-01-14T22:55:53.010Z",
                  "updatedAt": "2024-01-14T23:16:22.222Z"
              },
              "is_admin": true
          }
      }
    }
    

5. Delete

  • Description: Deletes a record from the database.

  • Endpoint: /:collectionName/delete/:id

  • Method: DELETE

  • Sample Request: DELETE /user/delete/cc6443a8-7633-45d4-b6a1-4335c3c59f81

    {
      "update": {
       "is_admin": true
      }
    }
    
  • Sample Response

    {
      "status": "success",
      "response": {}
    }
    

Error Response

An error response can be returned for a number of reasons, below is an example of an error response that can be returned. Note that all error response structure are the same.

{
  "status": "error",
  "response": false,
  "reason": "Document not found"
}

...Start Building 🚀🚀

Created with 🧡 by Owoade

Keywords

FAQs

Package last updated on 17 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc