diff --git a/README.md b/README.md index 8e117cd..fbf326a 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,42 @@ -# Getting Started with [Fastify-CLI](https://www.npmjs.com/package/fastify-cli) +# js-fastify-rest-api-example -This project was bootstrapped with Fastify-CLI. +REST API на [Fastify](https://fastify.dev/), собранный «по-взрослому»: +схема API описана отдельно от кода, база через ORM, валидация по схеме. -## Available Scripts +## Зачем это нужно -In the project directory, you can run: +Пример того, как выглядит API-проект, когда он перерастает один файл с +маршрутами. Отличия от учебной заглушки видны сразу: -### `npm run dev` +- **Контракт первичен.** API описан на [TypeSpec](https://typespec.io/) + в `main.tsp`, из него генерируется OpenAPI, а из OpenAPI — типы для кода. + Документация не расходится с реализацией, потому что порождена из одного + источника. +- **База через [Drizzle](https://orm.drizzle.team/)**: схема в `db/schema.ts`, + миграции генерируются по ней. +- **Валидация входа** отдельным слоем в `validators/`, а не внутри обработчика. -To start the app in dev mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. +## Запуск -### `npm start` +```bash +make install +make dev +make test +``` -For production mode +Полезное: -### `npm run test` +```bash +make routes # список маршрутов +make migration-generate # миграция по изменённой схеме +make generate-types # OpenAPI и типы из TypeSpec +make mock # поднять мок-сервер по OpenAPI +``` -Run the test cases. +--- -## Learn More +[![Hexlet Ltd. logo](https://raw.githubusercontent.com/Hexlet/assets/master/images/hexlet_logo128.png)](https://hexlet.io/?utm_source=github&utm_medium=link&utm_campaign=js-fastify-rest-api-example) -To learn Fastify, check out the [Fastify documentation](https://fastify.dev/docs/latest/). +This repository is created and maintained by the team and the community of Hexlet, an educational project. [Read more about Hexlet](https://hexlet.io/?utm_source=github&utm_medium=link&utm_campaign=js-fastify-rest-api-example). + +See most active contributors on [hexlet-friends](https://friends.hexlet.io/).