### Installation and Basic Usage Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/zh/documentation/package/mysql.md Instructions on how to install the @deepkit/mysql package and a basic TypeScript example demonstrating its usage with the Deepkit ORM. ```APIDOC ## Installation To install the `@deepkit/mysql` package, run the following command: ```shell npm install @deepkit/mysql ``` ## Basic Usage This example demonstrates how to set up the MySQL adapter and initialize the Deepkit Database. ### Method TypeScript ### Endpoint N/A ### Parameters N/A ### Request Body N/A ### Request Example ```typescript import { MySQLDatabaseAdapter } from '@deepkit/mysql'; import { Database } from '@deepkit/orm'; // Example using connection string const adapter = new MySQLDatabaseAdapter('mysql://user:password@localhost/mydatabase'); // Example using configuration object // const adapter = new MySQLDatabaseAdapter({ // host: 'localhost', // port: 3306, // user: 'user', // password: 'password', // database: 'mydatabase' // }); const database = new Database(adapter); ``` ### Response N/A ### Response Example N/A ``` -------------------------------- ### Example App Server Output Source: https://github.com/marcj/deepkit/blob/master/DEVELOPMENT.md Log output indicating the server has started successfully. ```shell ... 2023-01-05T23:22:02.199Z [LOG] HTTP listening at http://0.0.0.0:8080 2023-01-05T23:22:02.199Z [LOG] Debugger enabled at http://0.0.0.0:8080/_debug/ 2023-01-05T23:22:02.199Z [LOG] Server started. ``` -------------------------------- ### Installation and Basic Usage Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/broker-redis.md Install the @deepkit/broker-redis package and see a basic TypeScript example of how to initialize the Redis broker adapter and use it with BrokerKeyValue and BrokerBus. ```APIDOC ## Installation ```sh npm install @deepkit/broker-redis ``` ## Basic Usage This adapter provides a Redis-based implementation of the Deepkit Broker using ioredis. It can be used for KeyValue and Bus functionalities. ### Method `new RedisBrokerAdapter(options, logger)` ### Parameters #### Request Body - **options** (object) - Required - Configuration options for the Redis adapter. - **preifx** (string) - Required - A prefix for all keys stored in Redis. - **host** (string) - Required - The hostname of the Redis server. - **port** (number) - Required - The port of the Redis server. - **password** (string) - Optional - The password for Redis authentication. - **db** (number) - Optional - The Redis database to use. - **logger** (object) - Required - An instance of a logger, e.g., `ConsoleLogger` from `@deepkit/logger`. ### Request Example ```typescript import { BrokerKeyValue, BrokerBus } from '@deepkit/broker'; import { BrokerRedisAdapter } from '@deepkit/broker-redis'; import { ConsoleLogger } from '@deepkit/logger'; const adapter = new RedisBrokerAdapter({ preifx: 'myapp:', host: 'localhost', port: 6379, // password: 'your-password', // Optional, if your Redis server requires authentication // db: 0, // Optional, to specify a different Redis database }, new ConsoleLogger()); const keyValye = new BrokerKeyValue(adapter); const bus = new BrokerBus(adapter); // ... ``` ### Note This adapter does not implement the queue adapter of Deepkit Broker. ``` -------------------------------- ### Installation and Basic Usage Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/zh/documentation/package/postgres.md This snippet shows how to install the @deepkit/postgres package using npm and provides a basic example of connecting to a PostgreSQL database using the `PostgresDatabaseAdapter` and `Database` classes from Deepkit ORM. ```APIDOC ## Installation Install the package using npm: ```shell npm install @deepkit/postgres ``` ## Basic Usage Connect to a PostgreSQL database using the `PostgresDatabaseAdapter` and initialize the `Database`. ### Code Example ```typescript import { PostgresDatabaseAdapter } from '@deepkit/postgres'; import { Database } from '@deepkit/orm'; // Example using a connection string const adapter = new PostgresDatabaseAdapter('postgres://user:password@localhost/mydatabase'); // Example using connection options // const adapter = new PostgresDatabaseAdapter({ host: 'localhost', database: 'postgres', user: 'postgres' }); const database = new Database(adapter); ``` ### Description This example demonstrates the fundamental steps to integrate Deepkit ORM with a PostgreSQL database. It covers: 1. **Importing necessary classes**: `PostgresDatabaseAdapter` for establishing the connection and `Database` for ORM functionalities. 2. **Instantiating `PostgresDatabaseAdapter`**: This can be done either by providing a full connection string or by passing an object with connection details like host, database name, and user. 3. **Initializing `Database`**: The `Database` instance is created with the configured adapter, making it ready for ORM operations. ``` -------------------------------- ### Deepkit Framework Setup Source: https://github.com/marcj/deepkit/blob/master/README.md Provides the necessary commands to clone the Deepkit framework repository, install dependencies, and build the project. The postinstall script is required to build the type compiler. ```bash git clone https://github.com/deepkit/deepkit-framework.git cd deepkit-framework npm install npm run postinstall # Required: builds the type compiler npm run build ``` -------------------------------- ### Installation and Basic Usage Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/run.md Install the @deepkit/run package using npm and demonstrate its basic usage with a simple TypeScript example. ```APIDOC ## Installation ```sh npm install @deepkit/run ``` ## Basic Usage This tool allows you to run TypeScript code directly without a build step. It's particularly useful for testing and development. ### Example TypeScript File (`test.ts`) ```typescript import { typeOf } from '@deepkit/type'; console.log(typeOf()); ``` ### Running the TypeScript File Use the `node --import @deepkit/run` command to execute your TypeScript file: ```sh node --import @deepkit/run test.ts ``` This command will execute `test.ts` using Node.js, with the `@deepkit/run` module handling the TypeScript compilation and execution on the fly. ``` -------------------------------- ### Basic Deepkit App Setup with Framework Module Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/questions/_http-old.md This snippet shows the minimal setup for a Deepkit application, including the necessary FrameworkModule for HTTP functionalities. It's a common starting point for web applications. ```typescript import { Positive } from '@deepkit/type'; import { http, HttpRouterRegistry } from '@deepkit/http'; import { FrameworkModule } from "@deepkit/framework"; const app = new App({ imports: [new FrameworkModule()] }); ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/filesystem-sftp.md Instructions for installing the @deepkit/filesystem-sftp package. ```APIDOC ## Installation ### Description Install the package via npm to enable SFTP filesystem support in your Deepkit project. ### Command `npm install @deepkit/filesystem-sftp` ``` -------------------------------- ### Installation and Basic Usage Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/de/documentation/package/sqlite.md This snippet shows how to install the @deepkit/sqlite package using npm and provides a basic TypeScript example of setting up an in-memory SQLite database with Deepkit ORM. ```APIDOC ## Installation Install the package using npm: ```shell npm install @deepkit/sqlite ``` ## Basic Usage This example demonstrates how to initialize an in-memory SQLite database and use it with Deepkit ORM. ### Method Initialization and Database Setup ### Endpoint N/A (Local setup) ### Parameters N/A ### Request Example ```typescript import { SQLiteDatabaseAdapter } from '@deepkit/sqlite'; import { Database } from '@deepkit/orm'; // Initialize an in-memory SQLite database adapter const adapter = new SQLiteDatabaseAdapter(':memory'); // Create a Database instance using the adapter const database = new Database(adapter); console.log('SQLite database initialized successfully.'); ``` ### Response No direct API response for initialization. Success is indicated by the absence of errors during execution. #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Run Example Application Source: https://github.com/marcj/deepkit/blob/master/DEVELOPMENT.md Commands to launch the example application and its server. ```shell deepkit-framework » cd packages/example-app deepkit-framework/packages/example-app » npm run app ``` ```shell deepkit-framework/packages/example-app » npm run start ``` -------------------------------- ### Initialize and Use Broker Key-Value Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/broker/key-value.md Demonstrates basic setup of BrokerKeyValue and item-level operations like set, get, and remove. ```typescript import { BrokerKeyValue } from '@deepkit/broker'; const keyValue = new BrokerKeyValue(adapter, { ttl: '60s', // time to live for each key. 0 means no ttl (default). }); const item = keyValue.item('key1'); await item.set(123); console.log(await item.get()); //123 await item.remove(); ``` -------------------------------- ### Basic Deepkit Application Structure Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/framework/deployment.md This is a foundational example of a Deepkit application, demonstrating configuration, controllers, and module imports. It's suitable for getting started with a simple web service. ```typescript #!/usr/bin/env ts-node-script import { App } from '@deepkit/app'; import { FrameworkModule } from '@deepkit/framework'; import { http } from '@deepkit/http'; class Config { title: string = 'DEV my Page'; } class MyWebsite { constructor(protected title: Config['title']) { } @http.GET() helloWorld() { return 'Hello from ' + this.title; } } new App({ config: Config, controllers: [MyWebsite], imports: [new FrameworkModule] }) .loadConfigFromEnv() .run(); ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/marcj/deepkit/blob/master/examples/rpc-websockets/README.md Run this command to install project dependencies. The postinstall script automatically installs the Deepkit type compiler. ```bash # postinstall script automatically installs deepkit type compiler npm install ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/de/documentation/package/filesystem-google.md Install the @deepkit/filesystem-google package using npm. ```APIDOC ## Installation ### Description Install the `@deepkit/filesystem-google` package using npm. ### Command ```shell npm install @deepkit/filesystem-google ``` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/ko/documentation/package/filesystem-sftp.md Install the @deepkit/filesystem-sftp package using npm. ```APIDOC ## Installation Install the @deepkit/filesystem-sftp package using npm. ### Command ```shell npm install @deepkit/filesystem-sftp ``` ``` -------------------------------- ### Installation and Overview Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/app.md Installation instructions and core functionality overview for the @deepkit/app package. ```APIDOC ## Installation ### Command `npm install @deepkit/app` ## Overview ### Description The `@deepkit/app` package serves as the foundation for all Deepkit applications. It provides the necessary tools for service management, dependency injection, CLI command registration, and modular application configuration. ### Core Features - **Service Container & Dependency Injection**: Manage application services and their dependencies. - **CLI Parser**: Register and execute command-line interface controllers. - **Event Dispatcher**: Handle application-wide events. - **Module System**: Organize application logic into reusable modules. - **Configuration Loader**: Manage application settings and environment configurations. ``` -------------------------------- ### Start Development Server Source: https://github.com/marcj/deepkit/blob/master/packages/framework-debug-gui/README.md Starts the local development server and enables automatic reloading. ```bash ng serve ``` -------------------------------- ### Installation and Initialization Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/mongo.md Instructions for installing the package and initializing the MongoDB database adapter within the Deepkit ORM framework. ```APIDOC ## Installation ### Command `npm install @deepkit/mongo` ## Initialization ### Description Initialize the MongoDB database adapter and connect it to the Deepkit ORM Database instance. ### Code Example ```typescript import { MongoDatabaseAdapter } from '@deepkit/mongo'; import { Database } from '@deepkit/orm'; const adapter = new MongoDatabaseAdapter('mongodb://localhost:27017/mydatabase'); const database = new Database(adapter); ``` ``` -------------------------------- ### Build Output Example Source: https://github.com/marcj/deepkit/blob/master/DEVELOPMENT.md Example of the successful build output from Lerna. ```shell > build > build > tsc --build tsconfig.json && tsc --build tsconfig.esm.json && lerna run build lerna notice cli v7.4.1 ✔ @deepkit/core:build (320ms) ✔ @deepkit/topsort:build (324ms) ✔ @deepkit/type-spec:build (324ms) ✔ @deepkit/core-rxjs:build (326ms) ✔ @deepkit/filesystem:build (326ms) ... ✔ @deepkit/api-console-gui:build (19s) ✔ @deepkit/api-console-module:build (297ms) ✔ @deepkit/orm-browser-gui:build (21s) ✔ @deepkit/framework-debug-gui:build (29s) ✔ @deepkit/orm-browser:build (295ms) —————————————————————————————————————————————— > Lerna (powered by Nx) Successfully ran target build for 43 projects (1m) ``` -------------------------------- ### Installation and Basic Usage Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/ja/documentation/package/sqlite.md This snippet shows how to install the @deepkit/sqlite package and initialize a SQLite database in memory using the Deepkit ORM. ```APIDOC ## Installation Install the package using npm: ```shell npm install @deepkit/sqlite ``` ## Basic Usage Initialize a SQLite database in memory and integrate it with the Deepkit ORM. ### Method ```typescript import { SQLiteDatabaseAdapter } from '@deepkit/sqlite'; import { Database } from '@deepkit/orm'; const adapter = new SQLiteDatabaseAdapter(':memory'); const database = new Database(adapter); ``` ### Description This example demonstrates the basic setup for using the `@deepkit/sqlite` package. It involves importing the necessary classes, creating an in-memory SQLite database adapter, and then initializing the `Database` instance from the Deepkit ORM with this adapter. ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/desktop-ui.md Instructions for installing the @deepkit/desktop-ui package via npm. ```APIDOC ## Installation ### Description Install the @deepkit/desktop-ui package to start building desktop interfaces. ### Command `npm install @deepkit/desktop-ui` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/vite.md Instructions on how to install the @deepkit/vite package using npm. ```APIDOC ## Installation To install the `@deepkit/vite` package, use the following npm command: ```shell npm install @deepkit/vite ``` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/filesystem-google.md Instructions for installing the Google Cloud Storage filesystem package for Deepkit. ```APIDOC ## Installation ### Description Install the package via npm to enable Google Cloud Storage support. ### Command ```shell npm install @deepkit/filesystem-google ``` ``` -------------------------------- ### Installation and Usage Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/ko/documentation/package/rpc-tcp.md Instructions on how to install the @deepkit/rpc-tcp package and a placeholder for API documentation. ```APIDOC ## Installation ```shell npm install @deepkit/rpc-tcp ``` ## API Documentation Placeholder This section would typically contain detailed API endpoint documentation, including methods, parameters, request/response examples, and error handling for the `@deepkit/rpc-tcp` package. The `` tag suggests that detailed documentation is generated or available elsewhere. ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/filesystem-ftp.md Install the @deepkit/filesystem-ftp package using npm. ```APIDOC ## Installation Install the `@deepkit/filesystem-ftp` package using npm: ```shell npm install @deepkit/filesystem-ftp ``` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/bson.md How to install the @deepkit/bson package via npm. ```APIDOC ## Installation ### Command `npm install @deepkit/bson` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/filesystem.md Instructions for installing the @deepkit/filesystem package via npm. ```APIDOC ## Installation ### Description Install the @deepkit/filesystem package to your project using npm. ### Command `npm install @deepkit/filesystem` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/sql.md Instructions for installing the @deepkit/sql package via npm. ```APIDOC ## Installation ### Description Install the @deepkit/sql package using npm. ### Command `npm install @deepkit/sql` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/rpc-tcp.md How to install the @deepkit/rpc-tcp package via npm. ```APIDOC ## Installation ### Description Install the package using npm to enable TCP-based RPC communication in your project. ### Command ```shell npm install @deepkit/rpc-tcp ``` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/filesystem-database.md Instructions for installing the @deepkit/filesystem-database package via npm. ```APIDOC ## Installation ### Command `npm install @deepkit/filesystem-database` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/ja/documentation/package/filesystem-aws-s3.md Instructions for installing the AWS S3 filesystem driver for Deepkit. ```APIDOC ## Installation ### Description Install the package via npm to enable AWS S3 support in your Deepkit project. ### Command `npm install @deepkit/filesystem-aws-s3` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/bun.md Install the @deepkit/bun package using npm. ```APIDOC ## Installation Install the @deepkit/bun package using npm. ### Command ```shell npm install @deepkit/bun ``` ``` -------------------------------- ### Install sFTP adapter Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem/sftp.md Install the required package via npm. ```sh npm install @deepkit/filesystem-sftp ``` -------------------------------- ### Clone and Install Deepkit Framework Source: https://github.com/marcj/deepkit/blob/master/DEVELOPMENT.md Initializes the repository and installs necessary dependencies using Yarn. ```shell git clone https://github.com/deepkit/deepkit-framework.git cd deepkit-framework yarn ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/core-rxjs.md Instructions for installing the @deepkit/core-rxjs package via npm. ```APIDOC ## Installation ### Description Install the package using npm to begin using Deepkit's RxJS utilities. ### Command `npm install @deepkit/core-rxjs` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/filesystem-aws-s3.md Install the @deepkit/filesystem-aws-s3 package using npm. ```APIDOC ## Installation Install the `@deepkit/filesystem-aws-s3` package using npm. ### Command ```shell npm install @deepkit/filesystem-aws-s3 ``` ``` -------------------------------- ### Install FTP Filesystem Adapter Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem/ftp.md Install the required package via npm. ```bash npm install @deepkit/filesystem-ftp ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/stopwatch.md Instructions for installing the @deepkit/stopwatch package via npm. ```APIDOC ## Installation ### Description Install the package using npm to start using the stopwatch functionality. ### Command `npm install @deepkit/stopwatch` ``` -------------------------------- ### Start HTTP Server Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/framework.md Start the Deepkit Framework HTTP server using the CLI command. ```sh $ ./node_modules/.bin/ts-node ./app.ts server:start ``` -------------------------------- ### Install @deepkit/bench Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/bench.md Use npm to install the benchmarking package. ```sh npm install @deepkit/bench ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/injector.md Instructions for installing the @deepkit/injector package via npm. ```APIDOC ## Installation ### Description Install the @deepkit/injector package to enable dependency injection in your project. ### Command `npm install @deepkit/injector` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/event.md Instructions for installing the @deepkit/event package via npm. ```APIDOC ## Installation ### Command `npm install @deepkit/event` ``` -------------------------------- ### Install Database Filesystem Dependencies Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem/database.md Install the necessary packages for the Database Filesystem adapter and ORM. ```sh npm install @deepkit/filesystem-database @deepkit/orm ``` -------------------------------- ### Install Deepkit App Dependencies Manually Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/app.md Install the core Deepkit App package along with TypeScript and ts-node for manual project setup. ```bash mkdir my-project && cd my-project npm install typescript ts-node npm install @deepkit/app @deepkit/type @deepkit/type-compiler ``` -------------------------------- ### PostgresDatabaseAdapter Initialization Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/de/documentation/package/postgres.md Demonstrates how to install the package and initialize the database adapter using a connection string or configuration object. ```APIDOC ## Initialization ### Description Initializes the PostgreSQL database adapter for use with the Deepkit ORM. ### Installation `npm install @deepkit/postgres` ### Usage ```typescript import { PostgresDatabaseAdapter } from '@deepkit/postgres'; import { Database } from '@deepkit/orm'; // Using connection string const adapter = new PostgresDatabaseAdapter('postgres://user:password@localhost/mydatabase'); // Using configuration object // const adapter = new PostgresDatabaseAdapter({ host: 'localhost', database: 'postgres', user: 'postgres' }); const database = new Database(adapter); ``` ``` -------------------------------- ### Install Google Storage Filesystem Adapter Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem/google-storage.md Install the necessary package for the Google Storage filesystem adapter. ```sh npm install @deepkit/filesystem-google ``` -------------------------------- ### Initialize Filesystem with Database Adapter Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem/database.md Set up the Filesystem with a Database ORM adapter. Uncomment the desired database adapter for your setup. ```typescript import { Filesystem } from '@deepkit/filesystem'; import { FilesystemDatabaseAdapter } from '@deepkit/filesystem-database'; const database = new Database(new MemoryDatabaseAdapter()); // const database = new Database(new PostgresDatabaseAdapter()); // const database = new Database(new MongoDatabaseAdapter()); // const database = new Database(new MysqlDatabaseAdapter()); // const database = new Database(new SQLiteDatabaseAdapter()); const adapter = new FilesystemDatabaseAdapter({ database }); const filesystem = new Filesystem(adapter); ``` -------------------------------- ### Start Development Server Source: https://github.com/marcj/deepkit/blob/master/website/README.md Launches the local development environment. Requires Node v22 and a configured local Postgres database. ```sh npm run dev ``` -------------------------------- ### Install @deepkit/core-rxjs Source: https://github.com/marcj/deepkit/blob/master/packages/core-rxjs/README.md Use npm to install the package as a dependency in your project. ```bash npm install @deepkit/core-rxjs ``` -------------------------------- ### Install @deepkit/core Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/core.md Install the @deepkit/core package using npm. This is the first step to using the library. ```shell npm install @deepkit/core ``` -------------------------------- ### Basic Dependency Injection Setup Source: https://context7.com/marcj/deepkit/llms.txt Demonstrates setting up services and the application using Deepkit DI. Providers are auto-discovered from constructor types. ```typescript import { App } from '@deepkit/app'; // Services - no decorators needed class Logger { log(message: string) { console.log(`[LOG] ${message}`); } } class ConfigService { readonly apiUrl = 'https://api.example.com'; readonly timeout = 5000; } class HttpClient { constructor( private logger: Logger, private config: ConfigService ) {} async get(path: string): Promise { this.logger.log(`GET ${this.config.apiUrl}${path}`); // Implementation... return { data: 'example' }; } } class UserService { constructor( private http: HttpClient, private logger: Logger ) {} async getUser(id: number) { this.logger.log(`Fetching user ${id}`); return this.http.get(`/users/${id}`); } } // App setup - providers are auto-discovered from constructor types const app = new App({ providers: [ Logger, ConfigService, HttpClient, UserService ] }); // Get service instance const userService = app.get(UserService); await userService.getUser(1); ``` -------------------------------- ### Deepkit Quick Start Source: https://github.com/marcj/deepkit/blob/master/README.md Commands to initialize a new Deepkit application. ```bash npm init @deepkit/app@latest my-app cd my-app npm start ``` -------------------------------- ### Start Deepkit Server Source: https://github.com/marcj/deepkit/blob/master/packages/create-app/files/README.md Use this command to start the Deepkit HTTP/RPC server. It logs server status and listening details. ```sh $ npm run app server:start 2022-08-07T21:25:32.567Z [LOG] Start server ... 2022-08-07T21:25:32.569Z [LOG] RPC Controller HelloWorldControllerRpc /main 2022-08-07T21:25:32.569Z [LOG] 1 HTTP routes 2022-08-07T21:25:32.569Z [LOG] HTTP Controller HelloWorldControllerHttp 2022-08-07T21:25:32.569Z [LOG] GET /hello/:name 2022-08-07T21:25:32.569Z [LOG] HTTP listening at http://0.0.0.0:8080 2022-08-07T21:25:32.569Z [LOG] Server started. ``` -------------------------------- ### Install Deepkit Broker Redis Adapter Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/broker-redis.md Use npm to install the package in your project. ```sh npm install @deepkit/broker-redis ``` -------------------------------- ### Initialize MySQL Database Adapter Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/mysql.md Demonstrates how to install the package and initialize the MySQLDatabaseAdapter for the Deepkit ORM. ```APIDOC ## Initialization ### Description Installs the @deepkit/mysql package and configures the database adapter for the Deepkit ORM. ### Installation ```shell npm install @deepkit/mysql ``` ### Usage Example ```typescript import { MySQLDatabaseAdapter } from '@deepkit/mysql'; import { Database } from '@deepkit/orm'; const adapter = new MySQLDatabaseAdapter({host: 'localhost', port: 3306}); const database = new Database(adapter); ``` ``` -------------------------------- ### Define Route with Class Controller API Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/questions/http.md Defines an HTTP route using a class and decorators. This example creates a GET route '/hello' that returns 'Hello, World!'. ```typescript import { http, HttpRouterRegistry } from '@deepkit/http'; class MyController { @http.GET('/hello') hello() { return 'Hello, World!'; } } const app = new App({ controllers: [MyController] }); app.run(); ``` -------------------------------- ### Application Integration with BrokerKeyValue Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/zh/documentation/broker/key-value.md Example of using BrokerKeyValue within an application, making it available via dependency injection. Ensure to handle potential undefined return values from get. ```typescript import { BrokerKeyValue, BrokerKeyValueItem } from '@deepkit/broker'; import { FrameworkModule } from '@deepkit/framework'; // 将此类型移动到一个共享文件中 type MyKeyValueItem = BrokerKeyValueItem; class Service { constructor(private keyValueItem: MyKeyValueItem) { } async getTopUsers(): Promise { // 可能为 undefined。你需要处理这种情况。 // 如果你想避免这种情况,请使用 Broker Cache。 return await this.keyValueItem.get(); } } const app = new App({ providers: [ Service, provide((keyValue: BrokerKeyValue) => keyValue.item('top-users')), ], imports: [ new FrameworkModule(), ], }); ``` -------------------------------- ### Start RPC Client Source: https://github.com/marcj/deepkit/blob/master/packages/create-app/files/README.md Execute the command to start the Deepkit RPC client. This is used to interact with RPC controllers. ```sh $ npm run client-rpc # or if supported $ ./client.rpc.ts ``` -------------------------------- ### Install @deepkit/template Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/de/documentation/package/template.md Install the @deepkit/template package using npm. This is the first step to using the template engine. ```shell npm install @deepkit/template ``` -------------------------------- ### Install @deepkit/app Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/cli/getting-started.md Install the @deepkit/app package using npm. Ensure Runtime Types are installed first. ```sh npm install @deepkit/app ``` -------------------------------- ### Initialize Local Filesystem Adapter Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem/local.md Instantiate the local filesystem adapter with a specified root directory and create a Filesystem instance. No additional installation is required as it uses Node.js's `fs/promises`. ```typescript import { FilesystemLocalAdapter, Filesystem } from '@deepkit/filesystem'; const adapter = new FilesystemLocalAdapter({ root: '/path/to/files' }); const filesystem = new Filesystem(adapter); ``` -------------------------------- ### Initialize FTP Filesystem Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem/ftp.md Configure the adapter with server credentials and initialize the filesystem instance. ```typescript import { Filesystem } from '@deepkit/filesystem'; import { FilesystemFtpAdapter } from '@deepkit/filesystem-ftp'; const adapter = new FilesystemFtpAdapter({ root: 'folder', host: 'localhost', port: 21, username: 'user', password: 'password', }); const filesystem = new Filesystem(adapter); ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/ja/documentation/package/http.md Install the @deepkit/http package using npm. ```APIDOC ## Installation To install the `@deepkit/http` package, run the following command: ```shell npm install @deepkit/http ``` ``` -------------------------------- ### Initialize sFTP Filesystem Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem/sftp.md Configure the adapter with connection details and initialize the filesystem. ```typescript import { Filesystem } from '@deepkit/filesystem'; import { FilesystemSftpAdapter } from '@deepkit/filesystem-sftp'; const adapter = new FilesystemSftpAdapter({ root: 'folder', host: 'localhost', port: 22, username: 'user', password: 'password', }); const filesystem = new Filesystem(adapter); ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/template.md Install the @deepkit/template package using npm. ```APIDOC ## Installation ### Description Install the `@deepkit/template` package using npm. ### Command ```shell npm install @deepkit/template ``` ``` -------------------------------- ### Initialize Bun Project Source: https://github.com/marcj/deepkit/blob/master/packages/bun/README.md Initializes a new Bun project in the current directory. ```sh bun init ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/type-compiler.md Install the @deepkit/type-compiler package using npm. ```APIDOC ## Installation To use the @deepkit/type-compiler package, install it via npm: ### Command ```shell npm install @deepkit/type-compiler ``` ``` -------------------------------- ### Basic DI Container Setup Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/dependency-injection.md Initialize a DI container with a list of providers (classes) and retrieve an instance of a service. This is useful for managing dependencies in your application without manual instantiation. ```typescript import { InjectorContext } from '@deepkit/injector'; const injector = InjectorContext.forProviders( [UserRepository, HttpClient] ); const userRepo = injector.get(UserRepository); const users = await userRepo.getUsers(); ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/rpc.md Install the @deepkit/rpc package using npm. ```shell npm install @deepkit/rpc ``` -------------------------------- ### Full Application Setup with Deepkit Source: https://context7.com/marcj/deepkit/llms.txt This snippet shows a complete Deepkit application configuration, including modules, controllers, listeners, and command registration. It demonstrates loading configuration from environment variables and running the application. ```typescript import { App, onServerMainBootstrapDone } from '@deepkit/app'; import { FrameworkModule } from '@deepkit/framework'; import { http, HttpBody } from '@deepkit/http'; import { rpc } from '@deepkit/rpc'; import { Database } from '@deepkit/orm'; import { SQLiteDatabaseAdapter } from '@deepkit/sqlite'; import { Logger, LoggerInterface } from '@deepkit/logger'; import { entity, PrimaryKey, AutoIncrement, MinLength, Email } from '@deepkit/type'; // Configuration class AppConfig { environment: 'development' | 'production' = 'development'; dbPath: string = 'app.db'; port: number = 3000; } // Entity @entity.name('user') class User { id: number & PrimaryKey & AutoIncrement = 0; createdAt: Date = new Date(); constructor( public username: string & MinLength<3>, public email: string & Email ) {} } // Database service class AppDatabase extends Database { constructor(config: AppConfig) { super(new SQLiteDatabaseAdapter(config.dbPath), [User]); } } // HTTP Controller @http.controller('/api') class ApiController { constructor( private database: AppDatabase, private logger: LoggerInterface ) {} @http.GET('/users') async listUsers() { return this.database.query(User).find(); } @http.POST('/users') async createUser(body: HttpBody<{ username: string & MinLength<3>, email: string & Email }>) { const user = new User(body.username, body.email); await this.database.persist(user); this.logger.log('Created user:', user.username); return user; } @http.GET('/users/:id') async getUser(id: number) { return this.database.query(User).filter({ id }).findOne(); } } // RPC Controller @rpc.controller('users') class UserRpcController { constructor(private database: AppDatabase) {} @rpc.action() async getUser(id: number): Promise { return this.database.query(User).filter({ id }).findOneOrUndefined(); } @rpc.action() async searchUsers(query: string): Promise { return this.database.query(User) .filter({ username: { $like: `%${query}%` } }) .find(); } } // CLI Command import { Command, Flag } from '@deepkit/app'; class SeedCommand { constructor(private database: AppDatabase) {} async execute( @Flag({ description: 'Number of users to create' }) count: number = 10 ) { for (let i = 0; i < count; i++) { const user = new User(`user${i}`, `user${i}@example.com`); await this.database.persist(user); } console.log(`Created ${count} users`); } } // Application const app = new App({ config: AppConfig, providers: [AppDatabase], controllers: [ApiController, UserRpcController], listeners: [ onServerMainBootstrapDone.listen((event, logger: LoggerInterface, config: AppConfig) => { logger.log(`Server started in ${config.environment} mode on port ${config.port}`); }) ], imports: [ new FrameworkModule({ port: 3000, migrateOnStartup: true, debug: true }) ] }) .command('seed', SeedCommand) .setup((module, config: AppConfig) => { if (config.environment === 'production') { module.getImportedModuleByClass(FrameworkModule).configure({ debug: false }); } }); // Load config from environment variables and run app.loadConfigFromEnv({ prefix: 'APP_' }).run(); ``` -------------------------------- ### Filesystem Constructor Options Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem.md Illustrates the various options available when constructing a `Filesystem` instance, including default visibility settings, path normalization, URL building, and base URL configuration. ```typescript const filesystem = new Filesystem(new FilesystemLocalAdapter('/path/to/my/files'), { visibility: 'private', //default visibility for files directoryVisibility: 'private', //default visibility for directories pathNormalizer: (path: string) => path, //normalizes the path. By default it replaces `[^a-zA-Z0-9\.\-\_]` with `-`. urlBuilder: (path: string) => path, //builds the public url for a file. By default it returns baseUrl + path baseUrl: '', //base url for public urls }); ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/framework.md Install the @deepkit/framework package using npm. ```shell npm install @deepkit/framework ``` -------------------------------- ### SQLite Database Initialization Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/sqlite.md Demonstrates how to install the package and initialize a new SQLite database connection using the Deepkit ORM. ```APIDOC ## Initialization ### Description Install the @deepkit/sqlite package and configure the database adapter for use with the Deepkit ORM. ### Installation ```shell npm install @deepkit/sqlite ``` ### Usage Example ```typescript import { SQLiteDatabaseAdapter } from '@deepkit/sqlite'; import { Database } from '@deepkit/orm'; const adapter = new SQLiteDatabaseAdapter(':memory'); const database = new Database(adapter); ``` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/logger.md Install the @deepkit/logger package using npm. ```sh npm install @deepkit/logger ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/core.md Install the @deepkit/core package using npm. ```APIDOC ## Installation Install the @deepkit/core package using npm. ### Command ```shell npm install @deepkit/core ``` ``` -------------------------------- ### Initialize Local Filesystem Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/filesystem.md Initialize a local filesystem adapter pointing to a specific directory and create a Filesystem instance. ```typescript import { Filesystem, FilesystemLocalAdapter } from '@deepkit/filesystem'; const adapter = new FilesystemLocalAdapter('/path/to/my/files'); const filesystem = new Filesystem(adapter); ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/broker.md Install the @deepkit/broker package using npm. ```APIDOC ## Installation ### Description Install the @deepkit/broker package using npm. ### Command ```sh npm install @deepkit/broker ``` ``` -------------------------------- ### Install @deepkit/workflow Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/de/documentation/package/workflow.md Install the @deepkit/workflow package using npm. ```shell npm install @deepkit/workflow ``` -------------------------------- ### Initialize Database and Migrate Schema Source: https://context7.com/marcj/deepkit/llms.txt Sets up a database connection using a specified adapter (e.g., SQLite) and initializes the schema. Use migrations for production environments. ```typescript import { Database } from '@deepkit/orm'; import { SQLiteDatabaseAdapter } from '@deepkit/sqlite'; // Or: import { PostgresDatabaseAdapter } from '@deepkit/postgres'; // Or: import { MySQLDatabaseAdapter } from '@deepkit/mysql'; // Or: import { MongoDatabaseAdapter } from '@deepkit/mongo'; // Initialize database const database = new Database( new SQLiteDatabaseAdapter('app.db'), [User, Post, Tag, PostTag] ); // Create tables (development only - use migrations in production) await database.migrate(); ``` -------------------------------- ### Project Directory Structure Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/framework/public.md Example file structure showing a publicDir folder containing static assets. ```text . ├── app.ts └── publicDir └── logo.jpg ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/type.md Instructions for installing the @deepkit/type package via npm. ```APIDOC ## Installation ### Description Install the @deepkit/type package to enable runtime type reflection in your TypeScript project. ### Command `npm install @deepkit/type` ``` -------------------------------- ### Build Project Source: https://github.com/marcj/deepkit/blob/master/packages/framework-debug-gui/README.md Compiles the application and stores artifacts in the dist directory. ```bash ng build ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/workflow.md Instructions for installing the @deepkit/workflow package via npm. ```APIDOC ## Installation ### Description Install the @deepkit/workflow package to start using workflow management features in your project. ### Command `npm install @deepkit/workflow` ``` -------------------------------- ### Install @deepkit/sqlite Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/sqlite.md Install the @deepkit/sqlite package using npm. ```shell npm install @deepkit/sqlite ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/topsort.md Instructions for installing the @deepkit/topsort package via npm. ```APIDOC ## Installation ### Description Install the package using npm to include topological sorting capabilities in your project. ### Command `npm install @deepkit/topsort` ``` -------------------------------- ### Install @deepkit/mysql Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/mysql.md Install the @deepkit/mysql package using npm. ```shell npm install @deepkit/mysql ``` -------------------------------- ### Instantiate App with Module Configuration Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/app/configuration.md Shows how to instantiate the Deepkit App and provide initial configuration values to a module via its constructor. ```typescript import { MyModule } from './module.ts'; new App({ imports: [new MyModule({title: 'Hello World'})], }).run(); ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/orm.md Instructions for installing the @deepkit/orm package via npm. ```APIDOC ## Installation ### Description Install the Deepkit ORM package to your project dependencies. ### Command `npm install @deepkit/orm` ``` -------------------------------- ### Install @deepkit/mongo Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/mongo.md Install the @deepkit/mongo package using npm. ```shell npm install @deepkit/mongo ``` -------------------------------- ### Initialize and Use Google Storage Adapter Source: https://github.com/marcj/deepkit/blob/master/packages/filesystem-google/README.md Configures the storage adapter using either a key file or direct credentials, then performs basic file operations. ```typescript import { Storage } from '@deepkit/filesystem'; import { StorageGoogleAdapter } from '@deepkit/filesystem-google'; const storage = new Storage(new StorageGoogleAdapter({ bucket: 'my-bucket', path: 'my-path/', projectId: 'my-project-id', keyFilename: '/path/to/keyfile.json', //or credentials: { client_email: '...', private_key: '...', } })); const files = await storage.files(); await storage.write('test.txt', 'hello world'); ``` -------------------------------- ### Usage Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/package/filesystem-ftp.md Example of how to use the FTP filesystem with Deepkit. ```APIDOC ## Usage Use the `` component to generate documentation for the FTP filesystem: ```html ``` ``` -------------------------------- ### Define and Use BrokerQueue Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/broker/message-queue.md Demonstrates how to initialize BrokerQueue, define a typed channel with processing options, and consume/produce messages. Ensure the adapter is provided. ```typescript import { BrokerQueue, BrokerQueueChannel } from '@deepkit/broker'; const queue = new BrokerQueue(adapter); type User = { id: number, username: string }; const registrationChannel = queue.channel('user/registered', { process: QueueMessageProcessing.exactlyOnce, deduplicationInterval: '1s', }); // a worker consumes the messages. // this is usually done in a separate process. await registrationChannel.consume(async (user) => { console.log('User registered', user); // if the worker crashes here, the message is not lost. // it will be automatically redelivered to another worker. // if this callback returns without an error, the message is // marked as processed and eventually removed. }); // the application sending the message await registrationChannel.produce({ id: 1, username: 'Peter' }); ``` -------------------------------- ### Install Deepkit HTTP Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/http/getting-started.md Install the package via npm. ```sh npm install @deepkit/http ``` -------------------------------- ### Start Deepkit Server Source: https://github.com/marcj/deepkit/blob/master/website/src/pages/documentation/framework/database.md Command to launch the Deepkit application server, which initializes the ORM browser and other services. ```sh $ ts-node app.ts server:start 2021-06-11T15:08:54.330Z [LOG] Start HTTP server, using 1 workers. 2021-06-11T15:08:54.333Z [LOG] Migrate database default 2021-06-11T15:08:54.336Z [LOG] RPC DebugController deepkit/debug/controller 2021-06-11T15:08:54.337Z [LOG] RPC OrmBrowserController orm-browser/controller 2021-06-11T15:08:54.337Z [LOG] HTTP OrmBrowserController 2021-06-11T15:08:54.337Z [LOG] GET /_orm-browser/query httpQuery 2021-06-11T15:08:54.337Z [LOG] HTTP StaticController 2021-06-11T15:08:54.337Z [LOG] GET /_debug/:any serviceApp 2021-06-11T15:08:54.337Z [LOG] HTTP listening at http://localhost:8080/ ``` -------------------------------- ### Deepkit Injector Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/ko/documentation/package/injector.md Install the @deepkit/injector package using npm. ```APIDOC ## Installation ### Description Install the `@deepkit/injector` package using npm. ### Command ```bash npm install @deepkit/injector ``` ``` -------------------------------- ### Installation Source: https://github.com/marcj/deepkit/blob/master/website/src/translations/ja/documentation/package/orm.md Instructions for installing the Deepkit ORM package via npm. ```APIDOC ## Installation ### Description Install the @deepkit/orm package to start using the ORM in your project. ### Command `npm install @deepkit/orm` ```