Code Monkey home page Code Monkey logo

axe-api's Introduction

Next Generation Rest API Framework

Axe API has great documentation. Please check it out in here.

What Is Axe API?

Axe API is a Node.js framework that helps you create a Rest API in a declarative way quickly. ๐Ÿช“

It has been written with TypeScript and built on Express and Knex.js.

Motivation

You would understand easily what you are going to code when you look at a bunch of database tables and their relations with each other, more or less. Because, as a developer, you already know that Rest API best practices.

Therefore I asked a simple question more than two years ago;

"Can we create a Rest API in a declarative way, and handle all endpoints automatically?"

As a result of our work, we have a framework called Axe API that provides a solution to analyze your API definitions and handle all of the endpoints.

Basically, you define your models which are your API definitions, and Axe API analyzes them and processes all of your endpoints instead of you.

Showcase

Let's look at an example!

You have two database tables; users and posts. These tables are related to each other and we aim that create a Rest API for basic CRUD endpoints.

The only thing to do is creating models like the following example;

class User extends Model {
  get fillable(): string[] {
    return ["email", "name", "surname"];
  }

  posts(): IRelation {
    return this.hasMany("Post", "id", "user_id");
  }
}
class Post extends Model {
  get fillable(): string[] {
    return ["title", "description"];
  }

  user(): IRelation {
    return this.belongsTo("User", "user_id", "id");
  }
}

Tada! ๐ŸŽ‰

Your API is ready to process all of the following endpoints after those model definitions are done.

  • [GET] api/users
  • [POST] api/users
  • [GET] api/users/:id
  • [PUT] api/users/:id
  • [DELETE] api/users/:id
  • [GET] api/users/:userId/posts
  • [POST] api/users/:userId/posts
  • [GET] api/users/:userId/posts/:id
  • [PUT] api/users/:userId/posts/:id
  • [DELETE] api/users/:userId/posts/:id

This is the main power of Axe API. Nevertheless, it is not limited only to this power. There are many more features are waiting to discover. ๐Ÿ’ก

Installation

Using Axe API in an application is very easy. We've created a CLI tool for you; axe-magic.

You can create a new Axe API project by using axe-magic. But first, you can install it in your development environment. When you installed it, you can be able to access axe-magic command via CLI. You can use the following command to install axe-magic to your machine;

$ npm i -g axe-magic
$ axe-magic --version
1.0.0

After that, creating a new project is very easy. Just you can execute the following command;

$ axe-magic new my-api

This command will pull axe-api-template project to your current directory with a new name, my-api.

To install your project's depencies, you can execute the following commands in the root directory;

$ cd my-api
$ npm install

To serve this application, you can execute the following command;

$ npm run start:dev

After that, your first Axe API application will be running in localhost:3000.

You will see the following API response if you visit localhost:3000.

{
  "name": "AXE API",
  "description": "The best API creation tool in the world."
}

If you can see that response, it means that your project is running properly.

Documentation

Axe API has great documentation. Please check it out in here.

Contributors

License

MIT License

axe-api's People

Contributors

ozziest avatar dependabot[bot] avatar saracalihan avatar burakack avatar arifkarakilic avatar samantatarun 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.