### Install @ez4/stateful Source: https://github.com/sbalmt/ez4/blob/main/foundation/stateful/README.md Install the @ez4/stateful package as a development dependency using npm. ```sh npm install @ez4/stateful -D ``` -------------------------------- ### Install project dependencies Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-dynamodb-crudl/README.md Run this command to install the necessary node modules for the project. ```sh npm install ``` -------------------------------- ### Install EZ4 Local Scheduler Source: https://github.com/sbalmt/ez4/blob/main/providers/local/local-scheduler/README.md Install the local scheduler emulator as a development dependency. ```sh npm install @ez4/local-scheduler -D ``` -------------------------------- ### Install EZ4 Local Queue Source: https://github.com/sbalmt/ez4/blob/main/providers/local/local-queue/README.md Install the local queue package as a development dependency. ```sh npm install @ez4/local-queue -D ``` -------------------------------- ### Install Scheduler Packages Source: https://github.com/sbalmt/ez4/blob/main/contracts/scheduler/README.md Install the necessary EZ4 scheduler packages using npm. ```sh npm install @ez4/scheduler @ez4/local-scheduler @ez4/aws-scheduler -D ``` -------------------------------- ### Install EZ4 Utils package Source: https://github.com/sbalmt/ez4/blob/main/foundation/utils/README.md Use this command to install the utility package as a development dependency. ```sh npm install @ez4/utils -D ``` -------------------------------- ### Install EZ4 Local Storage Source: https://github.com/sbalmt/ez4/blob/main/providers/local/local-storage/README.md Use this command to install the package as a development dependency. ```sh npm install @ez4/local-storage -D ``` -------------------------------- ### Install EZ4 PgClient via NPM Source: https://github.com/sbalmt/ez4/blob/main/libraries/pgclient/README.md This command installs the @ez4/pgclient package as a development dependency in your Node.js project. Ensure you have npm installed and are running this within your project root directory. ```shell npm install @ez4/pgclient -D ``` -------------------------------- ### Install @ez4/aws-logs Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-logs/README.md Install the package as a development dependency. ```sh npm install @ez4/aws-logs -D ``` -------------------------------- ### Install EZ4 DynamoDB package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-dynamodb/README.md Install the package as a development dependency. ```sh npm install @ez4/aws-dynamodb -D ``` -------------------------------- ### Install AWS CloudFront Provider Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-cloudfront/README.md Install the AWS CloudFront provider package using npm. ```sh npm install @ez4/aws-cloudfront -D ``` -------------------------------- ### Install EZ4 Local Cache Source: https://github.com/sbalmt/ez4/blob/main/providers/local/local-cache/README.md Use this command to install the package as a development dependency. ```sh npm install @ez4/local-cache -D ``` -------------------------------- ### Install EZ4 Gateway UI package Source: https://github.com/sbalmt/ez4/blob/main/providers/docs/docs-gateway-ui/README.md Installs the @ez4/docs-gateway-ui package as a development dependency in your project. This command requires npm to be installed on your system. ```shell npm install @ez4/docs-gateway-ui -D ``` -------------------------------- ### GET /hello Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-service.md Defines a simple GET route named 'getHello' that handles requests to the '/hello' path. ```APIDOC ## GET /hello ### Description Handles GET requests to the /hello endpoint. ### Method GET ### Endpoint /hello ### Parameters #### Query Parameters None explicitly defined in this snippet. #### Request Body None explicitly defined in this snippet. ### Response #### Success Response (200) Details depend on the `routeHandler` implementation. #### Response Example None explicitly defined in this snippet. ``` -------------------------------- ### Install PgMigration Package Source: https://github.com/sbalmt/ez4/blob/main/libraries/pgmigration/README.md Install the EZ4 PgMigration package as a development dependency using npm. ```sh npm install @ez4/pgmigration -D ``` -------------------------------- ### Install EZ4 Gateway Docs Generator Source: https://github.com/sbalmt/ez4/blob/main/providers/docs/docs-gateway/README.md Install the EZ4 gateway documentation generator as a development dependency using npm. ```sh npm install @ez4/docs-gateway -D ``` -------------------------------- ### Install npm Packages Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-gateway-websocket/README.md Installs the necessary Node.js packages for the project using npm. This is a prerequisite for running the local emulation or deploying the application. ```sh npm install ``` -------------------------------- ### Route Declaration Example Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-routes.md Declares an HTTP route named 'getUser' with a GET method on the '/users/{id}' path. It specifies the listener, authorizer, handler, and custom HTTP error mappings for 404 and 400 status codes. The route is enabled and configured for CORS. ```typescript export declare class MyServer extends Http.Service { routes: [ Http.UseRoute<{ name: 'getUser'; path: 'GET /users/{id}'; listener: typeof serverListener; authorizer: typeof authorizeHandler; handler: typeof routeHandler; disabled: false; cors: true; httpErrors: { 404: [UserNotFound]; 400: [InvalidInput]; }; }> // ... ]; } ``` -------------------------------- ### EZ4 Project Configuration Example Source: https://github.com/sbalmt/ez4/blob/main/documentation/configuration.md This is a comprehensive example of an ez4.project.js file. It demonstrates how to configure project settings, default resource options, deployment parameters, serving options, watch mode, shared variables, tags, imported project references, and custom providers. ```javascript import { ArchitectureType, LogLevel, RuntimeType } from '@ez4/project'; /** * @type {import('@ez4/project').ProjectOptions} */ export default { prefix: 'dev', // Project prefix projectName: 'backend', // Project name (required) branchName: 'feat-1', // Optional branch name to share deployed resources sourceFiles: ['./src/api.ts'], // Entry-point source files tsconfigFile: 'tsconfig.json', // Specify a custom tsconfig.json location packageFile: 'package.json', // Specify a custom package.json location confirmMode: true, // Ask for deploy confirmation when it's true debugMode: true, // See more logs when serving and in the deployed resources localMode: true, // Enable the local mode for the resources when serving resetMode: true, // Enable the reset mode for the local resources when serving // Configure how the state file is stored stateFile: { path: 'ez4-state', // Path to the state file remote: true // Enable remote storage (in your cloud account) for the state file }, // Configure the default options for all resource contracts defaultOptions: { logLevel: LogLevel.Debug, // Default log level for all handlers logRetention: 15, // Default log retention (in days) for all handlers architecture: ArchitectureType.Arm, // Default architecture for all handlers runtime: RuntimeType.Node24, // Default runtime for all handlers memory: 192 // Default amount of memory available (in megabytes) for all handlers }, // Configure the deployment options for all resources deployOptions: { maxConcurrency: 10, // Maximum number of resource changes processed concurrently. // Configure the deployment release release: { tagName: 'Version', // Name of the tag to hold the release version variableName: 'VERSION', // Name of the environment variable to hold the release version version: '0.0.0' // Current release version } }, // Configure how to serve the project locally serveOptions: { localHost: 'localhost', // Host name/address when serving the project localPort: 3734 // Port when serving the project }, // Configure the watch mode for when serving the project watchOptions: { additionalPaths: ['./test'] // Additional paths to watch during development. }, // Configure the local development options for the providers localOptions: {}, // Configure the test options for the providers testOptions: {}, // Environment variables shared with all resources variables: { DUMMY_API_KEY: 'A-BC123' }, // Tags shared with all resources tags: { Project: 'EZ4' // Use the tag name/value key pair }, // Configure the imported projects references references: { // Identification key for the imported project another_project: { projectFile: '../frontend/ez4.project.js' // Path to the EZ4's configuration } }, // Configure the custom providers customProviders: { packages: ['@my-project/custom'] // List of installed packages that have custom providers } }; ``` -------------------------------- ### Install @ez4/aws-gateway Package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-gateway/README.md Installs the @ez4/aws-gateway package as a development dependency using npm. ```sh npm install @ez4/aws-gateway -D ``` -------------------------------- ### Install EZ4 Project Source: https://github.com/sbalmt/ez4/blob/main/foundation/project/README.md Use this command to install the EZ4 project package as a development dependency. ```sh npm install @ez4/project -D ``` -------------------------------- ### Install @ez4/aws-identity Package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-identity/README.md Installs the @ez4/aws-identity package as a development dependency using npm. ```sh npm install @ez4/aws-identity -D ``` -------------------------------- ### Install Database Packages Source: https://github.com/sbalmt/ez4/blob/main/contracts/database/README.md Installs the necessary EZ4 database packages and local database adapter. Use `@ez4/aws-dynamodb` for NoSQL instead of `@ez4/aws-aurora`. ```sh npm install @ez4/database @ez4/local-database @ez4/aws-aurora -D ``` -------------------------------- ### Install EZ4 Local Database Source: https://github.com/sbalmt/ez4/blob/main/providers/local/local-database/README.md Install the EZ4 local database emulator as a development dependency using npm. ```sh npm install @ez4/local-database -D ``` -------------------------------- ### Install EZ4 Queue Packages Source: https://github.com/sbalmt/ez4/blob/main/contracts/queue/README.md Install the necessary EZ4 packages for queue functionality, including local and AWS providers. ```sh npm install @ez4/queue @ez4/local-queue @ez4/aws-queue -D ``` -------------------------------- ### Install EZ4 AWS Common Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-common/README.md Install the package as a development dependency using npm. ```sh npm install @ez4/aws-common -D ``` -------------------------------- ### Install EZ4 Gateway Packages Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/README.md Install the necessary EZ4 gateway packages using npm. These are development dependencies. ```sh npm install @ez4/gateway @ez4/local-gateway @ez4/aws-gateway -D ``` -------------------------------- ### Install EZ4 Distribution Packages Source: https://github.com/sbalmt/ez4/blob/main/contracts/distribution/README.md Install the necessary EZ4 packages for distribution and AWS CloudFront integration using npm. ```sh npm install @ez4/distribution @ez4/aws-cloudfront -D ``` -------------------------------- ### Install @ez4/common Package Source: https://github.com/sbalmt/ez4/blob/main/foundation/common/README.md Instructions for installing the @ez4/common package using npm. This is a development dependency. ```sh npm install @ez4/common -D ``` -------------------------------- ### Install EZ4 PostgreSQL Query Builder Source: https://github.com/sbalmt/ez4/blob/main/libraries/pgsql/README.md Install the EZ4 PostgreSQL query builder as a development dependency using npm. ```sh npm install @ez4/pgsql -D ``` -------------------------------- ### Install EZ4 AWS Bucket package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-bucket/README.md Install the package as a development dependency using npm. ```sh npm install @ez4/aws-bucket -D ``` -------------------------------- ### Install EZ4 Transform Package Source: https://github.com/sbalmt/ez4/blob/main/foundation/transform/README.md Install the Transform package as a development dependency using npm. ```sh npm install @ez4/transform -D ``` -------------------------------- ### Install EZ4 Reflection package Source: https://github.com/sbalmt/ez4/blob/main/foundation/reflection/README.md Use this command to add the reflection library as a development dependency to your project. ```sh npm install @ez4/reflection -D ``` -------------------------------- ### Install NVM and Node.js Source: https://github.com/sbalmt/ez4/blob/main/documentation/quick-start.md Installs Node Version Manager (NVM) and Node.js version 24. Ensure to restart your terminal or source the NVM script. ```sh curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash \. "$HOME/.nvm/nvm.sh" nvm install 24 ``` -------------------------------- ### Emulate Project with Local Database Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-aurora-crudl/README.md This command starts a local emulation of the project, using a local database instead of the remote AWS Aurora instance. Useful for faster local development and testing. ```sh npm run serve -- --local ``` -------------------------------- ### Install EZ4 Topology Generator Source: https://github.com/sbalmt/ez4/blob/main/providers/docs/docs-topology/README.md Installs the @ez4/docs-topology package as a development dependency in your project. This is required to use the topology generation features. ```shell npm install @ez4/docs-topology -D ``` -------------------------------- ### Install EZ4 Database Docs Generator with npm Source: https://github.com/sbalmt/ez4/blob/main/providers/docs/docs-database/README.md Installs the EZ4 database documentation generator as a development dependency using npm. This command is typically run in the project's root directory. ```sh npm install @ez4/docs-database -D ``` -------------------------------- ### Install EZ4 Topic Packages Source: https://github.com/sbalmt/ez4/blob/main/contracts/topic/README.md Install the necessary EZ4 packages for topic functionality, including local and AWS providers, as development dependencies. ```sh npm install @ez4/topic @ez4/local-topic @ez4/aws-topic -D ``` -------------------------------- ### Install EZ4 Schema Package Source: https://github.com/sbalmt/ez4/blob/main/foundation/schema/README.md Install the EZ4 Schema package as a development dependency using npm. ```sh npm install @ez4/schema -D ``` -------------------------------- ### Install EZ4 project dependencies Source: https://github.com/sbalmt/ez4/blob/main/documentation/quick-start.md Installs the necessary development dependencies for an EZ4 project, including the project builder and TypeScript. ```sh npm install -D @ez4/project @types/node@24 typescript ``` -------------------------------- ### Install EZ4 Factory Package Source: https://github.com/sbalmt/ez4/blob/main/contracts/factory/README.md Install the EZ4 factory package as a development dependency using npm. ```sh npm install @ez4/factory -D ``` -------------------------------- ### Scheduler Start Date Configuration Source: https://github.com/sbalmt/ez4/blob/main/contracts/scheduler/docs/scheduler-service.md Define the start date for the scheduler's active window. ```typescript startDate: '2026-01-01T00:00:00Z'; ``` -------------------------------- ### Install EZ4 Gateway dependencies Source: https://github.com/sbalmt/ez4/blob/main/documentation/quick-start.md Installs development dependencies for the EZ4 gateway and local gateway. These are required for building API gateways. ```sh npm install -D @ez4/gateway @ez4/local-gateway ``` -------------------------------- ### Install EZ4 Validator Source: https://github.com/sbalmt/ez4/blob/main/foundation/validator/README.md Install the EZ4 Validator package as a development dependency using npm. ```sh npm install @ez4/validator -D ``` -------------------------------- ### Queue Listener Implementation Example Source: https://github.com/sbalmt/ez4/blob/main/contracts/queue/docs/queue-listener.md Implement a listener function to observe queue service events. Attach this function to your subscription handlers to monitor their lifecycle. ```typescript export function myListener(event: Queue.ServiceEvent, context: Service.Context) { switch (event.type) { case ServiceEventType.Begin: // Message batch processing started. break; case ServiceEventType.Ready: // Current message validation and transformation completed. break; case ServiceEventType.Done: // Current message processing completed successfully. break; case ServiceEventType.Error: // Current message validation or handler execution error. break; case ServiceEventType.End: // Message batch processing finished. break; } } ``` -------------------------------- ### Install EZ4 Storage Packages Source: https://github.com/sbalmt/ez4/blob/main/contracts/storage/README.md Install the necessary EZ4 packages for storage, including local and AWS bucket integrations. This command should be run in your project's root directory. ```sh npm install @ez4/storage @ez4/local-storage @ez4/aws-bucket -D ``` -------------------------------- ### Install EZ4 Validation Package Source: https://github.com/sbalmt/ez4/blob/main/contracts/validation/README.md Install the EZ4 validation package as a development dependency using npm. ```sh npm install @ez4/validation -D ``` -------------------------------- ### Manage AWS API Gateway Lifecycle with NPM Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-import-gateway/README.md Provides the standard command-line interface for managing the project lifecycle. These commands handle dependency installation, local development emulation, and cloud resource management. ```bash npm install npm run serve npm run deploy npm run destroy ``` -------------------------------- ### Install EZ4 Email Packages Source: https://github.com/sbalmt/ez4/blob/main/contracts/email/README.md Install the necessary EZ4 email packages using npm. This includes the core email package and the AWS provider. ```sh npm install @ez4/email @ez4/aws-email -D ``` -------------------------------- ### Path Parameters Field Example Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-requests.md Example declaration for path parameters, matching segments in the route path. These are automatically validated as strings and guaranteed to exist when declared. ```typescript parameters: { id: String.UUID; group: string; } ``` -------------------------------- ### Install EZ4 AWS Email Package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-email/README.md Installs the @ez4/aws-email package as a development dependency in your project using npm. ```shell npm install @ez4/aws-email -D ``` -------------------------------- ### Emulate Local WebSocket Server Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-gateway-websocket/README.md Starts a local server to emulate the AWS API Gateway WebSocket functionality. This allows for testing and development without deploying to AWS. ```sh npm run serve ``` -------------------------------- ### Install EZ4 Logger via NPM Source: https://github.com/sbalmt/ez4/blob/main/foundation/logger/README.md This command installs the @ez4/logger package as a development dependency in your project. It is required to begin using the logging API. ```shell npm install @ez4/logger -D ``` -------------------------------- ### Install EZ4 Local Topic Emulator with npm Source: https://github.com/sbalmt/ez4/blob/main/providers/local/local-topic/README.md Installs the EZ4 local topic emulator package as a development dependency using npm. This command is typically run in a Node.js project environment. ```sh npm install @ez4/local-topic -D ``` -------------------------------- ### Install EZ4 Local Gateway with npm Source: https://github.com/sbalmt/ez4/blob/main/providers/local/local-gateway/README.md Installs the EZ4 Local Gateway package as a development dependency using npm. This command is typically used to set up the local gateway emulator for development or testing purposes. ```sh npm install @ez4/local-gateway -D ``` -------------------------------- ### Install EZ4 Cache Dependencies Source: https://github.com/sbalmt/ez4/blob/main/contracts/cache/README.md Install the necessary EZ4 cache packages using npm. This includes the core cache package and specific engine providers. ```sh npm install @ez4/cache @ez4/local-cache @ez4/aws-valkey -D ``` -------------------------------- ### Define a Storage Contract Source: https://github.com/sbalmt/ez4/blob/main/contracts/storage/README.md Declare a custom storage service using EZ4's Bucket.Service. This example shows how to define event handlers, environment variables, and connected services for your storage. ```ts import type { Environment, Service } from '@ez4/common'; import type { Bucket } from '@ez4/storage'; // MyStorage declaration export declare class MyStorage extends Bucket.Service { autoExpireDays: 1; events: Bucket.UseEvents<{ handler: typeof eventHandler; }>; variables: { myVariable: Environment.Variable<'MY_VARIABLE'>; }; services: { otherService: Environment.Service; variables: Environment.ServiceVariables; }; } ``` -------------------------------- ### Install @ez4/local-common Package Source: https://github.com/sbalmt/ez4/blob/main/providers/local/local-common/README.md This snippet shows how to install the @ez4/local-common package as a development dependency using npm. This package contains common components shared across local emulator packages. ```sh npm install @ez4/local-common -D ``` -------------------------------- ### Declare a Custom Cache Service Source: https://github.com/sbalmt/ez4/blob/main/contracts/cache/README.md Define a custom cache service by extending `Cache.Service` and specifying the desired cache engine using `Cache.UseEngine`. This example uses the 'valkey' engine. ```ts import type { Environment, Service } from '@ez4/common'; import type { Cache } from '@ez4/cache'; // MyCache declaration export declare class MyCache extends Cache.Service { engine: Cache.UseEngine<{ name: 'valkey'; }>; } ``` -------------------------------- ### Gateway Authorizer Implementation Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/gateway-authorizer.md Example implementation of an authorizer function. It receives a typed authorization request and context, performs validation, and returns an authorization response with identity data. Throwing an exception or returning no identity denies the request. ```typescript export function authorizerHandler( request: Http.AuthIncoming, context: Service.Context ): AuthorizerResponse { // Validate token, check permissions, etc. return { identity: { userId: '00000000-0000-1000-9000-000000000000', roles: [RolesEnum.Admin], tenantId: 1000 } }; } ``` -------------------------------- ### Query Strings Field Example Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-requests.md Example declaration for query string parameters. Only explicitly declared query strings are included, parsed into declared types, and field names are affected by NamingStyle preference. ```typescript query: { search?: String.Max<250>; limit: Integer.Any; tags: TagsEnum[]; } ``` -------------------------------- ### Initialize npm project Source: https://github.com/sbalmt/ez4/blob/main/documentation/quick-start.md Initializes a new Node.js project by creating a package.json file. This is a standard npm command. ```sh npm init ``` -------------------------------- ### Install AWS Valkey Package with npm Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-valkey/README.md Installs the @ez4/aws-valkey package as a development dependency using npm. This package provides components for managing Valkey cache services on AWS. ```sh npm install @ez4/aws-valkey -D ``` -------------------------------- ### Install @ez4/aws-queue Package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-queue/README.md Installs the @ez4/aws-queue package as a development dependency using npm. This package is used for managing AWS Simple Queue Service. ```sh npm install @ez4/aws-queue -D ``` -------------------------------- ### Raw String Body Field Example Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-requests.md Example declaration for a raw string request body. This is useful for non-JSON formats and is directly assigned to the body field. ```typescript body: string; ``` -------------------------------- ### Service Declaration Example Source: https://github.com/sbalmt/ez4/blob/main/contracts/factory/docs/factory-service.md Declares a factory service by extending Factory.Service and defining its handler, options, variables, and dependent services. ```typescript export declare class MyFactory extends Factory.Service { handler: typeof createMyService; options: { myOption: string; }; variables: { myVariable: Environment.Variable<'MY_VARIABLE'>; }; services: { otherService: Environment.Service; variables: Environment.ServiceVariables; options: Environment.ServiceOptions; }; } ``` -------------------------------- ### Expected Input for Primitive Boolean Schema Source: https://github.com/sbalmt/ez4/blob/main/foundation/schema/docs/boolean-schema.md Example JSON input demonstrating valid values for the defined primitive boolean schema. ```json { "foo": true, "bar": false, "baz": true, "qux": false } ``` -------------------------------- ### Emulate project with remote or local cache Source: https://github.com/sbalmt/ez4/blob/main/examples/hello-aws-cache/README.md Use these commands to run the project locally. The first command uses a remote cache, while the second uses a local cache. ```sh npm run serve ``` ```sh npm run serve -- --local ``` -------------------------------- ### HTTP Service Defaults Declaration Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/gateway-defaults.md Declare default configurations for an HTTP service using Http.UseDefaults. This example shows settings for log retention, log level, architecture, runtime, listener, preferences, and HTTP error mapping. ```typescript export declare class MyServer extends Http.Service { defaults: Http.UseDefaults<{ logRetention: 45; logLevel: LogLevel.Debug; architecture: ArchitectureType.Arm; runtime: RuntimeType.Node24; listener: typeof globalListener; preferences: { namingStyle: NamingStyle.SnakeCase; }; // Only for HTTP Services. httpErrors: { 404: [EntryNotFound]; 400: [InvalidInput]; }; }>; } ``` -------------------------------- ### Install AWS Certificate Package (npm) Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-certificate/README.md Installs the @ez4/aws-certificate package as a development dependency using npm. This package is essential for managing AWS certificates within your project. ```sh npm install @ez4/aws-certificate -D ``` -------------------------------- ### Run Project Tests Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-storage-manager/README.md Execute this command to run the project's test suite. ```sh npm test ``` -------------------------------- ### Queue Subscription Declaration Source: https://github.com/sbalmt/ez4/blob/main/contracts/queue/docs/queue-subscriptions.md Declare queue subscriptions using the Queue.UseSubscription helper on the service. This example shows a basic declaration with listener, handler, concurrency, timeout, batch, and other configurations. ```typescript subscriptions: [ Queue.UseSubscription({ listener: typeof queueListener; handler: typeof processMessage; concurrency: 4; timeout: 120; batch: 5; }) ]; ``` -------------------------------- ### Example Topic Handler Function Source: https://github.com/sbalmt/ez4/blob/main/contracts/topic/docs/topic-handler.md Defines a basic message handler function for a topic subscription. It receives a typed incoming request and a service context, with business logic to be implemented within the function body. ```typescript export function myHandler(request: Topic.Incoming, context: Service.Context): void { const { message } = request; // Business logic here. } ``` -------------------------------- ### WebSocket Service Defaults Declaration Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/gateway-defaults.md Declare default configurations for a WebSocket service using Ws.UseDefaults. This example includes settings for log retention, log level, architecture, runtime, listener, and preferences. ```typescript export declare class MyServer extends Ws.Service { defaults: Ws.UseDefaults<{ logRetention: 45; logLevel: LogLevel.Debug; architecture: ArchitectureType.Arm; runtime: RuntimeType.Node24; listener: typeof globalListener; preferences: { namingStyle: NamingStyle.CamelCase; }; }>; } ``` -------------------------------- ### Run Project Tests with npm Source: https://github.com/sbalmt/ez4/blob/main/examples/hello-aws-queue/README.md Executes the project's test suite using npm. This command verifies the functionality and integrity of the code. ```sh npm test ``` -------------------------------- ### Install @ez4/aws-scheduler Package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-scheduler/README.md Installs the @ez4/aws-scheduler package as a development dependency using npm. This package provides components for managing scheduled events on AWS. ```sh npm install @ez4/aws-scheduler -D ``` -------------------------------- ### Deploy AWS resources Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-dynamodb-crudl/README.md Provisions the required infrastructure on the configured AWS account. ```sh npm run deploy ``` -------------------------------- ### Declare an HTTP Service with Routes Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-service.md Declare an HTTP service by extending Http.Service and providing a list of typed HTTP routes using Http.UseRoute. ```typescript export declare class MyServer extends Http.Service { name: 'HTTP Service'; routes: [ Http.UseRoute<{ name: 'getHello'; path: 'GET /hello'; handler: typeof routeHandler; }> ]; } ``` -------------------------------- ### JSON Body Field Example Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-requests.md Example declaration for a JSON request body payload. The shape is determined by the declared type, and fields are automatically parsed and validated. ```typescript body: { name: String.Size<1, 20>; email: String.Email; age?: Integer.Any; } ``` -------------------------------- ### Install AWS Topic Package with npm Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-topic/README.md Installs the @ez4/aws-topic package as a development dependency using npm. This package provides components for managing AWS SNS topics. ```sh npm install @ez4/aws-topic -D ``` -------------------------------- ### Install EZ4 AWS VPC Package (npm) Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-vpc/README.md Installs the EZ4 AWS VPC package as a development dependency using npm. This package provides components for managing VPCs on AWS. ```sh npm install @ez4/aws-vpc -D ``` -------------------------------- ### Install EZ4 AWS Function Package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-function/README.md Installs the EZ4 AWS Function package as a development dependency using npm. This package provides components for managing AWS Lambda functions. ```sh npm install @ez4/aws-function -D ``` -------------------------------- ### Configure package.json scripts and type Source: https://github.com/sbalmt/ez4/blob/main/documentation/quick-start.md Sets the project to use ES modules and defines scripts for deploying, destroying, serving, and testing the EZ4 project. Ensure these scripts are added to your package.json. ```json { "type": "module", "scripts": { "deploy": "tsc && ez4 deploy", "destroy": "tsc && ez4 destroy", "serve": "tsc && ez4 serve", "test": "tsc && ez4 test" } } ``` -------------------------------- ### Scheduler Target Configuration Source: https://github.com/sbalmt/ez4/blob/main/contracts/scheduler/docs/scheduler-service.md Configure the entry-point handler and optional listener for the scheduler. This also controls execution options like runtime and timeouts. ```typescript target: Cron.UseTarget({ handler: typeof eventHandler; listener: typeof schedulerListener; timeout: 30; }); ``` -------------------------------- ### Install EZ4 AWS Aurora Package Source: https://github.com/sbalmt/ez4/blob/main/providers/aws/aws-aurora/README.md Installs the EZ4 AWS Aurora package as a development dependency using npm. This package provides components for managing Aurora serverless v2 on AWS. ```sh npm install @ez4/aws-aurora -D ``` -------------------------------- ### Serve EZ4 API Gateway Source: https://github.com/sbalmt/ez4/blob/main/documentation/quick-start.md Builds the project using TypeScript and then serves the EZ4 API gateway. This command is typically run after defining the API contract. ```sh npm run serve ``` -------------------------------- ### Use Storage Service in Another Handler Source: https://github.com/sbalmt/ez4/blob/main/contracts/storage/README.md Demonstrates how to use the defined storage service (e.g., MyStorage) within another handler to read and write files. Ensure the storage service is injected into the context of the handler. ```ts import type { Service } from '@ez4/common'; import type { MyStorage } from './storage'; // Any other handler that has injected MyStorage service export async function anotherHandler(_request: any, context: Service.Context) { const { myStorage } = context; // Write a file await myStorage.write('dummy.txt', 'Hello storage'); // Read a file const content = myStorage.read('dummy.txt'); } ``` -------------------------------- ### Deploy AWS Resources Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-gateway-websocket/README.md Deploys the project's resources, including the API Gateway WebSocket, to the specified AWS account. This command automates the creation of necessary cloud infrastructure. ```sh npm run deploy ``` -------------------------------- ### Valid Input for Default Boolean Schema Source: https://github.com/sbalmt/ez4/blob/main/foundation/schema/docs/boolean-schema.md Example JSON input for a schema with a default boolean value. The default is applied even if the field is missing. ```json { "bar": "any text..." } ``` -------------------------------- ### Define a Custom Email Service Source: https://github.com/sbalmt/ez4/blob/main/contracts/email/README.md Declare a custom email service that extends the base Email.Service from EZ4. This example defines a service with a specific domain. ```ts import type { Environment, Service } from '@ez4/common'; import type { Email } from '@ez4/email'; // MyEmail declaration export declare class MyEmail extends Email.Service { domain: 'my-domain.com'; } ``` -------------------------------- ### Get a Scheduled Event Source: https://github.com/sbalmt/ez4/blob/main/contracts/scheduler/docs/scheduler-client.md Use `getEvent` to retrieve a scheduled event by its ID. The call returns `undefined` if the event is not found. Ensure the `myScheduler` is available in the context. ```typescript export async function anotherHandler(_request: any, context: Service.Context) { const { myScheduler } = context; const event = await myScheduler.getEvent('scheduler-id'); } ``` -------------------------------- ### Queue Subscription Additional Files Source: https://github.com/sbalmt/ez4/blob/main/contracts/queue/docs/queue-subscriptions.md Includes additional files in the handler bundle, such as static assets or configuration files. Paths are relative to the project root. ```typescript files: ['settings.json']; ``` -------------------------------- ### JSON Body Payload Structure Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/ws-requests.md Example of a typed JSON request body payload. Supports automatic parsing into declared types and includes optional fields. ```typescript body: { action: ActionEnum; value: String.Size<1, 250>; limit?: Integer.Any; } ``` -------------------------------- ### Initialize TypeScript configuration Source: https://github.com/sbalmt/ez4/blob/main/documentation/quick-start.md Initializes a TypeScript configuration file (tsconfig.json) with default settings. This command generates the basic structure for TypeScript compilation. ```sh npx tsc --init ``` -------------------------------- ### Declare Topic Request using Class Source: https://github.com/sbalmt/ez4/blob/main/contracts/topic/docs/topic-requests.md Implement the Topic.Message interface using a class for strongly typed and validated incoming requests. This is the preferred method. ```typescript declare class MyMessage implements Topic.Message { foo: string; bar: number; } ``` -------------------------------- ### Define a Topic Contract Source: https://github.com/sbalmt/ez4/blob/main/contracts/topic/README.md Declare a message type and a topic contract that specifies subscriptions, environment variables, and services. This contract guides EZ4 in generating event handling infrastructure. ```typescript import type { Environment, Service } from '@ez4/common'; import type { Topic } from '@ez4/topic'; // My message declaration declare class MyMessage implements Topic.Message { foo: string; bar: number; } // My topic declaration export declare class MyTopic extends Topic.Unordered { subscriptions: [ Topic.UseSubscription<{ handler: typeof processMessage; }> ]; variables: { myVariable: Environment.Variable<'MY_VARIABLE'>; }; services: { otherService: Environment.Service; variables: Environment.ServiceVariables; }; } ``` -------------------------------- ### Route Preferences Configuration Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/ws-routes.md Defines handler-specific preference options, such as naming style. Use the Ws.UsePreferences type helper for typing suggestions. ```typescript preferences: Ws.UsePreferences<{ namingStyle: NamingStyle.CamelCase; }>; ``` -------------------------------- ### Queue Service Subscriptions with Options Source: https://github.com/sbalmt/ez4/blob/main/contracts/queue/docs/queue-service.md Define multiple subscriptions for a queue service, each with specific configurations like batch size or concurrency. Handlers are referenced by type using 'typeof'. ```typescript subscriptions: [ Queue.UseSubscription<{ handler: typeof processMessageA; batch: 15; }>, Queue.UseSubscription<{ handler: typeof processMessageB; concurrency: 2; }> ]; ``` -------------------------------- ### Handler Configuration Source: https://github.com/sbalmt/ez4/blob/main/contracts/scheduler/docs/scheduler-target.md Define the entry-point function for scheduled events. The handler runs in its own cloud resource and is invoked for every triggered event. ```typescript handler: typeof eventHandler; ``` -------------------------------- ### Handle Service Creation with EZ4 Factory Source: https://github.com/sbalmt/ez4/blob/main/contracts/factory/README.md Implement the factory handler function that receives context with injected variables and services to construct the service instance. ```ts // MyFactory handler export function createMyService(context: Service.Context): MyService { const { otherService, variables } = context; // Access injected services otherService.call(); // Access injected variables variables.myVariable; // Return service instance return new MyService(); } ``` -------------------------------- ### Configure Default Settings Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-service.md Define default configuration for all routes, including payload naming, runtime settings, memory, timeouts, and logging levels. ```typescript defaults: Http.UseDefaults<{ logLevel: LogLevel.Debug; architecture: ArchitectureType.Arm; runtime: RuntimeType.Node24; }>; ``` -------------------------------- ### Define a Minimal EZ4 Distribution Service Source: https://github.com/sbalmt/ez4/blob/main/contracts/distribution/README.md A minimal example of a distribution service definition using EZ4's Cdn.Service. It includes a default index file, a default origin pointing to a bucket, a custom certificate for a domain, and fallback rules for handling specific status codes. ```ts import type { Environment } from '@ez4/common'; import type { Cdn } from '@ez4/distribution'; // MySite declaration export declare class MySite extends Cdn.Service { defaultIndex: 'index.html'; defaultOrigin: Cdn.UseDefaultOrigin<{ bucket: Environment.Service; }>; certificate: Cdn.UseCertificate<{ domain: '*.my-site.tld'; }>; aliases: ['home.my-site.tld']; fallbacks: [ Cdn.UseFallback<{ code: 404; location: '/index.html'; }> ]; } ``` -------------------------------- ### Manage AWS SNS Project Lifecycle via NPM Source: https://github.com/sbalmt/ez4/blob/main/examples/hello-aws-topic/README.md A collection of npm scripts to handle project dependencies, testing, local emulation, and AWS resource lifecycle management. These commands require a configured local.env file with valid AWS credentials. ```bash npm install npm test npm run serve npm run deploy npm run destroy ``` -------------------------------- ### EZ4 Project Configuration Source: https://github.com/sbalmt/ez4/blob/main/documentation/quick-start.md Defines the project configuration for EZ4, including the prefix, project name, source files, and state file settings. This file should be named ez4.project.js. ```js /** * @type {import('@ez4/project').ProjectOptions} */ export default { prefix: 'ez4', projectName: 'hello', sourceFiles: ['./src/api.ts'], stateFile: { path: 'deploy-state', remote: true } }; ``` -------------------------------- ### Seed database items Source: https://github.com/sbalmt/ez4/blob/main/examples/aws-dynamodb-crudl/README.md Populates the DynamoDB table with initial data entries. ```sh npm run seed ``` -------------------------------- ### Define Gateway Provider Variables and Services Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/README.md Declare environment variables and connected services for your gateway provider. These will be automatically injected into the handler context. ```typescript // MyServer route provider interface MyProvider extends Http.Provider { variables: { myVariable: Environment.Variable<'MY_VARIABLE'>; }; services: { otherService: Environment.Service; variables: Environment.ServiceVariables; }; } ``` -------------------------------- ### Enable VPC Access for HTTP Route Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-routes.md Enables VPC access for the route, allowing the handler to access private resources within the default VPC. This may increase cold-start latency. ```typescript vpc: true; ``` -------------------------------- ### Gateway Listener Implementation Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/gateway-listener.md Implement a listener function that receives a typed service event and a provider context. Use a switch statement to handle different event types like Begin, Ready, Done, Error, and End. ```typescript export function myListener(event: Http.ServiceEvent | Ws.ServiceEvent, context: Service.Context) { switch (event.type) { case ServiceEventType.Begin: // Request started. break; case ServiceEventType.Ready: // Validation and transformation completed. break; case ServiceEventType.Done: // Handler execution completed without error. break; case ServiceEventType.Error: // Validation or handler execution error. break; case ServiceEventType.End: // Request finished. break; } } ``` -------------------------------- ### Send an Email Using the Email Service Source: https://github.com/sbalmt/ez4/blob/main/contracts/email/README.md Demonstrates how to send an email from a handler that has access to the injected email service. Ensure the 'from' address matches the configured domain. ```ts import type { Service } from '@ez4/common'; import type { MyEmail } from './email'; // Any other handler that has injected MyEmail service export async function anotherHandler(_request: any, context: Service.Context) { const { myEmail } = context; await myEmail.send({ from: 'sender@my-domain.com', to: ['receiver@my-domain.com'], subject: 'Test email', body: { html: 'Test body' } }); } ``` -------------------------------- ### Http.UseRoute Declaration Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/http-routes.md Defines an HTTP route with its verb, path, handler, authorizer, and error mappings. ```APIDOC ## GET /users/{id} ### Description Defines a GET request to retrieve a user by their ID. ### Method GET ### Endpoint /users/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the user. #### Request Body None ### Response #### Success Response (200) - **user** (object) - Details of the user. #### Response Example { "user": { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "John Doe" } } ### Error Handling - **404** - UserNotFound: Returned when the specified user ID does not exist. - **400** - InvalidInput: Returned when the provided input is invalid. ``` -------------------------------- ### Listener Configuration Source: https://github.com/sbalmt/ez4/blob/main/contracts/scheduler/docs/scheduler-target.md Configure an optional listener to observe scheduler execution events. The listener runs within the same cloud resource as the handler and is useful for logging, tracing, and metrics. ```typescript listener: typeof schedulerListener; ``` -------------------------------- ### Configure Handler Preferences Source: https://github.com/sbalmt/ez4/blob/main/contracts/gateway/docs/gateway-defaults.md Set handler-specific preferences, such as naming style. Use Http.UsePreferences or Ws.UsePreferences for type suggestions. ```typescript preferences: { namingStyle: NamingStyle.SnakeCase; } ``` -------------------------------- ### Use Database Service in a Handler Source: https://github.com/sbalmt/ez4/blob/main/contracts/database/README.md Demonstrates how to use an injected database service within a handler to perform database operations like inserting and finding records. Ensure the handler has access to the MyDb service. ```ts import type { Service } from '@ez4/common'; import type { MyDb } from './db'; // Any other handler that has injected MyDb service export async function anotherHandler(_request: any, context: Service.Context) { const { myDb } = context; // Insert one record await myDb.test_table.insertOne({ data: { foo: 'foo', bar: 123 } }); // Find one record const result = await myDb.test_table.findOne({ select: { bar: true }, where: { foo: 'foo' } }); } ``` -------------------------------- ### Topic Listener Implementation Source: https://github.com/sbalmt/ez4/blob/main/contracts/topic/docs/topic-listener.md Implement a topic listener function that receives typed service events and context. Use a switch statement to handle different event types like Begin, Ready, Done, Error, and End. ```typescript export function topicListener(event: Topic.ServiceEvent, context: Service.Context) { switch (event.type) { case ServiceEventType.Begin: // Message processing started. break; case ServiceEventType.Ready: // Message validation and transformation completed. break; case ServiceEventType.Done: // Message processing completed successfully. break; case ServiceEventType.Error: // Message validation or handler execution error. break; case ServiceEventType.End: // Message processing finished. break; } } ``` -------------------------------- ### Defining a Distribution Service Source: https://github.com/sbalmt/ez4/blob/main/contracts/distribution/README.md How to declare a CDN distribution service using the Cdn.Service class and associated type helpers. ```APIDOC ## Defining a Distribution Service ### Description Defines a CDN distribution service by extending `Cdn.Service`. This configuration handles origin routing, certificate association, and fallback rules. ### Properties - **defaultIndex** (string) - Default index file name. - **certificate** (Cdn.UseCertificate<>) - Custom certificate associated with the distribution. - **fallbacks** (Cdn.UseFallback<>[]) - Fallback rules applied when an origin returns specific status codes. - **defaultOrigin** (Cdn.UseDefaultOrigin<>) - Default origin for the distribution. - **origins** (Cdn.UseOrigin<>) - Distribution origins. - **aliases** (string[]) - List of CNAME aliases for the distribution. - **disabled** (boolean) - Determines whether or not the distribution is disabled. ### Example ```ts export declare class MySite extends Cdn.Service { defaultIndex: 'index.html'; defaultOrigin: Cdn.UseDefaultOrigin<{ bucket: Environment.Service; }>; certificate: Cdn.UseCertificate<{ domain: '*.my-site.tld'; }>; aliases: ['home.my-site.tld']; fallbacks: [Cdn.UseFallback<{ code: 404; location: '/index.html'; }>]; } ``` ```