Code Monkey home page Code Monkey logo

docs's Introduction

Axe API is a TypeScript-based Node.js framework designed to eliminate the need for repetitive tasks associated with common elements while allowing developers to focus on custom logic.

It offers a comprehensive structure for your API, including numerous features and best practices that will save you time.

Video Introduction

Documentation

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

License

MIT License

docs's People

Contributors

arifkarakilic avatar berkaltiok avatar dependabot[bot] avatar ozgur-shape avatar ozziest avatar saracalihan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

docs's Issues

Better development environment

Motivation

Axe API is a great tool. But it is hard to maintain currently. Because it is written in TypeScript as a framework. We should use the compiled code of Axe API, in another application. Basically, as the Axe API Core Team, we should provide the best development experiences to the developers.

What do we need?

First and foremost, we need good, practical documentation. It must be short as possible. But also it should contain all the details of the development environment.

The following acceptance criteria should be done;

  • Easy preparation: Developers should be able to create their development environment in the terminal command.
  • Well documented: Developers should be able to access all of the development information. Guides. commands, FAQ, etc.
  • Easy testing: Developers should be able to execute all tests (unit, integrations etc.) with one command.

How we implemented it?

  • We should use the dev-api repository as the basic template.
  • We should use dev-kit name in the repository.
  • The project should have all of the commands internally.
  • We add full documentation. (Starting in the documentation could be useful to make it super simple)

Bugs

  • static keyword in the fillable and validation sections

  • Fixed UserHooks (password_salt, password_hash field, and delete the password property)

import bcrypt from "bcrypt";

const onBeforeInsert = async ({ formData }) => {
  // Genering salt
  formData.password_salt = bcrypt.genSaltSync(10);
  // Hashing the password
  formData.password = bcrypt.hashSync(
    formData.password,
    formData.password_salt
  );
};

export { onBeforeInsert };
  • IoC documentation
  • Add simple login enpoint
import { IoC } from "axe-api";
import bcrypt from "bcrypt";
import jwt from "jsonwebtoken";

const login = async (req, res) => {
  const { email, password } = req.body;
  const Database = await IoC.use("Database");
  const user = await Database.table("users").where("email", email).first();

  if (!user) {
    return res.status(404).json({
      error: "User not found",
    });
  }

  const userHash = bcrypt.hashSync(password, user.password_salt);
  if (userHash !== user.password) {
    return res.status(404).json({
      error: "User not found",
    });
  }

  const token = jwt.sign({ userId: user.id }, process.env.APP_KEY);
  return res.json({ token });
};

export default async ({ app }) => {
  app.post("/api/login", login);
};
  • isLogged middleware example
import jwt from "jsonwebtoken";

export default (req, res, next) => {
  const { authorization } = req.headers;
  if (!authorization) {
    return res.status(401).json({ error: "Unauthorized" });
  }

  try {
    const decoded = jwt.verify(
      authorization.replace("Bearer ", ""),
      process.env.APP_KEY
    );
    req.auth = decoded;
  } catch (error) {
    return res.status(401).json({ error: "Unauthorized" });
  }

  next();
};

Missing docs

Some of features and structures are not documented yet.

  • Configuration
  • Custom Routes
  • Middlewares
  • Migrations
  • Testing
  • Routing documentations: /docs, /docs/routes

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.