@sentzunhat/zacatl 0.0.0-alpha.8 → 0.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,40 +1,120 @@
1
1
  # zacatl
2
2
 
3
- blazing fast minimal straightforward library
3
+ A blazing fast, minimal, and straightforward microservice framework for Node.js, designed for rapid development of high-performance APIs and distributed systems.
4
4
 
5
- # @sentzunhat/library
5
+ ## Project Description
6
6
 
7
- **Blazing Fast Microservice Framework**
7
+ **zacatl** (published as `@sentzunhat/zacatl`) is a TypeScript-first microservice library that enables you to bootstrap robust, scalable services with minimal configuration. Built on top of Fastify and Mongoose, it provides a modular architecture for defining application logic, infrastructure, and service orchestration, while supporting advanced features like dependency injection, localization, and flexible error handling.
8
8
 
9
- ## Go Fast with minimal setup!
9
+ ## Features
10
10
 
11
- This library lets you bootstrap high-performance microservices in record time using Fastify, Mongoose, and other battle-tested technologies. Designed for speed and simplicity, it allows you to spin up gateway services, handle routes, and manage infrastructure seamlessly.
11
+ - **Fastify-based HTTP server**: Ultra-fast routing and extensibility.
12
+ - **Mongoose integration**: Easy MongoDB data modeling and repository pattern.
13
+ - **Modular architecture**: Clean separation of application, domain, infrastructure, and platform layers.
14
+ - **Dependency injection**: Powered by `tsyringe` for testability and flexibility.
15
+ - **Gateway support**: Proxy requests to upstream services with minimal setup.
16
+ - **Internationalization (i18n)**: Built-in support for multiple locales.
17
+ - **Comprehensive error handling**: Custom error classes and route error utilities.
18
+ - **Type-safe route and hook handlers**: Strongly-typed REST entry points using Zod and Fastify.
19
+ - **Testing utilities**: Vitest configuration and helpers for fast, isolated unit tests.
12
20
 
13
- With just a few lines of code, you can configure your services, connect databases, and proxy requests—while keeping the flexibility to scale with more advanced configurations. Whether you're building lightweight APIs or complex distributed systems, this framework has you covered.
21
+ ## Architecture Overview
14
22
 
15
- ### Get started
23
+ The framework is organized into the following layers:
24
+
25
+ - **Application**: Defines REST entry points (routes and hooks) and configures i18n.
26
+ - **Domain**: Registers business logic providers.
27
+ - **Infrastructure**: Manages repositories and external dependencies.
28
+ - **Platform**: Orchestrates service startup, database connections, and server/gateway configuration.
29
+
30
+ Each layer is extensible and testable, supporting clean code and maintainability.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ bun install
36
+ # or
37
+ npm install @sentzunhat/zacatl
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ Here's how to quickly spin up a microservice:
16
43
 
17
44
  ```ts
18
45
  import Fastify from "fastify";
19
- import { MicroService } from "@sentzunhat/library";
46
+ import { MicroService } from "@sentzunhat/zacatl";
20
47
 
21
- const fastifyApp = Fastify({});
48
+ const fastifyApp = Fastify();
22
49
 
23
50
  const microServer = new MicroService({
24
- service: { name: "my-service", server: { instance: fastifyApp } },
51
+ architecture: {
52
+ application: {
53
+ entryPoints: {
54
+ rest: {
55
+ hookHandlers: [], // Add your hook handler classes here
56
+ routeHandlers: [], // Add your route handler classes here
57
+ },
58
+ },
59
+ },
60
+ domain: { providers: [] }, // Add your domain provider classes here
61
+ infrastructure: { repositories: [] }, // Add your repository classes here
62
+ service: {
63
+ name: "my-service",
64
+ server: {
65
+ type: "SERVER",
66
+ vendor: "FASTIFY",
67
+ instance: fastifyApp,
68
+ },
69
+ databases: [
70
+ // Example for MongoDB:
71
+ // {
72
+ // vendor: "MONGOOSE",
73
+ // instance: new Mongoose(),
74
+ // connectionString: "mongodb://localhost/mydb",
75
+ // }
76
+ ],
77
+ },
78
+ },
25
79
  });
26
80
 
27
81
  microServer.start({ port: 9000 });
28
82
  ```
29
83
 
30
- To install dependencies:
84
+ ## Configuration
31
85
 
32
- ```bash
33
- bun install
34
- ```
86
+ - **Localization**: Place your locale JSON files in `src/locales/` (e.g., `en.json`, `fr.json`).
87
+ - **Environment Variables**: Configure your database connection strings and other settings as needed.
88
+ - **Custom Handlers**: Implement route and hook handlers by extending the provided abstract classes.
89
+
90
+ ## Testing
35
91
 
36
- To run:
92
+ Run all unit tests with coverage:
37
93
 
38
94
  ```bash
39
- bun run src/index.ts
95
+ bun run test
96
+ # or
97
+ npm run test
40
98
  ```
99
+
100
+ Test configuration uses Vitest with in-memory MongoDB for fast, isolated tests.
101
+
102
+ ## API Reference
103
+
104
+ - **Application Layer**: See `src/micro-service/architecture/application/`
105
+ - **Domain Layer**: See `src/micro-service/architecture/domain/`
106
+ - **Infrastructure Layer**: See `src/micro-service/architecture/infrastructure/`
107
+ - **Platform Layer**: See `src/micro-service/architecture/platform/`
108
+ - **Error Handling**: See `src/error/` for custom error classes and utilities.
109
+
110
+ ## Contributing
111
+
112
+ Contributions are welcome! If you find this software useful and make improvements, please consider submitting a pull request. See the [LICENSE](./LICENSE) for details.
113
+
114
+ ## License
115
+
116
+ MIT License © 2025 sentzunhat
117
+
118
+ ---
119
+
120
+ **zacatl** is built for speed, simplicity, and extensibility. For questions, issues, or feature requests, please open an issue on [GitHub](https://github.com/sentzunhat/zacatl).
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@sentzunhat/zacatl",
3
3
  "main": "src/index.ts",
4
4
  "module": "src/index.ts",
5
- "version": "0.0.0-alpha.8",
5
+ "version": "0.0.0-alpha.9",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/sentzunhat/zacatl.git"
@@ -10,8 +10,8 @@ export type GetRouteHandlerConstructor = {
10
10
 
11
11
  export abstract class GetRouteHandler<
12
12
  TBody = never,
13
- TQuerystring = z.ZodSchema<Record<string, string>>,
14
13
  TResponse = never,
14
+ TQuerystring = z.ZodSchema<Record<string, string>>,
15
15
  TParams = void
16
16
  > extends AbstractRouteHandler<TBody, TQuerystring, TResponse, TParams> {
17
17
  constructor(args: GetRouteHandlerConstructor) {
@@ -10,8 +10,8 @@ export type PostRouteHandlerConstructor = {
10
10
 
11
11
  export abstract class PostRouteHandler<
12
12
  TBody = never,
13
- TQuerystring = z.ZodSchema<Record<string, string>>,
14
13
  TResponse = never,
14
+ TQuerystring = z.ZodSchema<Record<string, string>>,
15
15
  TParams = void
16
16
  > extends AbstractRouteHandler<TBody, TQuerystring, TResponse, TParams> {
17
17
  constructor(args: PostRouteHandlerConstructor) {