@fastify-dev-toolkit/backend
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

fastify backend with auto json schema with type definitions

install

npm install @fastify-dev-toolkit/compiler
npm install @fastify-dev-toolkit/backend

add this in tsconfig.json

{
  "compilerOptions": {
    "plugins": [
      {
        "transform": "@fastify-dev-toolkit/compiler", // auto compiler plugin
        "transformProgram": true
      }
    ]
  }
}
/
└── src
    ├── routes // file route
    └── schema // type def in this folder will auto build to json schema

example

/
└── src
    ├── routes
    │   └── api
    │       └── v1
    │           └── test.ts  // url for /api/v1/test
    └── schema
        └── api
            └── one.ts
// /api/v1/test.ts
import {A, B} from '../schema/api/one' 

export default class AAA {
  get(): string {
    return 'ok'
  }
  post(request?: IPost<{ Body: Omit<A, 'a'>, Querystring: B }>): string {
    return 'ok'
  }
  put(): string {
    return ''
  }
  delete(): string {
    return ''
  }
}
// /schema/api/one.ts
type A = {
  a: string
  b: number
  c: MultipartUploadField
}
type B = {
  a: string
  b: number
}

if the ENVIRONMENT=development exist.

PORT=4002

use /documentation/ to view swagger

need ts-patch and add this in scripts

scripts: {
  "prepare": "ts-patch install -s"
}

Readme

Keywords

none

Package Sidebar

Install

npm i @fastify-dev-toolkit/backend

Weekly Downloads

0

Version

1.0.11

License

ISC

Unpacked Size

241 kB

Total Files

136

Last publish

Collaborators

  • ljx0517