GithubHelp home page GithubHelp logo

fast-z's Introduction

fastx

Fastx is a fastify route generator tool i made to skip the repeatitive process of creating new route files and copy code here and there. Thus, this tool handles it for me.

how to setup the tool

use curl to download the binary file:

curl -o fastx https://raw.githubusercontent.com/lumbrjx/fast-z/main/fastx

now you can check fastx -h show for user guide.

first you have to initialize the tool in your fastify project root folder by running:

fastx -i attach

you will have to specify the domains parent folder path e.g. /src/domains. the tool will generate a fastx.toml file in the same dir. there you can edit the domainPath field if you want to change the domains parent folder destination.

how to generate routes

You need to create a folder in the domains folder u specified earlier, then add a model.def.ts to it. the model.def.ts file will contain the routes zod schemas. each schema decalration should have a specific comment like this:

// --product,get,products,body,getProducts
export const ProductSchema = z.object({
  name: z.string().min(4).max(25),
  price: z.number().min(1).max(9999999999),
  is_available: z.boolean().default(true),
  description: z.string().min(10).max(300),
  category: z.string().min(4).max(25),
});

structure:

  • product: the route endpoint
  • get: the http method
  • products: route prefix
  • body: type of body (body, queryParams...)
  • getProducts: file name

to generate a route simply run (in the root dir):

fastx -g <folder name>

in addition you can ignore some schemas by adding 'ign':

// ign --product,get,products,body,getProducts
export const ProductSchema = z.object({
  name: z.string().min(4).max(25),
  price: z.number().min(1).max(9999999999),
  is_available: z.boolean().default(true),
  description: z.string().min(10).max(300),
  category: z.string().min(4).max(25),
});

fast-z's People

Contributors

lumbrjx avatar

Stargazers

Djawed 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.