Git Product home page Git Product logo

endrun's Introduction

Hono

GitHub Workflow Status GitHub Bundle Size Bundle Size Bundle Size npm type definitions GitHub last commit

Endrun

Endrun is a simple and powerful web API framework that dynamically generates endpoints and Swagger documentation based on database models using Prisma ORM.

Features

  • Dynamic Endpoint Generation: Automatically create endpoints for CRUD operations (GET, POST, PUT, DELETE) for each database model defined in Prisma, without the need for manual code writing.

  • Automatic Swagger Documentation: Generate Swagger documentation automatically for your APIs, specifying the operations available in each endpoint and the parameters required.

  • Prisma ORM Compatibility: Endrun works seamlessly with Prisma ORM for database management, providing a modern and efficient way to interact with your data.

  • Simplicity and Ease of Use: With its simple and user-friendly design, Endrun allows developers to quickly and confidently create powerful and stable APIs, without the need for repetitive code or unnecessary complexities.

Usage

To get started with Endrun, follow these simple steps:

  1. Install Endrun using npm:

npm install endrun dotenv prisma

vbnet Copy code

  1. Define your database models using Prisma.

  2. Import Endrun into your project and configure your endpoints.

  3. Start your server and enjoy the power and simplicity of Endrun!

Example

Here's a simple example of how to use Endrun to create an API endpoint:

// index.ts

import {Endrun} from 'endrun';
import dotenv from 'dotenv';

dotenv.config();

const PORT = process.env.PORT || 3030;

new Endrun().startServer(PORT);

and add the database address in the .env file :

# .env

DATABASE_URL=postgres://postgres:postgres@localhost:5432/endrun

you can add custom routes to Endrun class :

new Endrun((router, db) => [
  // base url /api
  // If /products exists, it overrides it; otherwise, it creates a new endpoint.
  router.get("/products", async (req, res) => {
    const result = await db.product.findMany();
    res.json(result);
  }),
  router.post("/products", async (req, res) => {
    const result = await db.product.create({
      data: await req.body, // An error is returned because we added that path to the withoutBodyParser !
    });
    res.json(result);
  }),
],{
  searchableModels : ["Product"],
  withoutBodyParser: ["/products"]
}).startServer(PORT);

endrun's People

Contributors

mooudmohammady avatar

Stargazers

Chris K. Thomas avatar Iman avatar jist avatar sadra soleimani avatar  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.