Giter Club home page Giter Club logo

kitajs's Introduction

Using this package? Please consider donating to support my open source work โค๏ธ
Help kitajs grow! Star and share this amazing repository with your friends and co-workers!


Kita JS logo


Discord License Codecov Last commit Stars


๐ŸŒท KitaJS

KitaJS is a routing meta framework.


๐ŸŽ‰ Kita is officially Stable! Try it out today!


Star History

Star History Chart

All Thanks To Our Contributors:

kitajs's People

Contributors

arthurfiorette avatar dependabot[bot] avatar devzolo avatar github-actions[bot] avatar joao-cabral avatar zmarques avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kitajs's Issues

Improve documentation.

Currently, lack of documentation is the major problem of Kita.

  • Finish all sections
    • Routing
    • Learn By building
      • setup
      • api routes
      • frontend
    • Learn by example
      • file uploads
      • authentication
      • logging
    • Guide
    • Templating (Should we have this? Probably fit better in kitajs/html)
    • Integrations
      • auth
      • (what more?)

I wrote the entire kita.js.org documentation alone. I'm 100% sure there will be grammar mistakes that can be easily fixed.

Site: https://kita.js.org
Documentation: https://github.com/kitajs/docs

  • Have at least 3 grammar revisors.

Better HTTP error detection

The same way a HTTP route can read throw clauses to add errors, providers should also include throw clauses it the route they are used.

Maybe custom errors should also be added by inferring their type

@url jsdoc is not working

/** @url /users */
export function get() {}

generates the following schema:

{
  "openapi": "3.1.0",
  "info": {
    "title": "API Reference",
    "description": "Powered by [Scalar](https://scalar.com/) & Generated by [KitaJS](https://kita.js.org/)",
    "version": "1.1.22"
  },
  "components": { "schemas": {} },
  "paths": {
    "/users": {
      "get": {
        "operationId": "getIndex",
        "responses": {
          "2XX": {
            "description": "Default Response",
            "content": {
              "application/json": { "schema": { "type": "boolean" } }
            }
          }
        }
      }
    }
  }
}

Support for wildcard routes

Using [...].ts should work as a fastify wildcard route. Currently this is the only hacky way to do it:

/**
 * @url /api/a/*
 */
export function get({ url, params }: FastifyRequest) {
  return { url, params };
}

returns = {
  "params": {
    "*": "asdasd/asd"
  },
  "url": "/api/a/asdasd/asd"
}

The Path parameter should also validate when its being used outside a /[named]/ route and a variant of it should be defined to get the request.params['*'] when the route is wildcard.

`Environment` provider

Add a /providers/environment.ts specific provider which should only default export a interface which its json schema should be parsed by env-schema.

// providers/environment.ts

export default interface Environment {
  /**
   * My description
   *
   * @default '...'
   * @minLength 32
   * @maxLength 64
   */
  MY_ENV: string;
}

export const options: EnvSchemaOpt = {
  dotenv: true
};

Multipart support

Needs integration with @fastify/multipart should also be done. MultipartFile and SavedMultipartFile.

Unusual providers registration order

Currently, providers must be prefixed with number like 1z.ts and a.ts when a.ts used z.ts as parameter, otherwise a.ts would throw because z was not registered yet.

Warn on file without routes

KitaJS should emit warnings on files inside routes that does not exports any route method and/or exported functions that does not represent any routes.

Provider Parameters

Providers should have the hability to provide generic parameters.

export function get(a: MyGenericProvider<'a', 2, true, {a:1}>) {}

Should have this definition:

export default function (params: ProviderParameters) {
  console.log(params) // ['a', '2', 'true', '{a:1}']
}

If possible, parsed JSON values should be cool.

export default function (params: ProviderParameters) {
  console.log(params) // ['a', 2, true, { a: 1 }]
}

Improve route parameters

  • Req and Res should change to the defaults FastifyRequest and FastifyResponse
  • Simplify Query type, we shouldn't break types when runtime execution works.
  • Remove this parameter usage, it gets messy when calling routes programatically. This resolves to void, which doesn't impact on calling the routes manually
  • Add tests and type tests for every parameter type.

Force `async` routes

Libraries like prisma may extend the promise return type, e.g PrismaPromise and it cannot be unwrapped into a real promise, making the return type incorrect.

Awaited should be used defined in the controller response type.

export type ControllerResponse = ReturnType<typeof controller>;

export declare function controllerHandler(
  req: FastifyRequest,
  reply: FastifyReply
): Promise<Awaited<ControllerResponse>>;

should be

export type ControllerResponse = Awaited<ReturnType<typeof controller>>;

export declare function controllerHandler(
  req: FastifyRequest,
  reply: FastifyReply
): Promise<ControllerResponse>;

Otherwise using ControllerResponse is impractical without adding Awaited everywhere.

Provider hooks

We should be able to use application hooks like the following:

// providers/test.ts

export default function() : Data {
}

// Registered as the fastify onRouteHandler
export function onRoute() {

}

// ... So on for 'onRegister', 'onReady', 'onListen', 'onClose', 'preClose'

`kita create` command needs a test suite.

After #365 (a bug that only happened on windows), its clear that it requires a full test suite across all 3 operating systems.

Our only problem is to ensure a copy of @kitajs/runtime instead of linking, otherwise the generated folder will get updated and break all other packages tests.

Automatically add properties to all required plugins.

Having the end user to manually register plugins like the following example is bad:

// Register fastify sensible to allow error handling
app.register(fastifySensible, {
  sharedSchemaId: "HttpError",
});

// Registers fastify's swagger support
app.register(fastifySwagger);
app.register(fastifySwaggerUi);

// Registers the generated kita plugin
app.register(Kita);

Every plugin kita needs, depending on providers/parameters usage, we should add the typings and the object as properties, like the following example:

app.register(Kita, {
  swagger: {},
  swaggerUi: {},
  sensible: {},

  // If other parameters like websocket are used, a `websocket` property should be added in case
  // the user wants to change some configuration. We should also consider good defaults.
  // websocket: {}
})

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.