- The objective of this project is not to create a new API. I was testing some project structures to validate the input and output values from the controller. I applied knowledge from all the API projects I have worked on and merged only the best practices that I consider essential for any API project. This includes: route documentation, input and output value validation, tests (coming soon), directory structure, some SOLID principles, and Design Patterns.
Folder | Description |
---|---|
src | Root folder of the project's source code. |
controllers | Contains controllers responsible for handling route requests and responses. |
lib | Folder with libraries and auxiliary resources for the project. |
definitions | Define endpoint schema. |
schemas | Defines validation and data structure schemas. |
types | Contains type and interface definitions for the project. |
utils | Includes utility functions and helpers to support core functionalities. |
services | Implements business logic. |
Script | Description |
---|---|
dev |
Runs the server in development mode |
build |
Build app to production |
Dependency | Description |
---|---|
typescript |
Typed JavaScript language. |
tsx |
TypeScript runtime with ES module support. |
fastify |
Fast web framework for Node.js. |
@fastify/swagger |
Swagger/OpenAPI plugin for Fastify. |
zod |
Schema validation library for TypeScript. |
- Swagger UI available in
/docs
route