GithubHelp home page GithubHelp logo

fuale / laravel-router-provider Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 48 KB

Exports Laravel Routes to callable TypeScript functions

License: MIT License

TypeScript 75.56% PHP 12.87% Python 11.57%
php laravel typescript export import python routes

laravel-router-provider's Introduction

Laravel Router Exporter

Export laravel routes into callable typescript functions

Программа выполняет поиск и экспортирование роутеров из Laravel приложения и конвертирует их в запускаемый набор typescript функций, которые соответствуют роутам

The program searches for and exports routers from a Laravel application and converts them into a runnable set of typescript functions that correspond to routes

Usage

  1. Clone project
  2. Install pnpm pnpm, then run: $ pnpm install

Output

A file containing routes with types will be generated

example below

Использование

  1. Установите pnpm, затем: $ pnpm install

  2. Установите python, затем выполните команду, перенаправив вывод в файл: $ ./transfer.py -s=<path/to/laravel/app> -d=<path/to/routes>.ts

Что на выходе

Будет сгенерирован файл содержащий роуты с типами

import ky, { Options } from "ky"

export const getRoutes = (client: typeof ky) => ({
  CsrfCookieShow: (options?: Partial<Options>) => {
    return client.get(`sanctum/csrf-cookie`, options)
  },
  PostStore: (
    {
      title,
      description,
      startAt,
      count,
      parameter
    }: {
      title?: string
      description?: string
      startAt?: Date
      count?: number
      parameter?: string
    },
    options?: Partial<Options>
  ) => {
    return client.get(`api/some-route/${parameter}`, {
      searchParams: {
        title: String(title),
        description: String(description),
        start_at: String(startAt),
        count: String(count)
      },
      ...options
    })
  },
  PostUpdate: (
    {
      some,
      param,
      parameter,
      another
    }: {
      some?: string
      param?: number
      parameter?: string
      another?: string
    },
    options?: Partial<Options>
  ) => {
    return client.post(`api/some-route/${parameter}/${another}/end`, {
      json: {
        some,
        param
      },
      ...options
    })
  }
})

Ограничения / Limitations

  • Только FormRequest параметры для контроллера / Only FormRequest class
  • Только роуты, указанные с использованием синтаксиса [Some::class, 'method'] / Only syntax [Some::class, 'method']
  • В качестве клиента использутеся ky (требуется установить для проекта)

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.