Awesome
<p align="center"> <img src="https://raw.githubusercontent.com/FastifyResty/fastify-resty/gh-images/logo/full-logo.png" width="650" height="auto"/> </p> <div align="center"> </div> <div align="center"> </div><hr> <p align="center"> If you find this useful, please don't forget to star :star: the repo, as this will help to promote the project. </p> <hr>Modern and declarative REST API framework for superfast and oversimplification backend development, build on top of Fastify and TypeScript.
Benefits :dart:
- Zero configuration - Generates RESTful API routes for your data out the box
- JSON Schema validation - Build JSON Schemas to validate and speedup your requests and replies
- Highly customizable - provides a lot of possible configurations for your application
- Purely TypeScript - Written in TypeScript and comes with all the required typings
- Declarative interface - Uses decorators for routes and models definitions
- Fastify compatible - Built with Fastify and supports all its features and plugins
- Built-in DI - Provides simple Dependency Injection interface to bind your entries
Install :pushpin:
Core module
$ npm install @fastify-resty/core fastify
TypeORM connector
$ npm install @fastify-resty/typeorm typeorm
Usage :rocket:
TypeORM Entity (author.entity.ts):
import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn } from 'typeorm';
@Entity()
export default class Author {
@PrimaryGeneratedColumn()
id: number;
@Column()
firstname: string;
@Column()
lastname: string;
@CreateDateColumn()
created_at: Date;
}
Entity controller (author.controller.ts):
import { EntityController } from '@fastify-resty/core';
import AuthorEntity from './author.entity';
@EntityController(AuthorEntity, '/authors')
export default class AuthorController {}
Bootstrap (app.ts):
import fastify from 'fastify';
import { createConnection } from 'typeorm';
import { bootstrap } from '@fastify-resty/core';
import typeorm from '@fastify-resty/typeorm';
import AuthorController from './author.controller';
async function main() {
const app = fastify();
const connection = await createConnection();
app.register(typeorm, { connection });
app.register(bootstrap, { controllers: [AuthorController] });
app.listen(8080, (err, address) => {
console.log(app.printRoutes());
});
}
main();
Generated routes:
└── /
└── users (DELETE|GET|PATCH|POST|PUT)
└── / (DELETE|GET|PATCH|POST|PUT)
└── :id (DELETE)
:id (GET)
:id (PATCH)
:id (PUT)
Documentation :books:
- Quickstart :label:
- Application Structure :label:
- Bootstrapping :label:
- Controllers :label:
- Entity Controllers :label:
- Model :label:
- Services :label:
- Dependency Injection :label:
Packages :package:
- @fastify-resty/core - Fastify Resty core functionality
- @fastify-resty/typeorm - Fastify Resty TypeORM connector
Examples :microscope:
Issues and contributions :memo:
Contributors are welcome, please fork and send pull requests! If you find a bug or have any ideas on how to improve this project please submit an issue.
License
Icons made by <a href="https://www.flaticon.com/authors/eucalyp" title="Eucalyp">Eucalyp</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>