├── .env.sample ├── .github ├── ISSUE_TEMPLATE │ └── config.yml └── workflows │ ├── build-and-push.yml │ ├── build-dev.yml │ ├── deploy-lib.yml │ ├── push-openapi-specs.yml │ └── release-to-panel.yml ├── .gitignore ├── .hygen.js ├── .hygen └── new │ └── queue │ ├── enums │ ├── index.ejs.t │ └── job-names.enum.ejs.t │ ├── index.ejs.t │ ├── prompt.js │ ├── queue.module.ejs.t │ ├── queue.processor.ejs.t │ └── queue.service.ejs.t ├── .npmrc ├── .prettierrc ├── .vscode └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── DockerfileDev ├── LICENCE ├── README.md ├── changelog.config.json ├── configs └── xray │ └── ssl │ └── .gitkeep ├── docker-compose-db-local.yml ├── docker-compose-db.yml ├── docker-compose-local.yml ├── docker-compose-prod-full-with-cf.yml ├── docker-compose-prod-with-cf.yml ├── docker-compose-prod.yml ├── docker-entrypoint.sh ├── ecosystem.config.js ├── eslint.config.mjs ├── libs └── contract │ ├── api │ ├── controllers │ │ ├── api-tokens.ts │ │ ├── auth.ts │ │ ├── hosts.ts │ │ ├── hwid.ts │ │ ├── inbounds.ts │ │ ├── index.ts │ │ ├── keygen.ts │ │ ├── nodes.ts │ │ ├── subscription-settings.ts │ │ ├── subscription-template.ts │ │ ├── subscription.ts │ │ ├── subscriptions.ts │ │ ├── system.ts │ │ ├── users.ts │ │ └── xray.ts │ ├── index.ts │ └── routes.ts │ ├── commands │ ├── api-tokens │ │ ├── create.command.ts │ │ ├── delete.command.ts │ │ ├── find.command.ts │ │ └── index.ts │ ├── auth │ │ ├── get-status.command.ts │ │ ├── index.ts │ │ ├── login.command.ts │ │ ├── oauth2 │ │ │ ├── index.ts │ │ │ └── telegram-callback.command.ts │ │ └── register.command.ts │ ├── hosts │ │ ├── bulk │ │ │ ├── delete-many-hosts.command.ts │ │ │ ├── disable-many-hosts.command.ts │ │ │ ├── enable-many-hosts.command.ts │ │ │ ├── index.ts │ │ │ ├── set-inbound-to-many-hosts.command.ts │ │ │ └── set-port-to-many-hosts.command.ts │ │ ├── create.command.ts │ │ ├── delete.command.ts │ │ ├── get-all.command.ts │ │ ├── get-one.command.ts │ │ ├── index.ts │ │ ├── reorder.command.ts │ │ └── update.command.ts │ ├── hwid │ │ ├── create-user-hwid-device.command.ts │ │ ├── delete-user-hwid-device.command.ts │ │ ├── get-user-hwid-devices.command.ts │ │ └── index.ts │ ├── inbounds │ │ ├── bulk │ │ │ ├── add-inbound-to-nodes.command.ts │ │ │ ├── add-inbound-to-users.command.ts │ │ │ ├── index.ts │ │ │ ├── remove-inbound-from-nodes.command.ts │ │ │ └── remove-inbound-from-users.command.ts │ │ ├── get-full-inbounds.command.ts │ │ ├── get-inbounds.command.ts │ │ └── index.ts │ ├── index.ts │ ├── keygen │ │ ├── get-pubkey.command.ts │ │ └── index.ts │ ├── nodes │ │ ├── actions │ │ │ ├── disable.command.ts │ │ │ ├── enable.command.ts │ │ │ ├── index.ts │ │ │ ├── reorder.command.ts │ │ │ ├── restart-all.command.ts │ │ │ └── restart.command.ts │ │ ├── create.command.ts │ │ ├── delete.command.ts │ │ ├── get-all.command.ts │ │ ├── get-one.command.ts │ │ ├── index.ts │ │ ├── stats │ │ │ ├── get-node-user-usage-by-range.command.ts │ │ │ ├── get-nodes-usage-by-range.command.ts │ │ │ ├── get-realtime-usage.command.ts │ │ │ └── index.ts │ │ └── update.command.ts │ ├── subscription-settings │ │ ├── get-subscription-settings.command.ts │ │ ├── index.ts │ │ └── update-subscription-settings.command.ts │ ├── subscription-template │ │ ├── get-template.command.ts │ │ ├── index.ts │ │ └── update-template.command.ts │ ├── subscription │ │ ├── get-outline-subscription-by-short-uuid.command.ts │ │ ├── get-subscription-by-short-uuid-by-client-type.command.ts │ │ ├── get-subscription-by-short-uuid.command.ts │ │ ├── get-subscription-info-by-short-uuid.command.ts │ │ └── index.ts │ ├── subscriptions │ │ ├── get-all-subscriptions.command.ts │ │ ├── get-by │ │ │ ├── get-subscription-by-username.command.ts │ │ │ └── index.ts │ │ └── index.ts │ ├── system │ │ ├── get-bandwidth-stats.command.ts │ │ ├── get-nodes-statistics.ts │ │ ├── get-stats.command.ts │ │ └── index.ts │ ├── users │ │ ├── actions │ │ │ ├── activate-all-inbounds.command.ts │ │ │ ├── disable-user.command.ts │ │ │ ├── enable-user.command.ts │ │ │ ├── index.ts │ │ │ ├── reset-user-traffic.command.ts │ │ │ └── revoke-user-subscription.command.ts │ │ ├── bulk-all │ │ │ ├── bulk-all-reset-traffic-users.command.ts │ │ │ ├── bulk-all-update-users.command.ts │ │ │ └── index.ts │ │ ├── bulk │ │ │ ├── bulk-delete-users-by-status.command.ts │ │ │ ├── bulk-delete-users.command.ts │ │ │ ├── bulk-reset-traffic-users.command.ts │ │ │ ├── bulk-revoke-users-subscription.command.ts │ │ │ ├── bulk-update-users-inbounds.command.ts │ │ │ ├── bulk-update-users.command.ts │ │ │ └── index.ts │ │ ├── create-user.command.ts │ │ ├── delete-user.command.ts │ │ ├── get-all-users.command.ts │ │ ├── get-by │ │ │ ├── get-user-by-email.command.ts │ │ │ ├── get-user-by-short-uuid.command.ts │ │ │ ├── get-user-by-subscription-uuid.command.ts │ │ │ ├── get-user-by-tag.command.ts │ │ │ ├── get-user-by-telegram-id.command.ts │ │ │ ├── get-user-by-username.command.ts │ │ │ └── index.ts │ │ ├── get-user-by-uuid.command.ts │ │ ├── get-user-usage-by-range.command.ts │ │ ├── index.ts │ │ ├── tags │ │ │ ├── get-all-tags.command.ts │ │ │ └── index.ts │ │ └── update-user.command.ts │ └── xray │ │ ├── get-config.command.ts │ │ ├── index.ts │ │ └── update-config.command.ts │ ├── constants │ ├── endpoint-details │ │ ├── endpoint-details.ts │ │ └── index.ts │ ├── errors │ │ ├── errors.ts │ │ └── index.ts │ ├── events │ │ ├── events.ts │ │ └── index.ts │ ├── hosts │ │ ├── alpn.ts │ │ ├── fingerprints.ts │ │ ├── index.ts │ │ └── security-layers.ts │ ├── index.ts │ ├── metrics │ │ ├── index.ts │ │ └── metric-names.constant.ts │ ├── nodes │ │ ├── cycle │ │ │ ├── cycle.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ └── status │ │ │ ├── index.ts │ │ │ └── status.constant.ts │ ├── roles │ │ ├── index.ts │ │ └── role.ts │ ├── subscription-template │ │ ├── index.ts │ │ └── template-type │ │ │ ├── index.ts │ │ │ ├── request-template-type.constant.ts │ │ │ └── template-type.constant.ts │ ├── templates │ │ ├── index.ts │ │ ├── template-keys.ts │ │ └── user-statuses.ts │ └── users │ │ ├── index.ts │ │ ├── reset-periods │ │ ├── index.ts │ │ └── reset-periods.constant.ts │ │ └── status │ │ ├── index.ts │ │ └── status.constant.ts │ ├── index.ts │ ├── models │ ├── api-tokens.schema.ts │ ├── auth.schema.ts │ ├── base-stat.schema.ts │ ├── extented-users.schema.ts │ ├── full-inbounds.schema.ts │ ├── happ.schema.ts │ ├── hosts.schema.ts │ ├── hwid-user-device.schema.ts │ ├── inbounds.schema.ts │ ├── index.ts │ ├── last-connected-node.schema.ts │ ├── nodes.schema.ts │ ├── subscription-settings.schema.ts │ └── users.schema.ts │ ├── package.json │ ├── tsconfig.backend.json │ └── tsconfig.frontend.json ├── nest-cli.json ├── package-lock.json ├── package.json ├── prisma ├── migrations │ ├── 20241129132625_init │ │ └── migration.sql │ ├── 20241205203645_ │ │ └── migration.sql │ ├── 20241216003610_add_new_field │ │ └── migration.sql │ ├── 20241222053036_add_users_online_stat │ │ └── migration.sql │ ├── 20241225185207_add_node_inbound_exclusions │ │ └── migration.sql │ ├── 20250113213322_add_updated_at_to_nodes_user_usage_history │ │ └── migration.sql │ ├── 20250113231728_add_view_position_for_nodes │ │ └── migration.sql │ ├── 20250114013223_add_country_code │ │ └── migration.sql │ ├── 20250126164718_add_description_field_and_fix_default_values │ │ └── migration.sql │ ├── 20250211135916_add_consumption_multiplier │ │ └── migration.sql │ ├── 20250219012541_remove │ │ └── migration.sql │ ├── 20250219013001_remove_depreacted_limit_strategies │ │ └── migration.sql │ ├── 20250225115627_add_network_and_security_to_inbounds │ │ └── migration.sql │ ├── 20250301181855_add_telegram_id_and_email_fields │ │ └── migration.sql │ ├── 20250301203122_upgrade_to_v6 │ │ └── migration.sql │ ├── 20250302162049_new_auth_system │ │ └── migration.sql │ ├── 20250307025906_add_xray_uptime │ │ └── migration.sql │ ├── 20250308020443_add_subscription_templates │ │ └── migration.sql │ ├── 20250311232029_add_subscription_settings │ │ └── migration.sql │ ├── 20250312014652_add_boolean_value_for_webpage_url │ │ └── migration.sql │ ├── 20250314164711_add_serve_json_at_base_subscription │ │ └── migration.sql │ ├── 20250314191018_add_username_to_base_subscription │ │ └── migration.sql │ ├── 20250315164331_add_security_layer │ │ └── migration.sql │ ├── 20250321173808_add_extra_xhttp │ │ └── migration.sql │ ├── 20250326125917_add_ca_certs │ │ └── migration.sql │ ├── 20250403121347_add_is_show_custom_remarks │ │ └── migration.sql │ ├── 20250404230114_replace_uuid_with_id_in_a_few_tables_drop_uuid_for_active_user_inbounds │ │ └── migration.sql │ ├── 20250409201313_add_hwid │ │ └── migration.sql │ ├── 20250410180959_add_custom_response_headers │ │ └── migration.sql │ ├── 20250415192807_change_primary_key_on_hwid_user_devices │ │ └── migration.sql │ ├── 20250505151503_add_user_tag │ │ └── migration.sql │ ├── 20250506222812_add_index_to_nodes_user_usage_history │ │ └── migration.sql │ ├── 20250506224824_add_indexes │ │ └── migration.sql │ ├── 20250518181139_add_first_connected_at_and_notification_threshold │ │ └── migration.sql │ ├── 20250519185746_add_randomize_hosts │ │ └── migration.sql │ └── migration_lock.toml ├── schema.prisma ├── seed │ └── config.seed.ts └── tsconfig.seed.json ├── src ├── app.module.ts ├── bin │ ├── cli │ │ └── cli.ts │ ├── gen-doc │ │ └── gen-doc.ts │ ├── processors │ │ ├── processors.root.module.ts │ │ └── processors.ts │ └── scheduler │ │ ├── scheduler.root.module.ts │ │ └── scheduler.ts ├── common │ ├── axios │ │ ├── axios.module.ts │ │ ├── axios.service.ts │ │ └── index.ts │ ├── config │ │ ├── app-config │ │ │ ├── config.schema.ts │ │ │ └── index.ts │ │ └── jwt │ │ │ ├── index.ts │ │ │ └── jwt.config.ts │ ├── converter │ │ └── universalConverter.ts │ ├── database │ │ ├── index.ts │ │ ├── prisma.module.ts │ │ └── prisma.service.ts │ ├── decorators │ │ ├── base-endpoint │ │ │ ├── base-endpoint.ts │ │ │ └── index.ts │ │ ├── get-client-country-code │ │ │ ├── get-client-country-code.ts │ │ │ └── index.ts │ │ ├── get-ip │ │ │ ├── get-ip.ts │ │ │ └── index.ts │ │ ├── get-jwt-payload │ │ │ ├── get-jwt-payload.ts │ │ │ └── index.ts │ │ ├── get-useragent │ │ │ ├── get-useragent.ts │ │ │ └── index.ts │ │ └── roles │ │ │ ├── index.ts │ │ │ └── roles.ts │ ├── exception │ │ ├── http-exeception-with-error-code.type.ts │ │ ├── httpException.filter.ts │ │ └── not-found-exception.filter.ts │ ├── guards │ │ ├── jwt-guards │ │ │ ├── def-jwt-guard.ts │ │ │ └── index.ts │ │ ├── proxy-check │ │ │ ├── index.ts │ │ │ └── proxy-check.guard.ts │ │ ├── roles │ │ │ ├── index.ts │ │ │ └── roles.guard.ts │ │ └── worker-routes │ │ │ ├── index.ts │ │ │ └── worker-routes.guard.ts │ ├── helpers │ │ ├── can-parse-json.ts │ │ ├── convert-bytes.ts │ │ ├── error-handler-with-null.helper.ts │ │ ├── error-handler.helper.ts │ │ └── xray-config │ │ │ ├── index.ts │ │ │ ├── interfaces │ │ │ ├── core.config.ts │ │ │ ├── ctr.type.ts │ │ │ ├── index.ts │ │ │ ├── protocol-settings.config.ts │ │ │ ├── protocols.config.ts │ │ │ ├── routing.config.ts │ │ │ └── transport.config.ts │ │ │ └── xray-config.validator.ts │ ├── middlewares │ │ ├── basic-auth.middleware.ts │ │ ├── check-auth-cookie.middleware.ts │ │ ├── get-real-ip.ts │ │ ├── index.ts │ │ └── proxy-check.middleware.ts │ ├── types │ │ ├── command-response.type.ts │ │ ├── converter.interface.ts │ │ └── crud-port.ts │ └── utils │ │ ├── bytes │ │ ├── index.ts │ │ └── pretty-bytes.util.ts │ │ ├── calc-percent-diff.util.ts │ │ ├── certs │ │ ├── encode-node-payload.ts │ │ ├── generate-certs.util.ts │ │ └── index.ts │ │ ├── extract-hwid-headers │ │ ├── extract-hwid-headers.util.ts │ │ └── index.ts │ │ ├── filter-logs │ │ ├── filter-logs.ts │ │ └── index.ts │ │ ├── flow │ │ ├── get-vless-flow.ts │ │ └── index.ts │ │ ├── get-date-ranges.uti.ts │ │ ├── get-elapsed-time.ts │ │ ├── get-short-number-from-number.ts │ │ ├── get-utc-date.util.ts │ │ ├── happ-crypto-link │ │ ├── create-happ-crypto-link.util.ts │ │ └── index.ts │ │ ├── index.ts │ │ ├── nano │ │ ├── index.ts │ │ └── nano.util.ts │ │ ├── resolve-country-emoji.ts │ │ ├── sleep.ts │ │ ├── startup-app │ │ ├── docs.ts │ │ ├── get-start-message.ts │ │ ├── gh-actions-docs.ts │ │ ├── index.ts │ │ ├── init-log.util.ts │ │ └── is-development.ts │ │ ├── superjson │ │ ├── index.ts │ │ └── superjson.util.ts │ │ ├── templates │ │ ├── index.ts │ │ └── replace-templates-values.ts │ │ └── validate-env-config.ts ├── integration-modules │ ├── integration-modules.ts │ ├── notifications │ │ ├── interfaces │ │ │ ├── error.event.interface.ts │ │ │ ├── index.ts │ │ │ ├── node.event.interface.ts │ │ │ ├── service.event.interface.ts │ │ │ └── user.event.interface.ts │ │ ├── telegram-bot │ │ │ ├── bot.update.service.ts │ │ │ ├── constants │ │ │ │ ├── bot-name.constant.ts │ │ │ │ └── index.ts │ │ │ ├── decorators │ │ │ │ ├── index.ts │ │ │ │ └── require-admin-id.decorator.ts │ │ │ ├── events │ │ │ │ ├── index.ts │ │ │ │ ├── nodes │ │ │ │ │ ├── index.ts │ │ │ │ │ └── nodes.events.ts │ │ │ │ ├── service │ │ │ │ │ ├── index.ts │ │ │ │ │ └── service.events.ts │ │ │ │ └── users │ │ │ │ │ ├── index.ts │ │ │ │ │ └── users.events.ts │ │ │ └── telegram-bot.module.ts │ │ └── webhook-module │ │ │ ├── events │ │ │ ├── index.ts │ │ │ └── webhook.events.ts │ │ │ └── webhook.module.ts │ └── prometheus-reporter │ │ ├── guards │ │ ├── basic-auth.guard.ts │ │ └── index.ts │ │ ├── prometheus-reporter.controller.ts │ │ ├── prometheus-reporter.module.ts │ │ └── strategies │ │ ├── basic.strategy.ts │ │ └── index.ts ├── main.ts ├── modules │ ├── admin │ │ ├── admin.converter.ts │ │ ├── admin.module.ts │ │ ├── commands │ │ │ ├── create-admin │ │ │ │ ├── create-admin.command.ts │ │ │ │ ├── create-admin.handler.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── entities │ │ │ └── admin.entity.ts │ │ ├── queries │ │ │ ├── count-admins-by-role │ │ │ │ ├── count-admins-by-role.handler.ts │ │ │ │ ├── count-admins-by-role.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-admin-by-username │ │ │ │ ├── get-admin-by-username.handler.ts │ │ │ │ ├── get-admin-by-username.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-first-admin │ │ │ │ ├── get-first-admin.handler.ts │ │ │ │ ├── get-first-admin.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── repositories │ │ │ └── admin.repository.ts │ ├── api-tokens │ │ ├── api-tokens.controllers.ts │ │ ├── api-tokens.converter.ts │ │ ├── api-tokens.module.ts │ │ ├── api-tokens.service.ts │ │ ├── dtos │ │ │ ├── create.dto.ts │ │ │ ├── delete.dto.ts │ │ │ ├── find.dto.ts │ │ │ └── index.ts │ │ ├── entities │ │ │ └── api-token.entity.ts │ │ ├── interfaces │ │ │ ├── api-token-jwt-payload.interface.ts │ │ │ ├── create.interface.ts │ │ │ ├── delete.interface.ts │ │ │ └── index.ts │ │ ├── models │ │ │ ├── create-response.model.ts │ │ │ ├── find.model.ts │ │ │ └── index.ts │ │ ├── queries │ │ │ ├── get-token-by-uuid │ │ │ │ ├── get-token-by-uuid.handler.ts │ │ │ │ ├── get-token-by-uuid.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── repositories │ │ │ └── api-tokens.repository.ts │ ├── auth │ │ ├── auth.controller.ts │ │ ├── auth.module.ts │ │ ├── auth.service.ts │ │ ├── commands │ │ │ ├── index.ts │ │ │ └── sign-api-token │ │ │ │ ├── index.ts │ │ │ │ ├── sign-api-token.command.ts │ │ │ │ └── sign-api-token.handler.ts │ │ ├── dtos │ │ │ ├── get-status.dto.ts │ │ │ ├── index.ts │ │ │ ├── login.dto.ts │ │ │ ├── oauth2 │ │ │ │ ├── index.ts │ │ │ │ └── telegram-callback.dto.ts │ │ │ └── register.dto.ts │ │ ├── interfaces │ │ │ ├── auth.interfaces.ts │ │ │ ├── index.ts │ │ │ ├── login.interface.ts │ │ │ └── register.interface.ts │ │ ├── model │ │ │ ├── auth-response.model.ts │ │ │ ├── get-status.response.model.ts │ │ │ ├── index.ts │ │ │ └── register.response.model.ts │ │ └── strategies │ │ │ ├── index.ts │ │ │ └── jwt.strategy.ts │ ├── hosts │ │ ├── controllers │ │ │ ├── hosts-bulk-actions.controller.ts │ │ │ ├── hosts.controller.ts │ │ │ └── index.ts │ │ ├── dtos │ │ │ ├── bulk-operations.dto.ts │ │ │ ├── create-host.dto.ts │ │ │ ├── delete-host.dto.ts │ │ │ ├── get-all-hosts.dto.ts │ │ │ ├── get-one.dto.ts │ │ │ ├── index.ts │ │ │ ├── reorder-hosts.dto.ts │ │ │ └── update-host.dto.ts │ │ ├── entities │ │ │ ├── host-with-inbound-tag.entity.ts │ │ │ └── hosts.entity.ts │ │ ├── hosts.converter.ts │ │ ├── hosts.module.ts │ │ ├── hosts.service.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ └── reorder-host.interface.ts │ │ ├── models │ │ │ ├── create-host.response.model.ts │ │ │ ├── delete-host.response.model.ts │ │ │ ├── get-all-hosts.response.model.ts │ │ │ ├── get-one-host.response.model.ts │ │ │ ├── index.ts │ │ │ └── update-host.response.model.ts │ │ ├── queries │ │ │ ├── get-hosts-for-user │ │ │ │ ├── get-hosts-for-user.handler.ts │ │ │ │ ├── get-hosts-for-user.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── repositories │ │ │ └── hosts.repository.ts │ ├── hwid-user-devices │ │ ├── commands │ │ │ ├── create-hwid-user-device │ │ │ │ ├── create-hwid-user-device.command.ts │ │ │ │ ├── create-hwid-user-device.handler.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── upsert-hwid-user-device │ │ │ │ ├── index.ts │ │ │ │ ├── upsert-hwid-user-device.command.ts │ │ │ │ └── upsert-hwid-user-device.handler.ts │ │ ├── dtos │ │ │ ├── create-user-hwid-device.dto.ts │ │ │ ├── delete-user-hwid-device.dto.ts │ │ │ ├── get-user-hwid-devices.dto.ts │ │ │ └── index.ts │ │ ├── entities │ │ │ └── hwid-user-device.entity.ts │ │ ├── hwid-user-devices.controller.ts │ │ ├── hwid-user-devices.converter.ts │ │ ├── hwid-user-devices.module.ts │ │ ├── hwid-user-devices.service.ts │ │ ├── index.ts │ │ ├── models │ │ │ ├── base-user-hwid-devices.response.model.ts │ │ │ └── index.ts │ │ ├── queries │ │ │ ├── check-hwid-exists │ │ │ │ ├── check-hwid-exists.handler.ts │ │ │ │ ├── check-hwid-exists.query.ts │ │ │ │ └── index.ts │ │ │ ├── count-users-devices │ │ │ │ ├── count-users-devices.handler.ts │ │ │ │ ├── count-users-devices.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── repositories │ │ │ └── hwid-user-devices.repository.ts │ ├── inbounds │ │ ├── builders │ │ │ ├── add-inbound-to-nodes │ │ │ │ ├── add-inbound-to-nodes.builder.ts │ │ │ │ └── index.ts │ │ │ ├── add-inbound-to-users │ │ │ │ ├── add-inbound-to-users.builder.ts │ │ │ │ └── index.ts │ │ │ ├── add-inbounds-to-users-by-uuids │ │ │ │ ├── add-inbounds-to-users-by-uuids.builder.ts │ │ │ │ └── index.ts │ │ │ ├── get-inbound-stats-by-uuid │ │ │ │ ├── get-inbound-stats-by-uuid.builder.ts │ │ │ │ └── index.ts │ │ │ ├── remove-inbound-from-nodes │ │ │ │ ├── index.ts │ │ │ │ └── remove-inbound-from-nodes.builder.ts │ │ │ ├── remove-inbound-from-users │ │ │ │ ├── index.ts │ │ │ │ └── remove-inbound-from-users.builder.ts │ │ │ └── remove-inbounds-from-users-by-uuids │ │ │ │ ├── index.ts │ │ │ │ └── remove-inbounds-from-users-by-uuids.builder.ts │ │ ├── commands │ │ │ ├── add-inbounds-to-users-by-uuids │ │ │ │ ├── add-inbounds-to-users-by-uuids.command.ts │ │ │ │ ├── add-inbounds-to-users-by-uuids.handler.ts │ │ │ │ └── index.ts │ │ │ ├── create-many-inbounds │ │ │ │ ├── create-many-inbounds.command.ts │ │ │ │ ├── create-many-inbounds.handler.ts │ │ │ │ └── index.ts │ │ │ ├── create-many-user-active-inbounds │ │ │ │ ├── create-many-user-active-inbounds.command.ts │ │ │ │ ├── create-many-user-active-inbounds.handler.ts │ │ │ │ └── index.ts │ │ │ ├── delete-many-active-inbounds-by-user-uuid │ │ │ │ ├── delete-many-active-inbounds-by-user-uuid.command.ts │ │ │ │ ├── delete-many-active-inbounds-by-user-uuid.handler.ts │ │ │ │ └── index.ts │ │ │ ├── delete-many-inbounds │ │ │ │ ├── delete-many-inbounds.command.ts │ │ │ │ ├── delete-many-inbounds.handler.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── remove-inbounds-from-users-by-uuids │ │ │ │ ├── index.ts │ │ │ │ ├── remove-inbounds-from-users-by-uuids.command.ts │ │ │ │ └── remove-inbounds-from-users-by-uuids.handler.ts │ │ │ ├── reset-node-inbound-exclusions-by-node-uuid │ │ │ │ ├── index.ts │ │ │ │ ├── reset-node-inbound-exclusions-by-node-uuid.command.ts │ │ │ │ └── reset-node-inbound-exclusions-by-node-uuid.handler.ts │ │ │ └── update-inbound │ │ │ │ ├── index.ts │ │ │ │ ├── update-inbound.command.ts │ │ │ │ └── update-inbound.handler.ts │ │ ├── controllers │ │ │ ├── inbounds-bulk-actions.controller.ts │ │ │ ├── inbounds.controller.ts │ │ │ └── index.ts │ │ ├── converters │ │ │ ├── active-user-inbounds.converter.ts │ │ │ ├── inbounds.converter.ts │ │ │ ├── index.ts │ │ │ └── node-inbound-exclusions.converter.ts │ │ ├── dtos │ │ │ ├── bulk-operations.dto.ts │ │ │ ├── get-full-inbounds.dto.ts │ │ │ ├── get-inbounds.dto.ts │ │ │ └── index.ts │ │ ├── entities │ │ │ ├── active-user-inbound.entity.ts │ │ │ ├── base-inbound.entity.ts │ │ │ ├── inbound-with-stats.entity.ts │ │ │ ├── inbounds.entity.ts │ │ │ ├── index.ts │ │ │ └── node-inbound-exclusion.entity.ts │ │ ├── inbounds.module.ts │ │ ├── inbounds.service.ts │ │ ├── interfaces │ │ │ ├── inbounds-with-tags-and-type.interface.ts │ │ │ └── index.ts │ │ ├── models │ │ │ ├── bulk-operation.response.model.ts │ │ │ ├── get-base-inbounds.response.model.ts │ │ │ ├── get-full-inbounds.response.model.ts │ │ │ ├── get-inbounds.response.model.ts │ │ │ └── index.ts │ │ ├── queries │ │ │ ├── get-all-inbounds │ │ │ │ ├── get-all-inbounds.handler.ts │ │ │ │ ├── get-all-inbounds.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── repositories │ │ │ ├── active-user-inbounds.repository.ts │ │ │ ├── inbounds.repository.ts │ │ │ └── node-inbound-exclusions.repository.ts │ ├── keygen │ │ ├── commands │ │ │ ├── get-node-jwt │ │ │ │ ├── get-node-jwt.command.ts │ │ │ │ ├── get-node-jwt.handler.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── dtos │ │ │ ├── get-pubkey-dto.ts │ │ │ └── index.ts │ │ ├── entities │ │ │ └── keygen.entity.ts │ │ ├── keygen.controller.ts │ │ ├── keygen.converter.ts │ │ ├── keygen.module.ts │ │ ├── keygen.service.ts │ │ ├── model │ │ │ ├── index.ts │ │ │ └── keygen-response.model.ts │ │ └── repositories │ │ │ └── keygen.repository.ts │ ├── nodes-traffic-usage-history │ │ ├── commands │ │ │ ├── create-node-traffic-usage-history │ │ │ │ ├── create-node-traffic-usage-history.command.ts │ │ │ │ ├── create-node-traffic-usage-history.handler.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── entities │ │ │ └── nodes-traffic-usage-history.entity.ts │ │ ├── index.ts │ │ ├── nodes-traffic-usage-history.converter.ts │ │ ├── nodes-traffic-usage-history.module.ts │ │ └── repositories │ │ │ └── nodes-traffic-usage-history.repository.ts │ ├── nodes-usage-history │ │ ├── builders │ │ │ ├── get-7days-stats │ │ │ │ ├── get-7days-stats.builder.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── commands │ │ │ ├── index.ts │ │ │ └── upsert-history-entry │ │ │ │ ├── index.ts │ │ │ │ ├── upsert-history-entry.command.ts │ │ │ │ └── upsert-history-entry.handler.ts │ │ ├── dtos │ │ │ ├── index.ts │ │ │ └── nodes-usage-by-range.dto.ts │ │ ├── entities │ │ │ ├── index.ts │ │ │ └── nodes-usage-history.entity.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── get-7days-stats.interface.ts │ │ │ ├── get-nodes-usage-by-range.interface.ts │ │ │ └── index.ts │ │ ├── models │ │ │ ├── get-nodes-usage-by-range.response.model.ts │ │ │ └── index.ts │ │ ├── nodes-usage-history.controller.ts │ │ ├── nodes-usage-history.converter.ts │ │ ├── nodes-usage-history.module.ts │ │ ├── nodes-usage-history.service.ts │ │ ├── queries │ │ │ ├── get-7days-stats │ │ │ │ ├── get-7days-stats.handler.ts │ │ │ │ ├── get-7days-stats.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-sum-by-dt-range │ │ │ │ ├── get-sum-by-dt-range.handler.ts │ │ │ │ ├── get-sum-by-dt-range.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── repositories │ │ │ └── nodes-usage-history.repository.ts │ ├── nodes-user-usage-history │ │ ├── builders │ │ │ ├── bulk-upsert-history-entry │ │ │ │ ├── bulk-upsert-history-entry.builder.ts │ │ │ │ └── index.ts │ │ │ ├── get-node-users-usage-by-range │ │ │ │ ├── get-node-users-usage-by-range.builder.ts │ │ │ │ └── index.ts │ │ │ ├── get-nodes-realtime-usage │ │ │ │ ├── get-nodes-realtime-usage.builder.ts │ │ │ │ └── index.ts │ │ │ └── get-user-usage-by-range │ │ │ │ ├── get-user-usage-by-range.builder.ts │ │ │ │ └── index.ts │ │ ├── commands │ │ │ ├── bulk-upsert-user-history-entry │ │ │ │ ├── bulk-upsert-user-history-entry.command.ts │ │ │ │ ├── bulk-upsert-user-history-entry.handler.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── upsert-user-history-entry │ │ │ │ ├── index.ts │ │ │ │ ├── upsert-user-history-entry.command.ts │ │ │ │ └── upsert-user-history-entry.handler.ts │ │ ├── dtos │ │ │ ├── index.ts │ │ │ ├── node-user-usage-by-range.dto.ts │ │ │ └── nodes-realtime-usage.dto.ts │ │ ├── entities │ │ │ ├── index.ts │ │ │ └── nodes-user-usage-history.entity.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── get-node-users-usage-by-range.ts │ │ │ ├── get-nodes-realtime-usage.ts │ │ │ ├── index.ts │ │ │ └── last-connected-node.ts │ │ ├── models │ │ │ ├── get-node-user-usage-by-range.response.model.ts │ │ │ ├── get-nodes-realtime-usage.response.model.ts │ │ │ └── index.ts │ │ ├── nodes-user-usage-history.controller.ts │ │ ├── nodes-user-usage-history.converter.ts │ │ ├── nodes-user-usage-history.module.ts │ │ ├── nodes-user-usage-history.service.ts │ │ ├── queries │ │ │ ├── get-user-last-connected-node │ │ │ │ ├── get-user-last-connected-node.handler.ts │ │ │ │ ├── get-user-last-connected-node.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-user-usage-by-range │ │ │ │ ├── get-user-usage-by-range.handler.ts │ │ │ │ ├── get-user-usage-by-range.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── repositories │ │ │ └── nodes-user-usage-history.repository.ts │ ├── nodes │ │ ├── commands │ │ │ ├── increment-used-traffic │ │ │ │ ├── increment-used-traffic.command.ts │ │ │ │ ├── increment-used-traffic.handler.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── update-node │ │ │ │ ├── index.ts │ │ │ │ ├── update-node.command.ts │ │ │ │ └── update-node.handler.ts │ │ ├── dtos │ │ │ ├── create-node.request.dto.ts │ │ │ ├── delete-node.dto.ts │ │ │ ├── disable-node.request.dto.ts │ │ │ ├── enable-node.request.dto.ts │ │ │ ├── get-all-nodes.dto.ts │ │ │ ├── get-one-node.dto.ts │ │ │ ├── index.ts │ │ │ ├── reorder.dto.ts │ │ │ ├── restart-all.dto.ts │ │ │ ├── restart-node.request.dto.ts │ │ │ └── update-node.dto.ts │ │ ├── entities │ │ │ ├── index.ts │ │ │ └── nodes.entity.ts │ │ ├── events │ │ │ ├── add-user-to-node │ │ │ │ ├── add-user-to-node.event.ts │ │ │ │ ├── add-user-to-node.handler.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── remove-user-from-node │ │ │ │ ├── index.ts │ │ │ │ ├── remove-user-from-node.event.ts │ │ │ │ └── remove-user-from-node.handler.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ ├── node-with-excluded-inbounds.interface.ts │ │ │ └── reorder-node.interface.ts │ │ ├── models │ │ │ ├── create-node.response.model.ts │ │ │ ├── delete-node.response.model.ts │ │ │ ├── get-all-nodes.response.model.ts │ │ │ ├── get-one-node.response.model.ts │ │ │ ├── index.ts │ │ │ └── restart-node.response.model.ts │ │ ├── nodes.controller.ts │ │ ├── nodes.converter.ts │ │ ├── nodes.module.ts │ │ ├── nodes.service.ts │ │ ├── queries │ │ │ ├── get-all-nodes │ │ │ │ ├── get-all-nodes.handler.ts │ │ │ │ ├── get-all-nodes.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-enabled-nodes │ │ │ │ ├── get-enabled-nodes.handler.ts │ │ │ │ ├── get-enabled-nodes.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-nodes-by-criteria │ │ │ │ ├── get-nodes-by-criteria.handler.ts │ │ │ │ ├── get-nodes-by-criteria.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-online-nodes │ │ │ │ ├── get-online-nodes.handler.ts │ │ │ │ ├── get-online-nodes.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ └── repositories │ │ │ └── nodes.repository.ts │ ├── remnawave-backend.modules.ts │ ├── remnawave-service │ │ ├── remnawave-service.module.ts │ │ └── remnawave-service.service.ts │ ├── subscription-settings │ │ ├── dtos │ │ │ ├── get-subscription-settings.dto.ts │ │ │ ├── index.ts │ │ │ └── update-subscription-settings.dto.ts │ │ ├── entities │ │ │ └── subscription-settings.entity.ts │ │ ├── index.ts │ │ ├── models │ │ │ ├── get-subscription-settings.response.model.ts │ │ │ └── index.ts │ │ ├── queries │ │ │ ├── get-subscription-settings │ │ │ │ ├── get-subscription-settings.handler.ts │ │ │ │ ├── get-subscription-settings.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── repositories │ │ │ └── subscription-settings.repository.ts │ │ ├── subscription-settings.controller.ts │ │ ├── subscription-settings.converter.ts │ │ ├── subscription-settings.module.ts │ │ └── subscription-settings.service.ts │ ├── subscription-template │ │ ├── constants │ │ │ ├── config-types.ts │ │ │ └── index.ts │ │ ├── dtos │ │ │ ├── get-template.dto.ts │ │ │ ├── index.ts │ │ │ └── update-template.dto.ts │ │ ├── entities │ │ │ └── subscription-template.entity.ts │ │ ├── generators │ │ │ ├── clash.generator.service.ts │ │ │ ├── format-hosts.service.ts │ │ │ ├── index.ts │ │ │ ├── interfaces │ │ │ │ ├── formatted-hosts.interface.ts │ │ │ │ └── index.ts │ │ │ ├── mihomo.generator.service.ts │ │ │ ├── outline.generator.service.ts │ │ │ ├── singbox.generator.service.ts │ │ │ ├── xray-json.generator.service.ts │ │ │ └── xray.generator.service.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── generate-subscription-by-client-type.interface.ts │ │ │ ├── generate-subscription.interface.ts │ │ │ └── index.ts │ │ ├── models │ │ │ ├── get-template.response.model.ts │ │ │ ├── index.ts │ │ │ └── update-subscription.response.model.ts │ │ ├── render-templates.service.ts │ │ ├── repositories │ │ │ └── subscription-template.repository.ts │ │ ├── subscription-template.controller.ts │ │ ├── subscription-template.converter.ts │ │ ├── subscription-template.module.ts │ │ └── subscription-template.service.ts │ ├── subscription │ │ ├── controllers │ │ │ ├── index.ts │ │ │ ├── subscription.controller.ts │ │ │ └── subscriptions.controller.ts │ │ ├── dto │ │ │ ├── get-all-subscriptions.dto.ts │ │ │ ├── get-outline-subscription.dto.ts │ │ │ ├── get-subscription-by-client-type.dto.ts │ │ │ ├── get-subscription-by-username.dto.ts │ │ │ ├── get-subscription-info.dto.ts │ │ │ ├── get-subscription.dto.ts │ │ │ └── index.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ └── subscription-headers.interface.ts │ │ ├── models │ │ │ ├── all-subscription.response.model.ts │ │ │ ├── index.ts │ │ │ ├── subscription-not-found.response.model.ts │ │ │ ├── subscription-raw.response.model.ts │ │ │ └── subscription-with-config.response.model.ts │ │ ├── subscription.module.ts │ │ ├── subscription.service.ts │ │ └── utils │ │ │ ├── get-user-info.headers.ts │ │ │ └── parse-sing-box-version.ts │ ├── system │ │ ├── dtos │ │ │ ├── get-bandwidth-stats.dto.ts │ │ │ ├── get-nodes-statistics.dto.ts │ │ │ ├── get-stats.dto.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── models │ │ │ ├── get-bandwidth-stats.response.model.ts │ │ │ ├── get-nodes-statistics.response.model.ts │ │ │ ├── get-stats.response.model.ts │ │ │ └── index.ts │ │ ├── system.controller.ts │ │ ├── system.module.ts │ │ └── system.service.ts │ ├── user-traffic-history │ │ ├── commands │ │ │ ├── create-user-traffic-history │ │ │ │ ├── create-user-traffic-history.command.ts │ │ │ │ ├── create-user-traffic-history.handler.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── entities │ │ │ └── user-traffic-history.entity.ts │ │ ├── index.ts │ │ ├── repositories │ │ │ └── user-traffic-history.repository.ts │ │ ├── user-traffic-history.converter.ts │ │ └── user-traffic-history.module.ts │ ├── users │ │ ├── builders │ │ │ ├── batch-reset-limited-users-usage │ │ │ │ ├── batch-reset-limited-users-usage.builder.ts │ │ │ │ └── index.ts │ │ │ ├── batch-reset-users-usage │ │ │ │ ├── batch-reset-users-usage.builder.ts │ │ │ │ └── index.ts │ │ │ ├── bulk-delete-by-status │ │ │ │ ├── bulk-delete-by-status.builder.ts │ │ │ │ └── index.ts │ │ │ ├── bulk-update-user-used-traffic │ │ │ │ ├── bulk-update-user-used-traffic.builder.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── last-connected-node │ │ │ │ ├── index.ts │ │ │ │ ├── last-connected-node.builder.ts │ │ │ │ └── last-connected-node.interface.ts │ │ │ ├── sum-lifetime-usage │ │ │ │ ├── index.ts │ │ │ │ └── sum-lifetime-usage.builder.ts │ │ │ ├── trigger-threshold-notifications-builder │ │ │ │ ├── index.ts │ │ │ │ └── trigger-threshold-notifications-builder.builder.ts │ │ │ └── users-with-inbound-tag │ │ │ │ ├── index.ts │ │ │ │ └── users-with-inbound-tag.builder.ts │ │ ├── commands │ │ │ ├── batch-reset-limited-users-traffic │ │ │ │ ├── batch-reset-limited-users-traffic.command.ts │ │ │ │ ├── batch-reset-limited-users-traffic.handler.ts │ │ │ │ └── index.ts │ │ │ ├── batch-reset-user-traffic │ │ │ │ ├── batch-reset-user-traffic.command.ts │ │ │ │ ├── batch-reset-user-traffic.handler.ts │ │ │ │ └── index.ts │ │ │ ├── bulk-delete-by-status │ │ │ │ ├── bulk-delete-by-status.command.ts │ │ │ │ ├── bulk-delete-by-status.handler.ts │ │ │ │ └── index.ts │ │ │ ├── bulk-increment-used-traffic │ │ │ │ ├── bulk-increment-used-traffic.command.ts │ │ │ │ ├── bulk-increment-used-traffic.handler.ts │ │ │ │ └── index.ts │ │ │ ├── change-user-status │ │ │ │ ├── change-user-status.command.ts │ │ │ │ ├── change-user-status.handler.ts │ │ │ │ └── index.ts │ │ │ ├── increment-used-traffic │ │ │ │ ├── increment-used-traffic.command.ts │ │ │ │ ├── increment-used-traffic.handler.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── reset-user-traffic │ │ │ │ ├── index.ts │ │ │ │ ├── reset-user-traffic.command.ts │ │ │ │ └── reset-user-traffic.handler.ts │ │ │ ├── revoke-user-subscription │ │ │ │ ├── index.ts │ │ │ │ ├── revoke-user-subscription.command.ts │ │ │ │ └── revoke-user-subscription.handler.ts │ │ │ ├── trigger-threshold-notification │ │ │ │ ├── index.ts │ │ │ │ ├── trigger-threshold-notification.command.ts │ │ │ │ └── trigger-threshold-notification.handler.ts │ │ │ ├── update-exceeded-users │ │ │ │ ├── index.ts │ │ │ │ ├── update-exceeded-users.command.ts │ │ │ │ └── update-exceeded-users.handler.ts │ │ │ ├── update-expired-users │ │ │ │ ├── index.ts │ │ │ │ ├── update-expired-users.command.ts │ │ │ │ └── update-expired-users.handler.ts │ │ │ ├── update-status-and-traffic-and-reset-at │ │ │ │ ├── index.ts │ │ │ │ ├── update-status-and-traffic-and-reset-at.command.ts │ │ │ │ └── update-status-and-traffic-and-reset-at.handler.ts │ │ │ ├── update-sub-last-opened-and-user-agent │ │ │ │ ├── index.ts │ │ │ │ ├── update-sub-last-opened-and-user-agent.command.ts │ │ │ │ └── update-sub-last-opened-and-user-agent.handler.ts │ │ │ └── update-user-with-service │ │ │ │ ├── index.ts │ │ │ │ ├── update-user-with-service.command.ts │ │ │ │ └── update-user-with-service.handler.ts │ │ ├── controllers │ │ │ ├── index.ts │ │ │ ├── users-bulk-actions.controller.ts │ │ │ ├── users-stats.controller.ts │ │ │ └── users.controller.ts │ │ ├── dtos │ │ │ ├── activate-all-inbounds.dto.ts │ │ │ ├── bulk │ │ │ │ ├── bulk-delete-users-by-status.dto.ts │ │ │ │ ├── bulk-operations.dto.ts │ │ │ │ └── index.ts │ │ │ ├── create-user.dto.ts │ │ │ ├── delete-user.dto.ts │ │ │ ├── disable-user.dto.ts │ │ │ ├── enable-user.dto.ts │ │ │ ├── get-all-users-v2.dto.ts │ │ │ ├── get-user-by-email.dto.ts │ │ │ ├── get-user-by-short-uuid.dto.ts │ │ │ ├── get-user-by-subscription-uuid.dto.ts │ │ │ ├── get-user-by-telegram-id.dto.ts │ │ │ ├── get-user-by-username.dto.ts │ │ │ ├── get-user-by-uuid.dto.ts │ │ │ ├── get-user-usage-by-range.dto.ts │ │ │ ├── get-users-by-tag.dto.ts │ │ │ ├── index.ts │ │ │ ├── reset-user-traffic.dto.ts │ │ │ ├── revoke-user-subscription.dto.ts │ │ │ ├── tags │ │ │ │ ├── get-all-tags.dto.ts │ │ │ │ └── index.ts │ │ │ └── update-user.dto.ts │ │ ├── entities │ │ │ ├── index.ts │ │ │ ├── user-with-active-inbounds-and-last-connected-node.entity.ts │ │ │ ├── user-with-active-inbounds.entity.ts │ │ │ ├── user-with-ai-and-lcn-raw.entity.ts │ │ │ ├── users-for-config.ts │ │ │ └── users.entity.ts │ │ ├── events │ │ │ └── index.ts │ │ ├── interfaces │ │ │ ├── get-user-by-unique.interface.ts │ │ │ ├── get-user-usage-by-range.interface.ts │ │ │ ├── get-user-with-last-connected-node.interface.ts │ │ │ ├── get-users-by-telegram-id-or-email.interface.ts │ │ │ ├── index.ts │ │ │ ├── user-stats.interface.ts │ │ │ ├── user-status-count.interface.ts │ │ │ ├── user-with-active-inbounds-and-last-connected-node.interface.ts │ │ │ ├── user-with-active-inbounds.interface.ts │ │ │ └── user-with-lifetime-traffic.interface.ts │ │ ├── models │ │ │ ├── bulk │ │ │ │ ├── bulk-all.response.model.ts │ │ │ │ ├── bulk-delete-by-status.response.model.ts │ │ │ │ ├── bulk-operation.response.model.ts │ │ │ │ └── index.ts │ │ │ ├── create-user.response.model.ts │ │ │ ├── delete-user.response.model.ts │ │ │ ├── get-all-tags.response.model.ts │ │ │ ├── get-all-users.response.model.ts │ │ │ ├── get-full-user.response.model.ts │ │ │ ├── get-user-usage-by-range.response.model.ts │ │ │ ├── get-user.response.model.ts │ │ │ └── index.ts │ │ ├── queries │ │ │ ├── get-active-users │ │ │ │ ├── get-active-users.handler.ts │ │ │ │ ├── get-active-users.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-all-users │ │ │ │ ├── get-all-users.handler.ts │ │ │ │ ├── get-all-users.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-exceeded-traffic-usage-users │ │ │ │ ├── get-exceeded-traffic-usage-users.handler.ts │ │ │ │ ├── get-exceeded-traffic-usage-users.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-expired-users │ │ │ │ ├── get-expired-users.handler.ts │ │ │ │ ├── get-expired-users.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-prepared-config-with-users │ │ │ │ ├── get-prepared-config-with-users.handler.ts │ │ │ │ ├── get-prepared-config-with-users.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-short-user-stats │ │ │ │ ├── get-short-user-stats.handler.ts │ │ │ │ ├── get-short-user-stats.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-user-by-short-uuid │ │ │ │ ├── get-user-by-short-uuid.handler.ts │ │ │ │ ├── get-user-by-short-uuid.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-user-by-username │ │ │ │ ├── get-user-by-username.handler.ts │ │ │ │ ├── get-user-by-username.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-user-by-uuid │ │ │ │ ├── get-user-by-uuid.handler.ts │ │ │ │ ├── get-user-by-uuid.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-users-by-expire-at │ │ │ │ ├── get-users-by-expire-at.handler.ts │ │ │ │ ├── get-users-by-expire-at.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-users-by-traffic-strategy-and-status │ │ │ │ ├── get-users-by-traffic-strategy-and-status.handler.ts │ │ │ │ ├── get-users-by-traffic-strategy-and-status.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-users-for-config-batch │ │ │ │ ├── get-users-for-config-batch.handler.ts │ │ │ │ ├── get-users-for-config-batch.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-users-for-config │ │ │ │ ├── get-users-for-config.handler.ts │ │ │ │ ├── get-users-for-config.query.ts │ │ │ │ └── index.ts │ │ │ ├── get-users-with-pagination │ │ │ │ ├── get-users-with-pagination.handler.ts │ │ │ │ ├── get-users-with-pagination.query.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── repositories │ │ │ └── users.repository.ts │ │ ├── users.converter.ts │ │ ├── users.module.ts │ │ └── users.service.ts │ └── xray-config │ │ ├── dtos │ │ ├── get-config.dto.ts │ │ ├── index.ts │ │ └── update-config.dto.ts │ │ ├── entities │ │ └── xray-config.entity.ts │ │ ├── index.ts │ │ ├── models │ │ └── get-config.response.model.ts │ │ ├── queries │ │ ├── get-validated-config │ │ │ ├── get-validated-config.handler.ts │ │ │ ├── get-validated-config.query.ts │ │ │ └── index.ts │ │ ├── get-xray-config │ │ │ ├── get-xray-config.handler.ts │ │ │ ├── get-xray-config.query.ts │ │ │ └── index.ts │ │ └── index.ts │ │ ├── repositories │ │ └── xray-config.repository.ts │ │ ├── xray-config.controller.ts │ │ ├── xray-config.converter.ts │ │ ├── xray-config.module.ts │ │ └── xray-config.service.ts ├── queue │ ├── bulk-user-operations │ │ ├── bulk-user-operations.module.ts │ │ ├── bulk-user-operations.processor.ts │ │ ├── bulk-user-operations.service.ts │ │ ├── enums │ │ │ ├── bulk-user-operations-job-names.enum.ts │ │ │ └── index.ts │ │ └── index.ts │ ├── expire-user-notifications │ │ ├── enums │ │ │ ├── expire-user-notifications-job-names.enum.ts │ │ │ └── index.ts │ │ ├── expire-user-notifications.module.ts │ │ ├── expire-user-notifications.processor.ts │ │ ├── expire-user-notifications.service.ts │ │ └── index.ts │ ├── first-connected-users │ │ ├── enums │ │ │ ├── first-connected-users-job-names.enum.ts │ │ │ └── index.ts │ │ ├── first-connected-users.module.ts │ │ ├── first-connected-users.processor.ts │ │ ├── first-connected-users.service.ts │ │ └── index.ts │ ├── index.ts │ ├── node-health-check │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── node-health-check-job-names.enum.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ └── node-health-check.interface.ts │ │ ├── node-health-check.module.ts │ │ ├── node-health-check.processor.ts │ │ └── node-health-check.service.ts │ ├── node-users │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── node-users-job-names.enum.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── add-user-to-node.payload.interface.ts │ │ │ ├── index.ts │ │ │ └── remove-user-from-node.payload.interface.ts │ │ ├── node-users.module.ts │ │ ├── node-users.processor.ts │ │ └── node-users.service.ts │ ├── notifications │ │ ├── notifications-modules.ts │ │ ├── telegram-bot-logger │ │ │ ├── enums │ │ │ │ ├── index.ts │ │ │ │ └── telegram-bot-logger-job-names.enum.ts │ │ │ ├── index.ts │ │ │ ├── telegram-bot-logger.module.ts │ │ │ ├── telegram-bot-logger.processor.ts │ │ │ └── telegram-bot-logger.service.ts │ │ └── webhook-logger │ │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── webhook-logger-job-names.enum.ts │ │ │ ├── index.ts │ │ │ ├── interfaces │ │ │ ├── base-webhook-logger.interface.ts │ │ │ └── index.ts │ │ │ ├── webhook-logger.module.ts │ │ │ ├── webhook-logger.processor.ts │ │ │ └── webhook-logger.service.ts │ ├── queue.enum.ts │ ├── queue.module.ts │ ├── queue.service.ts │ ├── record-node-usage │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── record-node-usage-job-names.enum.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ └── record-node-usage.interface.ts │ │ ├── record-node-usage.module.ts │ │ ├── record-node-usage.processor.ts │ │ └── record-node-usage.service.ts │ ├── record-user-usage │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── record-user-usage-job-names.enum.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ └── record-user-usage.interface.ts │ │ ├── record-user-usage.module.ts │ │ ├── record-user-usage.processor.ts │ │ └── record-user-usage.service.ts │ ├── reset-user-traffic │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── reset-user-traffic-job-names.enum.ts │ │ ├── index.ts │ │ ├── reset-user-traffic.module.ts │ │ ├── reset-user-traffic.processor.ts │ │ └── reset-user-traffic.service.ts │ ├── start-all-nodes │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── start-all-nodes-job-names.enum.ts │ │ ├── index.ts │ │ ├── start-all-nodes.module.ts │ │ ├── start-all-nodes.processor.ts │ │ └── start-all-nodes.service.ts │ ├── start-node │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── start-node-job-names.enum.ts │ │ ├── index.ts │ │ ├── start-node.module.ts │ │ ├── start-node.processor.ts │ │ └── start-node.service.ts │ ├── stop-node │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── stop-node-job-names.enum.ts │ │ ├── index.ts │ │ ├── stop-node.module.ts │ │ ├── stop-node.processor.ts │ │ └── stop-node.service.ts │ ├── update-users-usage │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── update-users-usage-job-names.enum.ts │ │ ├── index.ts │ │ ├── update-users-usage.module.ts │ │ ├── update-users-usage.processor.ts │ │ └── update-users-usage.service.ts │ ├── user-actions │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── user-actions-job-names.enum.ts │ │ ├── index.ts │ │ ├── user-actions.module.ts │ │ ├── user-actions.processor.ts │ │ └── user-actions.service.ts │ └── user-jobs │ │ ├── enums │ │ ├── index.ts │ │ └── user-jobs-job-names.enum.ts │ │ ├── index.ts │ │ ├── user-jobs.module.ts │ │ ├── user-jobs.processor.ts │ │ └── user-jobs.service.ts └── scheduler │ ├── enqueue │ ├── index.ts │ ├── node-health-check │ │ ├── index.ts │ │ └── node-health-check.task.ts │ ├── record-nodes-usage │ │ ├── index.ts │ │ └── record-nodes-usage.task.ts │ ├── record-user-usage │ │ ├── index.ts │ │ └── record-user-usage.task.ts │ ├── reset-user-traffic-jobs │ │ ├── index.ts │ │ ├── reset-user-traffic-day │ │ │ ├── index.ts │ │ │ └── reset-user-traffic-day.task.ts │ │ ├── reset-user-traffic-month │ │ │ ├── index.ts │ │ │ └── reset-user-traffic-month.task.ts │ │ └── reset-user-traffic-week │ │ │ ├── index.ts │ │ │ └── reset-user-traffic-week.task.ts │ └── users-jobs │ │ ├── find-exceeded-usage-users │ │ ├── find-exceeded-usage-users.task.ts │ │ └── index.ts │ │ ├── find-expired-users │ │ ├── find-expired-users.task.ts │ │ └── index.ts │ │ ├── find-users-for-expire-notifications │ │ ├── find-users-for-expire-notifications.task.ts │ │ └── index.ts │ │ ├── find-users-for-threshold-notification │ │ ├── find-users-for-threshold-notification.task.ts │ │ └── index.ts │ │ └── index.ts │ ├── intervals.ts │ ├── metrics-providers.ts │ ├── scheduler.module.ts │ └── tasks │ ├── export-metrics │ └── export-metrics.task.ts │ ├── index.ts │ ├── reset-node-traffic │ ├── index.ts │ └── reset-node-traffic.service.ts │ └── review-nodes │ ├── index.ts │ └── review-nodes.task.ts ├── tsconfig.build.json └── tsconfig.json /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: 🐞 Bug report 3 | url: https://github.com/remnawave/panel/issues/new/choose 4 | about: Please report any frontend/backend bugs on @remnawave/panel repository. 5 | - name: 💡 Feature request 6 | url: https://github.com/remnawave/panel/issues/new/choose 7 | about: Feel free to request any new features. 8 | -------------------------------------------------------------------------------- /.hygen/new/queue/enums/index.ejs.t: -------------------------------------------------------------------------------- 1 | --- 2 | to: "src/queue/<%= h.queueFolderName(queueName) %>/enums/index.ts" 3 | unless_exists: true 4 | --- 5 | <% 6 | queueJobNamesEnumFileName = h.queueJobNamesEnumFileName(queueName) 7 | 8 | %>export * from './<%= queueJobNamesEnumFileName %>'; 9 | -------------------------------------------------------------------------------- /.hygen/new/queue/enums/job-names.enum.ejs.t: -------------------------------------------------------------------------------- 1 | --- 2 | to: "src/queue/<%= h.queueFolderName(queueName) %>/enums/<%= h.queueJobNamesEnumFileName(queueName) %>.ts" 3 | unless_exists: true 4 | --- 5 | <% 6 | queueJobNamesEnumFileName = h.queueJobNamesEnumFileName(queueName) 7 | QueueJobNamesEnumName = h.QueueJobNamesEnumName(queueName) 8 | 9 | %>export enum <%= QueueJobNamesEnumName %> { 10 | exampleJob = 'exampleJob', 11 | } 12 | -------------------------------------------------------------------------------- /.hygen/new/queue/index.ejs.t: -------------------------------------------------------------------------------- 1 | --- 2 | to: "src/queue/<%= h.queueFolderName(queueName) %>/index.ts" 3 | unless_exists: true 4 | --- 5 | <% 6 | queueServiceFileName = h.queueServiceFileName(queueName) 7 | 8 | %>export * from './enums'; 9 | export * from './<%= queueServiceFileName %>'; 10 | -------------------------------------------------------------------------------- /.hygen/new/queue/prompt.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | prompt: ({ prompter }) => { 3 | return prompter 4 | .prompt([ 5 | { 6 | type: 'input', 7 | name: 'queueName', 8 | message: 'Queue Name:', 9 | validate(value) { 10 | if (!value.length) { 11 | return 'Queue must have a name.' 12 | } 13 | return true 14 | } 15 | } 16 | ]) 17 | .then((answer) => { 18 | return answer 19 | }) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": true, 3 | "tabWidth": 4, 4 | "printWidth": 100, 5 | "singleQuote": true, 6 | "trailingComma": "all", 7 | "overrides": [ 8 | { 9 | "files": ["*.js", "*.jsx", "*.ts", "*.tsx"], 10 | "options": { 11 | "parser": "typescript" 12 | } 13 | }, 14 | { 15 | "files": ["*.md", "*.json", "*.yaml", "*.yml"], 16 | "options": { 17 | "tabWidth": 2 18 | } 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | "i18n-ally.disabled": true 4 | } -------------------------------------------------------------------------------- /changelog.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "hideAuthorEmail": true, 3 | "noAuthors": true 4 | } -------------------------------------------------------------------------------- /configs/xray/ssl/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/configs/xray/ssl/.gitkeep -------------------------------------------------------------------------------- /docker-compose-local.yml: -------------------------------------------------------------------------------- 1 | services: 2 | remnawave-panel: 3 | build: 4 | context: . 5 | dockerfile: Dockerfile 6 | container_name: 'remnawave-panel' 7 | restart: always 8 | network_mode: host 9 | env_file: 10 | - .env 11 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/api-tokens.ts: -------------------------------------------------------------------------------- 1 | export const API_TOKENS_CONTROLLER = 'tokens' as const; 2 | 3 | export const API_TOKENS_ROUTES = { 4 | CREATE: '', 5 | DELETE: (uuid: string) => `${uuid}`, 6 | GET: '', 7 | } as const; 8 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/auth.ts: -------------------------------------------------------------------------------- 1 | export const AUTH_CONTROLLER = 'auth' as const; 2 | 3 | export const AUTH_ROUTES = { 4 | LOGIN: 'login', 5 | REGISTER: 'register', 6 | GET_STATUS: 'status', 7 | 8 | OAUTH2: { 9 | TELEGRAM_CALLBACK: 'oauth2/tg/callback', 10 | }, 11 | } as const; 12 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/hwid.ts: -------------------------------------------------------------------------------- 1 | export const HWID_CONTROLLER = 'hwid' as const; 2 | 3 | export const HWID_ROUTES = { 4 | CREATE_USER_HWID_DEVICE: 'devices', 5 | GET_USER_HWID_DEVICES: (userUuid: string) => `devices/${userUuid}`, 6 | DELETE_USER_HWID_DEVICE: 'devices/delete', 7 | } as const; 8 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/inbounds.ts: -------------------------------------------------------------------------------- 1 | export const INBOUNDS_CONTROLLER = 'inbounds' as const; 2 | 3 | export const INBOUNDS_ROUTES = { 4 | GET_INBOUNDS: '', 5 | GET_FULL_INBOUNDS: 'full', 6 | 7 | BULK: { 8 | ADD_INBOUND_TO_USERS: 'bulk/add-to-users', 9 | REMOVE_INBOUND_FROM_USERS: 'bulk/remove-from-users', 10 | ADD_INBOUND_TO_NODES: 'bulk/add-to-nodes', 11 | REMOVE_INBOUND_FROM_NODES: 'bulk/remove-from-nodes', 12 | }, 13 | } as const; 14 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './api-tokens'; 2 | export * from './auth'; 3 | export * from './hosts'; 4 | export * from './hwid'; 5 | export * from './inbounds'; 6 | export * from './keygen'; 7 | export * from './nodes'; 8 | export * from './subscription'; 9 | export * from './subscription-settings'; 10 | export * from './subscription-template'; 11 | export * from './subscriptions'; 12 | export * from './system'; 13 | export * from './users'; 14 | export * from './xray'; 15 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/keygen.ts: -------------------------------------------------------------------------------- 1 | export const KEYGEN_CONTROLLER = 'keygen' as const; 2 | 3 | export const KEYGEN_ROUTES = { 4 | GET: '', 5 | } as const; 6 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/subscription-settings.ts: -------------------------------------------------------------------------------- 1 | export const SUBSCRIPTION_SETTINGS_CONTROLLER = 'subscription-settings' as const; 2 | 3 | export const SUBSCRIPTION_SETTINGS_ROUTES = { 4 | GET: '', 5 | UPDATE: '', 6 | } as const; 7 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/subscription-template.ts: -------------------------------------------------------------------------------- 1 | export const SUBSCRIPTION_TEMPLATE_CONTROLLER = 'subscription-templates' as const; 2 | 3 | export const SUBSCRIPTION_TEMPLATE_ROUTES = { 4 | GET: (templateType: string) => `${templateType}`, 5 | UPDATE: '', 6 | } as const; 7 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/subscription.ts: -------------------------------------------------------------------------------- 1 | export const SUBSCRIPTION_CONTROLLER = 'sub' as const; 2 | 3 | export const SUBSCRIPTION_ROUTES = { 4 | GET: '', 5 | GET_OUTLINE: '/outline', 6 | GET_INFO: (shortUuid: string) => `${shortUuid}/info`, 7 | } as const; 8 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/subscriptions.ts: -------------------------------------------------------------------------------- 1 | export const SUBSCRIPTIONS_CONTROLLER = 'subscriptions' as const; 2 | 3 | export const SUBSCRIPTIONS_ROUTES = { 4 | GET: '', 5 | GET_BY: { 6 | USERNAME: (username: string) => `by-username/${username}`, 7 | }, 8 | } as const; 9 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/system.ts: -------------------------------------------------------------------------------- 1 | export const SYSTEM_CONTROLLER = 'system' as const; 2 | 3 | export const SYSTEM_ROUTES = { 4 | STATS: { 5 | SYSTEM_STATS: 'stats', 6 | BANDWIDTH_STATS: 'stats/bandwidth', 7 | NODES_STATS: 'stats/nodes', 8 | }, 9 | } as const; 10 | -------------------------------------------------------------------------------- /libs/contract/api/controllers/xray.ts: -------------------------------------------------------------------------------- 1 | export const XRAY_CONTROLLER = 'xray' as const; 2 | 3 | export const XRAY_ROUTES = { 4 | GET: '', 5 | UPDATE: '', 6 | } as const; 7 | -------------------------------------------------------------------------------- /libs/contract/api/index.ts: -------------------------------------------------------------------------------- 1 | export * from './controllers'; 2 | export * from './routes'; 3 | -------------------------------------------------------------------------------- /libs/contract/commands/api-tokens/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create.command'; 2 | export * from './delete.command'; 3 | export * from './find.command'; 4 | -------------------------------------------------------------------------------- /libs/contract/commands/auth/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-status.command'; 2 | export * from './login.command'; 3 | export * from './oauth2'; 4 | export * from './register.command'; 5 | -------------------------------------------------------------------------------- /libs/contract/commands/auth/oauth2/index.ts: -------------------------------------------------------------------------------- 1 | export * from './telegram-callback.command'; 2 | -------------------------------------------------------------------------------- /libs/contract/commands/hosts/bulk/index.ts: -------------------------------------------------------------------------------- 1 | export * from './delete-many-hosts.command'; 2 | export * from './disable-many-hosts.command'; 3 | export * from './enable-many-hosts.command'; 4 | export * from './set-inbound-to-many-hosts.command'; 5 | export * from './set-port-to-many-hosts.command'; 6 | -------------------------------------------------------------------------------- /libs/contract/commands/hosts/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk'; 2 | export * from './create.command'; 3 | export * from './delete.command'; 4 | export * from './get-all.command'; 5 | export * from './get-one.command'; 6 | export * from './reorder.command'; 7 | export * from './update.command'; 8 | -------------------------------------------------------------------------------- /libs/contract/commands/hwid/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-user-hwid-device.command'; 2 | export * from './delete-user-hwid-device.command'; 3 | export * from './get-user-hwid-devices.command'; 4 | -------------------------------------------------------------------------------- /libs/contract/commands/inbounds/bulk/index.ts: -------------------------------------------------------------------------------- 1 | export * from './add-inbound-to-nodes.command'; 2 | export * from './add-inbound-to-users.command'; 3 | export * from './remove-inbound-from-nodes.command'; 4 | export * from './remove-inbound-from-users.command'; 5 | -------------------------------------------------------------------------------- /libs/contract/commands/inbounds/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk'; 2 | export * from './get-full-inbounds.command'; 3 | export * from './get-inbounds.command'; 4 | -------------------------------------------------------------------------------- /libs/contract/commands/index.ts: -------------------------------------------------------------------------------- 1 | export * from './api-tokens'; 2 | export * from './auth'; 3 | export * from './hosts'; 4 | export * from './hwid'; 5 | export * from './inbounds'; 6 | export * from './keygen'; 7 | export * from './nodes'; 8 | export * from './subscription'; 9 | export * from './subscription-settings'; 10 | export * from './subscription-template'; 11 | export * from './subscriptions'; 12 | export * from './system'; 13 | export * from './users'; 14 | export * from './xray'; 15 | -------------------------------------------------------------------------------- /libs/contract/commands/keygen/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-pubkey.command'; 2 | -------------------------------------------------------------------------------- /libs/contract/commands/nodes/actions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './disable.command'; 2 | export * from './enable.command'; 3 | export * from './reorder.command'; 4 | export * from './restart-all.command'; 5 | export * from './restart.command'; 6 | -------------------------------------------------------------------------------- /libs/contract/commands/nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './actions'; 2 | export * from './create.command'; 3 | export * from './delete.command'; 4 | export * from './get-all.command'; 5 | export * from './get-one.command'; 6 | export * from './stats'; 7 | export * from './update.command'; 8 | -------------------------------------------------------------------------------- /libs/contract/commands/nodes/stats/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-node-user-usage-by-range.command'; 2 | export * from './get-nodes-usage-by-range.command'; 3 | export * from './get-realtime-usage.command'; 4 | -------------------------------------------------------------------------------- /libs/contract/commands/subscription-settings/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-subscription-settings.command'; 2 | export * from './update-subscription-settings.command'; 3 | -------------------------------------------------------------------------------- /libs/contract/commands/subscription-template/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-template.command'; 2 | export * from './update-template.command'; 3 | -------------------------------------------------------------------------------- /libs/contract/commands/subscription/get-subscription-by-short-uuid.command.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | import { REST_API } from '../../api'; 4 | 5 | export namespace GetSubscriptionByShortUuidCommand { 6 | export const url = REST_API.SUBSCRIPTION.GET; 7 | export const TSQ_url = url(':shortUuid'); 8 | 9 | export const RequestSchema = z.object({ 10 | shortUuid: z.string(), 11 | }); 12 | 13 | export type Request = z.infer; 14 | } 15 | -------------------------------------------------------------------------------- /libs/contract/commands/subscription/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-outline-subscription-by-short-uuid.command'; 2 | export * from './get-subscription-by-short-uuid-by-client-type.command'; 3 | export * from './get-subscription-by-short-uuid.command'; 4 | export * from './get-subscription-info-by-short-uuid.command'; 5 | -------------------------------------------------------------------------------- /libs/contract/commands/subscriptions/get-by/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-subscription-by-username.command'; 2 | -------------------------------------------------------------------------------- /libs/contract/commands/subscriptions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-all-subscriptions.command'; 2 | export * from './get-by'; 3 | -------------------------------------------------------------------------------- /libs/contract/commands/system/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-bandwidth-stats.command'; 2 | export * from './get-nodes-statistics'; 3 | export * from './get-stats.command'; 4 | -------------------------------------------------------------------------------- /libs/contract/commands/users/actions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './activate-all-inbounds.command'; 2 | export * from './disable-user.command'; 3 | export * from './enable-user.command'; 4 | export * from './reset-user-traffic.command'; 5 | export * from './revoke-user-subscription.command'; 6 | -------------------------------------------------------------------------------- /libs/contract/commands/users/bulk-all/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-all-reset-traffic-users.command'; 2 | export * from './bulk-all-update-users.command'; 3 | -------------------------------------------------------------------------------- /libs/contract/commands/users/bulk/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-delete-users-by-status.command'; 2 | export * from './bulk-delete-users.command'; 3 | export * from './bulk-reset-traffic-users.command'; 4 | export * from './bulk-revoke-users-subscription.command'; 5 | export * from './bulk-update-users-inbounds.command'; 6 | export * from './bulk-update-users.command'; 7 | -------------------------------------------------------------------------------- /libs/contract/commands/users/get-by/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-user-by-email.command'; 2 | export * from './get-user-by-short-uuid.command'; 3 | export * from './get-user-by-subscription-uuid.command'; 4 | export * from './get-user-by-tag.command'; 5 | export * from './get-user-by-telegram-id.command'; 6 | export * from './get-user-by-username.command'; 7 | -------------------------------------------------------------------------------- /libs/contract/commands/users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './actions'; 2 | export * from './bulk'; 3 | export * from './bulk-all'; 4 | 5 | export * from './create-user.command'; 6 | export * from './delete-user.command'; 7 | 8 | export * from './get-all-users.command'; 9 | export * from './get-by'; 10 | 11 | export * from './get-user-by-uuid.command'; 12 | 13 | export * from './get-user-usage-by-range.command'; 14 | export * from './tags'; 15 | 16 | export * from './update-user.command'; 17 | -------------------------------------------------------------------------------- /libs/contract/commands/users/tags/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-all-tags.command'; 2 | -------------------------------------------------------------------------------- /libs/contract/commands/xray/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-config.command'; 2 | export * from './update-config.command'; 3 | -------------------------------------------------------------------------------- /libs/contract/constants/endpoint-details/index.ts: -------------------------------------------------------------------------------- 1 | export * from './endpoint-details'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/errors/index.ts: -------------------------------------------------------------------------------- 1 | export * from './errors'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/events/index.ts: -------------------------------------------------------------------------------- 1 | export * from './events'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/hosts/alpn.ts: -------------------------------------------------------------------------------- 1 | export const ALPN = { 2 | H3: 'h3', 3 | H2: 'h2', 4 | HTTP_1_1: 'http/1.1', 5 | H_COMBINED: 'h2,http/1.1', 6 | H3_H2_H1_COMBINED: 'h3,h2,http/1.1', 7 | H3_H2_COMBINED: 'h3,h2', 8 | } as const; 9 | 10 | export type TAlpn = [keyof typeof ALPN][number]; 11 | export const ALPN_VALUES = Object.values(ALPN); 12 | -------------------------------------------------------------------------------- /libs/contract/constants/hosts/fingerprints.ts: -------------------------------------------------------------------------------- 1 | export const FINGERPRINTS = { 2 | CHROME: 'chrome', 3 | FIREFOX: 'firefox', 4 | SAFARI: 'safari', 5 | IOS: 'ios', 6 | ANDROID: 'android', 7 | EDGE: 'edge', 8 | QQ: 'qq', 9 | RANDOM: 'random', 10 | RANDOMIZED: 'randomized', 11 | } as const; 12 | 13 | export type TFingerprints = [keyof typeof FINGERPRINTS][number]; 14 | export const FINGERPRINTS_VALUES = Object.values(FINGERPRINTS); 15 | -------------------------------------------------------------------------------- /libs/contract/constants/hosts/index.ts: -------------------------------------------------------------------------------- 1 | export * from './alpn'; 2 | export * from './fingerprints'; 3 | export * from './security-layers'; 4 | -------------------------------------------------------------------------------- /libs/contract/constants/hosts/security-layers.ts: -------------------------------------------------------------------------------- 1 | export const SECURITY_LAYERS = { 2 | DEFAULT: 'DEFAULT', 3 | TLS: 'TLS', 4 | NONE: 'NONE', 5 | } as const; 6 | 7 | export type TSecurityLayers = [keyof typeof SECURITY_LAYERS][number]; 8 | export const SECURITY_LAYERS_VALUES = Object.values(SECURITY_LAYERS); 9 | -------------------------------------------------------------------------------- /libs/contract/constants/index.ts: -------------------------------------------------------------------------------- 1 | export * from './endpoint-details'; 2 | export * from './errors'; 3 | export * from './events'; 4 | export * from './hosts'; 5 | export * from './metrics'; 6 | export * from './nodes'; 7 | export * from './roles'; 8 | export * from './subscription-template'; 9 | export * from './templates'; 10 | export * from './users'; 11 | -------------------------------------------------------------------------------- /libs/contract/constants/metrics/index.ts: -------------------------------------------------------------------------------- 1 | export * from './metric-names.constant'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/metrics/metric-names.constant.ts: -------------------------------------------------------------------------------- 1 | export const METRIC_NAMES = { 2 | NODE_ONLINE_USERS: 'node_online_users', 3 | NODE_STATUS: 'node_status', 4 | USERS_STATUS: 'users_status', 5 | USERS_TOTAL: 'users_total', 6 | } as const; 7 | 8 | export type TMetricNames = typeof METRIC_NAMES; 9 | export type TMetricNamesKeys = (typeof METRIC_NAMES)[keyof typeof METRIC_NAMES]; 10 | -------------------------------------------------------------------------------- /libs/contract/constants/nodes/cycle/cycle.ts: -------------------------------------------------------------------------------- 1 | export const NODES_CYCLE = { 2 | MONTH: 'MONTH', 3 | YEAR: 'YEAR', 4 | } as const; 5 | 6 | export type TNodesCycle = [keyof typeof NODES_CYCLE][number]; 7 | export const NODES_CYCLE_VALUES = Object.values(NODES_CYCLE); 8 | -------------------------------------------------------------------------------- /libs/contract/constants/nodes/cycle/index.ts: -------------------------------------------------------------------------------- 1 | export * from './cycle'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './cycle'; 2 | export * from './status'; 3 | -------------------------------------------------------------------------------- /libs/contract/constants/nodes/status/index.ts: -------------------------------------------------------------------------------- 1 | export * from './status.constant'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/nodes/status/status.constant.ts: -------------------------------------------------------------------------------- 1 | export const NODES_STATUS = { 2 | CONNECTED: 'CONNECTED', 3 | DISCONNECTED: 'DISCONNECTED', 4 | DISABLED: 'DISABLED', 5 | } as const; 6 | 7 | export type TNodesStatus = [keyof typeof NODES_STATUS][number]; 8 | export const NODES_STATUS_VALUES = Object.values(NODES_STATUS); 9 | -------------------------------------------------------------------------------- /libs/contract/constants/roles/index.ts: -------------------------------------------------------------------------------- 1 | export * from './role'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/roles/role.ts: -------------------------------------------------------------------------------- 1 | export const ROLE = { 2 | ADMIN: 'ADMIN', 3 | API: 'API', 4 | } as const; 5 | 6 | export type TRole = typeof ROLE; 7 | export type TRolesKeys = (typeof ROLE)[keyof typeof ROLE]; 8 | export type TRoleTypes = [keyof typeof ROLE][number]; 9 | -------------------------------------------------------------------------------- /libs/contract/constants/subscription-template/index.ts: -------------------------------------------------------------------------------- 1 | export * from './template-type'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/subscription-template/template-type/index.ts: -------------------------------------------------------------------------------- 1 | export * from './request-template-type.constant'; 2 | export * from './template-type.constant'; 3 | -------------------------------------------------------------------------------- /libs/contract/constants/subscription-template/template-type/template-type.constant.ts: -------------------------------------------------------------------------------- 1 | export const SUBSCRIPTION_TEMPLATE_TYPE = { 2 | STASH: 'STASH', 3 | SINGBOX: 'SINGBOX', 4 | SINGBOX_LEGACY: 'SINGBOX_LEGACY', 5 | MIHOMO: 'MIHOMO', 6 | XRAY_JSON: 'XRAY_JSON', 7 | CLASH: 'CLASH', 8 | } as const; 9 | 10 | export type TSubscriptionTemplateType = [keyof typeof SUBSCRIPTION_TEMPLATE_TYPE][number]; 11 | export const SUBSCRIPTION_TEMPLATE_TYPE_VALUES = Object.values(SUBSCRIPTION_TEMPLATE_TYPE); 12 | -------------------------------------------------------------------------------- /libs/contract/constants/templates/index.ts: -------------------------------------------------------------------------------- 1 | export * from './template-keys'; 2 | export * from './user-statuses'; 3 | -------------------------------------------------------------------------------- /libs/contract/constants/templates/template-keys.ts: -------------------------------------------------------------------------------- 1 | export const TEMPLATE_KEYS = [ 2 | 'DAYS_LEFT', 3 | 'TRAFFIC_USED', 4 | 'TRAFFIC_LEFT', 5 | 'STATUS', 6 | 'TOTAL_TRAFFIC', 7 | 'USERNAME', 8 | 'EMAIL', 9 | 'TELEGRAM_ID', 10 | 'SUBSCRIPTION_URL', 11 | ] as const; 12 | export type TemplateKeys = (typeof TEMPLATE_KEYS)[number]; 13 | -------------------------------------------------------------------------------- /libs/contract/constants/templates/user-statuses.ts: -------------------------------------------------------------------------------- 1 | export const USER_STATUSES_TEMPLATE = { 2 | ACTIVE: ' ✅ Active', 3 | EXPIRED: ' ⚠️ Expired', 4 | DISABLED: '❌ Disabled', 5 | LIMITED: '🔴 Limited', 6 | } as const; 7 | -------------------------------------------------------------------------------- /libs/contract/constants/users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reset-periods'; 2 | export * from './status'; 3 | -------------------------------------------------------------------------------- /libs/contract/constants/users/reset-periods/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reset-periods.constant'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/users/reset-periods/reset-periods.constant.ts: -------------------------------------------------------------------------------- 1 | export const RESET_PERIODS = { 2 | NO_RESET: 'NO_RESET', 3 | DAY: 'DAY', 4 | WEEK: 'WEEK', 5 | MONTH: 'MONTH', 6 | } as const; 7 | 8 | export type TResetPeriods = [keyof typeof RESET_PERIODS][number]; 9 | export const RESET_PERIODS_VALUES = Object.values(RESET_PERIODS); 10 | -------------------------------------------------------------------------------- /libs/contract/constants/users/status/index.ts: -------------------------------------------------------------------------------- 1 | export * from './status.constant'; 2 | -------------------------------------------------------------------------------- /libs/contract/constants/users/status/status.constant.ts: -------------------------------------------------------------------------------- 1 | export const USERS_STATUS = { 2 | ACTIVE: 'ACTIVE', 3 | DISABLED: 'DISABLED', 4 | LIMITED: 'LIMITED', 5 | EXPIRED: 'EXPIRED', 6 | } as const; 7 | 8 | export type TUsersStatus = [keyof typeof USERS_STATUS][number]; 9 | export const USERS_STATUS_VALUES = Object.values(USERS_STATUS); 10 | -------------------------------------------------------------------------------- /libs/contract/index.ts: -------------------------------------------------------------------------------- 1 | export * from './api'; 2 | export * from './commands'; 3 | export * from './constants'; 4 | export * from './models'; 5 | -------------------------------------------------------------------------------- /libs/contract/models/api-tokens.schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | export const ApiTokensSchema = z.object({ 4 | uuid: z.string().uuid(), 5 | token: z.string(), 6 | tokenName: z.string(), 7 | tokenDescription: z.nullable(z.string()), 8 | 9 | createdAt: z 10 | .string() 11 | .datetime() 12 | .transform((str) => new Date(str)), 13 | updatedAt: z 14 | .string() 15 | .datetime() 16 | .transform((str) => new Date(str)), 17 | }); 18 | -------------------------------------------------------------------------------- /libs/contract/models/auth.schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | export const AuthSchema = z.object({ 4 | hash: z.string(), 5 | }); 6 | -------------------------------------------------------------------------------- /libs/contract/models/base-stat.schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | export const BaseStatSchema = z.object({ 4 | current: z.string(), 5 | previous: z.string(), 6 | difference: z.string(), 7 | }); 8 | -------------------------------------------------------------------------------- /libs/contract/models/extented-users.schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | import { LastConnectedNodeSchema } from './last-connected-node.schema'; 4 | import { UsersSchema } from './users.schema'; 5 | import { HappSchema } from './happ.schema'; 6 | 7 | export const ExtendedUsersSchema = UsersSchema.extend({ 8 | subscriptionUrl: z.string(), 9 | lastConnectedNode: LastConnectedNodeSchema, 10 | happ: HappSchema, 11 | }); 12 | -------------------------------------------------------------------------------- /libs/contract/models/happ.schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | export const HappSchema = z.object({ 4 | cryptoLink: z.string(), 5 | }); 6 | -------------------------------------------------------------------------------- /libs/contract/models/inbounds.schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | export const InboundsSchema = z.object({ 4 | uuid: z.string().uuid(), 5 | tag: z.string(), 6 | type: z.string(), 7 | network: z.nullable(z.string()), 8 | security: z.nullable(z.string()), 9 | }); 10 | -------------------------------------------------------------------------------- /libs/contract/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './api-tokens.schema'; 2 | export * from './auth.schema'; 3 | export * from './base-stat.schema'; 4 | export * from './extented-users.schema'; 5 | export * from './full-inbounds.schema'; 6 | export * from './happ.schema'; 7 | export * from './hosts.schema'; 8 | export * from './hwid-user-device.schema'; 9 | export * from './inbounds.schema'; 10 | export * from './last-connected-node.schema'; 11 | export * from './nodes.schema'; 12 | export * from './subscription-settings.schema'; 13 | export * from './users.schema'; 14 | -------------------------------------------------------------------------------- /libs/contract/models/last-connected-node.schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | export const LastConnectedNodeSchema = z 4 | .object({ 5 | connectedAt: z 6 | .string() 7 | .datetime() 8 | .transform((str) => new Date(str)), 9 | nodeName: z.string(), 10 | }) 11 | .nullable(); 12 | -------------------------------------------------------------------------------- /prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (e.g., Git) 3 | provider = "postgresql" -------------------------------------------------------------------------------- /prisma/tsconfig.seed.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../dist/prisma", 5 | "module": "NodeNext" 6 | }, 7 | "include": [ 8 | "seed/**/*" 9 | ] 10 | } -------------------------------------------------------------------------------- /src/common/axios/axios.module.ts: -------------------------------------------------------------------------------- 1 | import { Global, Module } from '@nestjs/common'; 2 | import { CqrsModule } from '@nestjs/cqrs'; 3 | 4 | import { AxiosService } from './axios.service'; 5 | 6 | @Global() 7 | @Module({ 8 | imports: [CqrsModule], 9 | providers: [AxiosService], 10 | exports: [AxiosService], 11 | }) 12 | export class AxiosModule {} 13 | -------------------------------------------------------------------------------- /src/common/axios/index.ts: -------------------------------------------------------------------------------- 1 | export * from './axios.module'; 2 | export * from './axios.service'; 3 | -------------------------------------------------------------------------------- /src/common/config/app-config/index.ts: -------------------------------------------------------------------------------- 1 | export * from './config.schema'; 2 | -------------------------------------------------------------------------------- /src/common/config/jwt/index.ts: -------------------------------------------------------------------------------- 1 | export * from './jwt.config'; 2 | -------------------------------------------------------------------------------- /src/common/config/jwt/jwt.config.ts: -------------------------------------------------------------------------------- 1 | import { ConfigModule, ConfigService } from '@nestjs/config'; 2 | import { JwtModuleAsyncOptions } from '@nestjs/jwt'; 3 | 4 | export const getJWTConfig = (): JwtModuleAsyncOptions => ({ 5 | imports: [ConfigModule], 6 | inject: [ConfigService], 7 | useFactory: (configService: ConfigService) => ({ 8 | secret: configService.getOrThrow('JWT_AUTH_SECRET'), 9 | }), 10 | }); 11 | -------------------------------------------------------------------------------- /src/common/database/index.ts: -------------------------------------------------------------------------------- 1 | export * from './prisma.module'; 2 | -------------------------------------------------------------------------------- /src/common/database/prisma.module.ts: -------------------------------------------------------------------------------- 1 | import { Global, Module } from '@nestjs/common'; 2 | 3 | import { PrismaService } from './prisma.service'; 4 | 5 | @Global() 6 | @Module({ 7 | providers: [PrismaService], 8 | exports: [PrismaService], 9 | }) 10 | export class PrismaModule {} 11 | -------------------------------------------------------------------------------- /src/common/database/prisma.service.ts: -------------------------------------------------------------------------------- 1 | import { PrismaClient } from '@prisma/client'; 2 | 3 | import { Injectable, OnModuleInit } from '@nestjs/common'; 4 | // { log: ['query'] } 5 | @Injectable() 6 | export class PrismaService extends PrismaClient implements OnModuleInit { 7 | constructor() { 8 | super(); 9 | } 10 | async onModuleInit() { 11 | await this.$connect(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/common/decorators/base-endpoint/index.ts: -------------------------------------------------------------------------------- 1 | export * from './base-endpoint'; 2 | -------------------------------------------------------------------------------- /src/common/decorators/get-client-country-code/get-client-country-code.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 2 | 3 | export const GetClientCountryCode = createParamDecorator( 4 | (data: unknown, ctx: ExecutionContext): string => { 5 | const request = ctx.switchToHttp().getRequest(); 6 | const country = request.headers['cf-ipcountry'] as null | string; 7 | if (!country) { 8 | return 'XX'; 9 | } 10 | return country; 11 | }, 12 | ); 13 | -------------------------------------------------------------------------------- /src/common/decorators/get-client-country-code/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-client-country-code'; 2 | -------------------------------------------------------------------------------- /src/common/decorators/get-ip/get-ip.ts: -------------------------------------------------------------------------------- 1 | import requestIp from 'request-ip'; 2 | 3 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 4 | 5 | export const IpAddress = createParamDecorator((data, ctx: ExecutionContext) => { 6 | const request = ctx.switchToHttp().getRequest(); 7 | 8 | if (request.clientIp) { 9 | return request.clientIp; 10 | } 11 | 12 | const ip = requestIp.getClientIp(request); 13 | return ip || 'Unknown'; 14 | }); 15 | -------------------------------------------------------------------------------- /src/common/decorators/get-ip/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-ip'; 2 | -------------------------------------------------------------------------------- /src/common/decorators/get-jwt-payload/get-jwt-payload.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 2 | 3 | export const GetJWTPayload = createParamDecorator((data: unknown, ctx: ExecutionContext) => { 4 | const request = ctx.switchToHttp().getRequest(); 5 | return request.user; 6 | }); 7 | -------------------------------------------------------------------------------- /src/common/decorators/get-jwt-payload/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-jwt-payload'; 2 | -------------------------------------------------------------------------------- /src/common/decorators/get-useragent/get-useragent.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 2 | 3 | export const UserAgent = createParamDecorator((data, ctx: ExecutionContext) => { 4 | const request = ctx.switchToHttp().getRequest(); 5 | 6 | if (request.headers['user-agent']) { 7 | return request.headers['user-agent']; 8 | } 9 | 10 | return 'Unknown'; 11 | }); 12 | -------------------------------------------------------------------------------- /src/common/decorators/get-useragent/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-useragent'; 2 | -------------------------------------------------------------------------------- /src/common/decorators/roles/index.ts: -------------------------------------------------------------------------------- 1 | import { Roles } from './roles'; 2 | 3 | export { Roles }; 4 | -------------------------------------------------------------------------------- /src/common/decorators/roles/roles.ts: -------------------------------------------------------------------------------- 1 | import { SetMetadata } from '@nestjs/common'; 2 | 3 | import { ROLE, TRolesKeys } from '@libs/contracts/constants'; 4 | 5 | export const Roles = (...roles: TRolesKeys[]) => SetMetadata(ROLE, roles); 6 | -------------------------------------------------------------------------------- /src/common/exception/http-exeception-with-error-code.type.ts: -------------------------------------------------------------------------------- 1 | import { HttpException } from '@nestjs/common/exceptions/http.exception'; 2 | 3 | export class HttpExceptionWithErrorCodeType extends HttpException { 4 | errorCode: string; 5 | 6 | constructor(message: string, errorCode: string, statusCode: number) { 7 | super(message, statusCode); 8 | this.errorCode = errorCode; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/common/exception/not-found-exception.filter.ts: -------------------------------------------------------------------------------- 1 | import { ArgumentsHost, Catch, ExceptionFilter, NotFoundException } from '@nestjs/common'; 2 | 3 | @Catch(NotFoundException) 4 | export class NotFoundExceptionFilter implements ExceptionFilter { 5 | catch(exception: NotFoundException, host: ArgumentsHost) { 6 | const ctx = host.switchToHttp(); 7 | const response = ctx.getResponse(); 8 | 9 | response.socket?.destroy(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/common/guards/jwt-guards/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/common/guards/jwt-guards/index.ts -------------------------------------------------------------------------------- /src/common/guards/proxy-check/index.ts: -------------------------------------------------------------------------------- 1 | export * from './proxy-check.guard'; 2 | -------------------------------------------------------------------------------- /src/common/guards/roles/index.ts: -------------------------------------------------------------------------------- 1 | import { RolesGuard } from './roles.guard'; 2 | 3 | export { RolesGuard }; 4 | -------------------------------------------------------------------------------- /src/common/guards/worker-routes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './worker-routes.guard'; 2 | -------------------------------------------------------------------------------- /src/common/helpers/can-parse-json.ts: -------------------------------------------------------------------------------- 1 | export function canParseJSON(jsonString: string): boolean { 2 | try { 3 | JSON.parse(jsonString); 4 | return true; 5 | } catch { 6 | return false; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/common/helpers/error-handler-with-null.helper.ts: -------------------------------------------------------------------------------- 1 | import { errorHandler } from '@common/helpers/error-handler.helper'; 2 | 3 | import { ICommandResponse } from '../types/command-response.type'; 4 | 5 | export function errorHandlerWithNull(response: ICommandResponse): null | T { 6 | if (response.isOk) { 7 | if (!response.response) { 8 | return null; 9 | } 10 | return errorHandler(response); 11 | } else { 12 | return errorHandler(response); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/common/helpers/xray-config/index.ts: -------------------------------------------------------------------------------- 1 | export * from './xray-config.validator'; 2 | -------------------------------------------------------------------------------- /src/common/helpers/xray-config/interfaces/core.config.ts: -------------------------------------------------------------------------------- 1 | import { InboundObject } from './protocols.config'; 2 | 3 | export interface IXrayConfig { 4 | api?: unknown; 5 | dns?: unknown; 6 | fakedns?: unknown; 7 | inbounds: InboundObject[]; 8 | log?: unknown; 9 | outbounds: unknown; 10 | policy?: unknown; 11 | reverse?: unknown; 12 | routing?: unknown; 13 | stats?: unknown; 14 | } 15 | -------------------------------------------------------------------------------- /src/common/helpers/xray-config/interfaces/ctr.type.ts: -------------------------------------------------------------------------------- 1 | export type TCtrXRayConfig = object | Record | string; 2 | -------------------------------------------------------------------------------- /src/common/helpers/xray-config/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './core.config'; 2 | export * from './ctr.type'; 3 | export * from './protocol-settings.config'; 4 | export * from './protocols.config'; 5 | export * from './routing.config'; 6 | export * from './transport.config'; 7 | -------------------------------------------------------------------------------- /src/common/helpers/xray-config/interfaces/routing.config.ts: -------------------------------------------------------------------------------- 1 | export interface FallbackObject { 2 | alpn?: string; 3 | dest?: number | string; 4 | path?: string; 5 | xver?: number; 6 | } 7 | -------------------------------------------------------------------------------- /src/common/middlewares/get-real-ip.ts: -------------------------------------------------------------------------------- 1 | import { NextFunction, Request, Response } from 'express'; 2 | import { getClientIp } from '@supercharge/request-ip'; 3 | import morgan from 'morgan'; 4 | 5 | morgan.token('remote-addr', (req: Request) => { 6 | return getClientIp(req) || '0.0.0.0'; 7 | }); 8 | 9 | export const getRealIp = function (req: Request, res: Response, next: NextFunction) { 10 | next(); 11 | }; 12 | -------------------------------------------------------------------------------- /src/common/middlewares/index.ts: -------------------------------------------------------------------------------- 1 | export * from './basic-auth.middleware'; 2 | export * from './check-auth-cookie.middleware'; 3 | export * from './get-real-ip'; 4 | export * from './proxy-check.middleware'; 5 | -------------------------------------------------------------------------------- /src/common/types/command-response.type.ts: -------------------------------------------------------------------------------- 1 | export interface ICommandResponse { 2 | code?: string; 3 | isOk: boolean; 4 | message?: string; 5 | response?: T; 6 | } 7 | -------------------------------------------------------------------------------- /src/common/types/converter.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IConverter { 2 | fromEntitiesToPrismaModels(entities: T[]): U[]; 3 | fromEntityToPrismaModel(entity: T): U; 4 | fromPrismaModelsToEntities(prismaModels: U[]): T[]; 5 | fromPrismaModelToEntity(prismaModel: U): T; 6 | } 7 | -------------------------------------------------------------------------------- /src/common/utils/bytes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './pretty-bytes.util'; 2 | -------------------------------------------------------------------------------- /src/common/utils/certs/encode-node-payload.ts: -------------------------------------------------------------------------------- 1 | interface INodePayload { 2 | nodeCertPem: string; 3 | nodeKeyPem: string; 4 | caCertPem: string; 5 | jwtPublicKey: string; 6 | } 7 | 8 | export function encodeCertPayload(payload: INodePayload): string { 9 | const json = JSON.stringify(payload); 10 | return Buffer.from(json, 'utf-8').toString('base64'); 11 | } 12 | -------------------------------------------------------------------------------- /src/common/utils/certs/index.ts: -------------------------------------------------------------------------------- 1 | export * from './generate-certs.util'; 2 | -------------------------------------------------------------------------------- /src/common/utils/extract-hwid-headers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './extract-hwid-headers.util'; 2 | -------------------------------------------------------------------------------- /src/common/utils/filter-logs/filter-logs.ts: -------------------------------------------------------------------------------- 1 | import winston from 'winston'; 2 | 3 | const contextsToIgnore = ['InstanceLoader', 'RoutesResolver', 'RouterExplorer']; 4 | 5 | export const customLogFilter = winston.format((info) => { 6 | if (info.context) { 7 | const contextValue = String(info.context); 8 | if (contextsToIgnore.some((ctx) => contextValue === ctx)) { 9 | return false; 10 | } 11 | } 12 | return info; 13 | }); 14 | -------------------------------------------------------------------------------- /src/common/utils/filter-logs/index.ts: -------------------------------------------------------------------------------- 1 | export * from './filter-logs'; 2 | -------------------------------------------------------------------------------- /src/common/utils/flow/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-vless-flow'; 2 | -------------------------------------------------------------------------------- /src/common/utils/get-elapsed-time.ts: -------------------------------------------------------------------------------- 1 | import ms from 'enhanced-ms'; 2 | 3 | export function formatExecutionTime(startTime: number): string { 4 | return ms(Date.now() - startTime, 'short') || '0ms'; 5 | } 6 | 7 | export function getTime(): number { 8 | return Date.now(); 9 | } 10 | -------------------------------------------------------------------------------- /src/common/utils/get-utc-date.util.ts: -------------------------------------------------------------------------------- 1 | export const getUtcDateUtil = () => { 2 | const now = new Date(); 3 | const utcTimestamp = Date.UTC( 4 | now.getUTCFullYear(), 5 | now.getUTCMonth(), 6 | now.getUTCDate(), 7 | now.getUTCHours(), 8 | now.getUTCMinutes(), 9 | now.getUTCSeconds(), 10 | now.getUTCMilliseconds(), 11 | ); 12 | return new Date(utcTimestamp); 13 | }; 14 | -------------------------------------------------------------------------------- /src/common/utils/happ-crypto-link/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-happ-crypto-link.util'; 2 | -------------------------------------------------------------------------------- /src/common/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './certs'; 2 | export * from './happ-crypto-link'; 3 | export * from './superjson'; 4 | -------------------------------------------------------------------------------- /src/common/utils/nano/index.ts: -------------------------------------------------------------------------------- 1 | export * from './nano.util'; 2 | -------------------------------------------------------------------------------- /src/common/utils/resolve-country-emoji.ts: -------------------------------------------------------------------------------- 1 | import countryCodeEmoji from 'country-code-emoji'; 2 | 3 | export function resolveCountryEmoji(countryCode: string): string { 4 | if (countryCode === 'XX') { 5 | return '🏴‍☠️'; 6 | } 7 | 8 | try { 9 | return countryCodeEmoji(countryCode); 10 | } catch { 11 | return '🏴‍☠️'; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/common/utils/sleep.ts: -------------------------------------------------------------------------------- 1 | export function sleep(ms: number): Promise { 2 | return new Promise((resolve) => setTimeout(resolve, ms)); 3 | } 4 | -------------------------------------------------------------------------------- /src/common/utils/startup-app/index.ts: -------------------------------------------------------------------------------- 1 | export * from './docs'; 2 | export * from './init-log.util'; 3 | export * from './is-development'; 4 | -------------------------------------------------------------------------------- /src/common/utils/startup-app/init-log.util.ts: -------------------------------------------------------------------------------- 1 | import { LogLevel } from '@nestjs/common'; 2 | 3 | import { isDevelopment } from './is-development'; 4 | 5 | export function initLogs(): LogLevel[] { 6 | const logLevels: LogLevel[] = isDevelopment() 7 | ? ['log', 'error', 'warn', 'debug', 'verbose'] 8 | : ['log', 'error', 'warn']; 9 | 10 | return logLevels; 11 | } 12 | -------------------------------------------------------------------------------- /src/common/utils/superjson/index.ts: -------------------------------------------------------------------------------- 1 | export * from './superjson.util'; 2 | -------------------------------------------------------------------------------- /src/common/utils/superjson/superjson.util.ts: -------------------------------------------------------------------------------- 1 | import { ClassConstructor, instanceToPlain, plainToInstance } from 'class-transformer'; 2 | import superjson from 'superjson'; 3 | 4 | export function serializeCustom(data: T): string { 5 | return superjson.stringify(instanceToPlain(data)); 6 | } 7 | 8 | export function deserialize(data: string, type: ClassConstructor): T { 9 | return plainToInstance(type, superjson.parse(data)); 10 | } 11 | -------------------------------------------------------------------------------- /src/common/utils/templates/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/common/utils/templates/index.ts -------------------------------------------------------------------------------- /src/common/utils/validate-env-config.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | 3 | export function validateEnvConfig(schema: z.ZodType, config: Record): T { 4 | try { 5 | return schema.parse(config); 6 | } catch (e) { 7 | throw new Error(`.env configuration validation error: ${e}`); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/interfaces/error.event.interface.ts: -------------------------------------------------------------------------------- 1 | import { TErrorsEvents } from '@libs/contracts/constants'; 2 | 3 | export interface IErrorEvent { 4 | description: string; 5 | } 6 | 7 | export class CustomErrorEvent { 8 | eventName: TErrorsEvents; 9 | data: IErrorEvent; 10 | 11 | constructor(event: TErrorsEvents, data: IErrorEvent) { 12 | this.eventName = event; 13 | this.data = data; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './error.event.interface'; 2 | export * from './node.event.interface'; 3 | export * from './service.event.interface'; 4 | export * from './user.event.interface'; 5 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/interfaces/node.event.interface.ts: -------------------------------------------------------------------------------- 1 | import { TNodeEvents } from '@libs/contracts/constants'; 2 | 3 | import { NodesEntity } from '@modules/nodes/entities/nodes.entity'; 4 | 5 | export class NodeEvent { 6 | node: NodesEntity; 7 | eventName: TNodeEvents; 8 | 9 | constructor(node: NodesEntity, event: TNodeEvents) { 10 | this.node = node; 11 | this.eventName = event; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/telegram-bot/bot.update.service.ts: -------------------------------------------------------------------------------- 1 | import { InjectBot, Update } from '@kastov/grammy-nestjs'; 2 | import { Bot, Context } from 'grammy'; 3 | 4 | import { BOT_NAME } from './constants/bot-name.constant'; 5 | 6 | @Update() 7 | export class BotUpdateService { 8 | constructor( 9 | @InjectBot(BOT_NAME) 10 | private readonly bot: Bot, 11 | ) {} 12 | } 13 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/telegram-bot/constants/bot-name.constant.ts: -------------------------------------------------------------------------------- 1 | export const BOT_NAME = 'RemnawaveBot'; 2 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/telegram-bot/constants/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bot-name.constant'; 2 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/telegram-bot/decorators/index.ts: -------------------------------------------------------------------------------- 1 | export * from './require-admin-id.decorator'; 2 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/telegram-bot/events/index.ts: -------------------------------------------------------------------------------- 1 | import { ServiceEvents } from './service/service.events'; 2 | import { UsersEvents } from './users/users.events'; 3 | import { NodesEvents } from './nodes'; 4 | 5 | export const TELEGRAM_BOT_EVENTS = [UsersEvents, NodesEvents, ServiceEvents]; 6 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/telegram-bot/events/nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './nodes.events'; 2 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/telegram-bot/events/service/index.ts: -------------------------------------------------------------------------------- 1 | export * from './service.events'; 2 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/telegram-bot/events/users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './users.events'; 2 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/webhook-module/events/index.ts: -------------------------------------------------------------------------------- 1 | import { WebhookEvents } from './webhook.events'; 2 | 3 | export const WEBHOOK_EVENTS = [WebhookEvents]; 4 | -------------------------------------------------------------------------------- /src/integration-modules/notifications/webhook-module/webhook.module.ts: -------------------------------------------------------------------------------- 1 | import { ConfigModule } from '@nestjs/config'; 2 | import { Module } from '@nestjs/common'; 3 | 4 | import { WEBHOOK_EVENTS } from './events'; 5 | 6 | @Module({ 7 | imports: [ConfigModule], 8 | controllers: [], 9 | providers: [...WEBHOOK_EVENTS], 10 | }) 11 | export class WebhookModule {} 12 | -------------------------------------------------------------------------------- /src/integration-modules/prometheus-reporter/guards/basic-auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { ExecutionContext, Injectable } from '@nestjs/common'; 2 | import { AuthGuard } from '@nestjs/passport'; 3 | 4 | @Injectable() 5 | export class BasicAuthGuard extends AuthGuard('basic') { 6 | canActivate(context: ExecutionContext) { 7 | const response = context.switchToHttp().getResponse(); 8 | 9 | response.setHeader('WWW-Authenticate', 'Basic realm="Prometheus Metrics"'); 10 | 11 | return super.canActivate(context); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/integration-modules/prometheus-reporter/guards/index.ts: -------------------------------------------------------------------------------- 1 | export * from './basic-auth.guard'; 2 | -------------------------------------------------------------------------------- /src/integration-modules/prometheus-reporter/strategies/index.ts: -------------------------------------------------------------------------------- 1 | export * from './basic.strategy'; 2 | -------------------------------------------------------------------------------- /src/modules/admin/commands/create-admin/create-admin.command.ts: -------------------------------------------------------------------------------- 1 | import { TRoleTypes } from '@libs/contracts/constants'; 2 | 3 | export class CreateAdminCommand { 4 | constructor( 5 | public readonly username: string, 6 | public readonly password: string, 7 | public readonly role: TRoleTypes, 8 | ) {} 9 | } 10 | -------------------------------------------------------------------------------- /src/modules/admin/commands/create-admin/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-admin.command'; 2 | export * from './create-admin.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/admin/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateAdminHandler } from './create-admin'; 2 | 3 | export const COMMANDS = [CreateAdminHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/admin/entities/admin.entity.ts: -------------------------------------------------------------------------------- 1 | import { Admin } from '@prisma/client'; 2 | 3 | import { TRoleTypes } from '@libs/contracts/constants'; 4 | 5 | export class AdminEntity implements Admin { 6 | public uuid: string; 7 | public username: string; 8 | public passwordHash: string; 9 | public role: TRoleTypes; 10 | 11 | public createdAt: Date; 12 | public updatedAt: Date; 13 | 14 | constructor(admin: Partial) { 15 | Object.assign(this, admin); 16 | return this; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/modules/admin/queries/count-admins-by-role/count-admins-by-role.query.ts: -------------------------------------------------------------------------------- 1 | import { TRoleTypes } from '@libs/contracts/constants'; 2 | 3 | export class CountAdminsByRoleQuery { 4 | constructor(public readonly role: TRoleTypes) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/admin/queries/count-admins-by-role/index.ts: -------------------------------------------------------------------------------- 1 | export * from './count-admins-by-role.handler'; 2 | export * from './count-admins-by-role.query'; 3 | -------------------------------------------------------------------------------- /src/modules/admin/queries/get-admin-by-username/get-admin-by-username.query.ts: -------------------------------------------------------------------------------- 1 | import { TRoleTypes } from '@libs/contracts/constants'; 2 | 3 | export class GetAdminByUsernameQuery { 4 | constructor( 5 | public readonly username: string, 6 | public readonly role: TRoleTypes, 7 | ) {} 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/admin/queries/get-admin-by-username/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-admin-by-username.handler'; 2 | export * from './get-admin-by-username.query'; 3 | -------------------------------------------------------------------------------- /src/modules/admin/queries/get-first-admin/get-first-admin.query.ts: -------------------------------------------------------------------------------- 1 | import { TRoleTypes } from '@libs/contracts/constants'; 2 | 3 | export class GetFirstAdminQuery { 4 | constructor(public readonly role: TRoleTypes) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/admin/queries/get-first-admin/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-first-admin.handler'; 2 | export * from './get-first-admin.query'; 3 | -------------------------------------------------------------------------------- /src/modules/admin/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetAdminByUsernameHandler } from './get-admin-by-username'; 2 | import { CountAdminsByRoleHandler } from './count-admins-by-role'; 3 | import { GetFirstAdminHandler } from './get-first-admin'; 4 | 5 | export const QUERIES = [GetAdminByUsernameHandler, CountAdminsByRoleHandler, GetFirstAdminHandler]; 6 | -------------------------------------------------------------------------------- /src/modules/api-tokens/dtos/create.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { CreateApiTokenCommand } from '@libs/contracts/commands'; 4 | 5 | export class CreateApiTokenRequestDto extends createZodDto(CreateApiTokenCommand.RequestSchema) {} 6 | export class CreateApiTokenResponseDto extends createZodDto(CreateApiTokenCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/api-tokens/dtos/delete.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { DeleteApiTokenCommand } from '@libs/contracts/commands'; 4 | 5 | export class DeleteApiTokenRequestDto extends createZodDto(DeleteApiTokenCommand.RequestSchema) {} 6 | export class DeleteApiTokenResponseDto extends createZodDto(DeleteApiTokenCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/api-tokens/dtos/find.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { FindAllApiTokensCommand } from '@libs/contracts/commands'; 4 | 5 | export class FindAllApiTokensResponseDto extends createZodDto( 6 | FindAllApiTokensCommand.ResponseSchema, 7 | ) {} 8 | -------------------------------------------------------------------------------- /src/modules/api-tokens/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create.dto'; 2 | export * from './delete.dto'; 3 | export * from './find.dto'; 4 | -------------------------------------------------------------------------------- /src/modules/api-tokens/entities/api-token.entity.ts: -------------------------------------------------------------------------------- 1 | import { ApiTokens } from '@prisma/client'; 2 | 3 | export class ApiTokenEntity implements ApiTokens { 4 | public uuid: string; 5 | public token: string; 6 | public tokenName: string; 7 | public tokenDescription: null | string; 8 | 9 | public createdAt: Date; 10 | public updatedAt: Date; 11 | 12 | constructor(apiToken: Partial) { 13 | Object.assign(this, apiToken); 14 | return this; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/modules/api-tokens/interfaces/api-token-jwt-payload.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IApiTokenJWTPayload { 2 | uuid: string; 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/api-tokens/interfaces/create.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ICreateApiTokenRequest { 2 | tokenDescription: null | string; 3 | tokenName: string; 4 | } 5 | 6 | export interface ICreateApiTokenResponse { 7 | token: string; 8 | uuid: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/modules/api-tokens/interfaces/delete.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IApiTokenDeleteResponse { 2 | result: boolean; 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/api-tokens/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './api-token-jwt-payload.interface'; 2 | export * from './create.interface'; 3 | export * from './delete.interface'; 4 | -------------------------------------------------------------------------------- /src/modules/api-tokens/models/create-response.model.ts: -------------------------------------------------------------------------------- 1 | import { ApiTokenEntity } from '../entities/api-token.entity'; 2 | 3 | export class CreateApiTokenResponseModel { 4 | public readonly token: string; 5 | public readonly uuid: string; 6 | constructor(data: ApiTokenEntity) { 7 | this.token = data.token; 8 | this.uuid = data.uuid; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/modules/api-tokens/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-response.model'; 2 | export * from './find.model'; 3 | -------------------------------------------------------------------------------- /src/modules/api-tokens/queries/get-token-by-uuid/get-token-by-uuid.query.ts: -------------------------------------------------------------------------------- 1 | export class GetTokenByUuidQuery { 2 | constructor(public readonly uuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/api-tokens/queries/get-token-by-uuid/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-token-by-uuid.handler'; 2 | export * from './get-token-by-uuid.query'; 3 | -------------------------------------------------------------------------------- /src/modules/api-tokens/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetTokenByUuidHandler } from './get-token-by-uuid'; 2 | 3 | export const QUERIES = [GetTokenByUuidHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/auth/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { SignApiTokenHandler } from './sign-api-token/sign-api-token.handler'; 2 | 3 | export const COMMANDS = [SignApiTokenHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/auth/commands/sign-api-token/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/modules/auth/commands/sign-api-token/index.ts -------------------------------------------------------------------------------- /src/modules/auth/commands/sign-api-token/sign-api-token.command.ts: -------------------------------------------------------------------------------- 1 | export class SignApiTokenCommand { 2 | constructor(public readonly uuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/auth/dtos/get-status.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetStatusCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetStatusResponseDto extends createZodDto(GetStatusCommand.ResponseSchema) {} 6 | -------------------------------------------------------------------------------- /src/modules/auth/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-status.dto'; 2 | export * from './login.dto'; 3 | export * from './oauth2'; 4 | export * from './register.dto'; 5 | -------------------------------------------------------------------------------- /src/modules/auth/dtos/login.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { LoginCommand } from '@libs/contracts/commands'; 4 | 5 | export class LoginRequestDto extends createZodDto(LoginCommand.RequestSchema) {} 6 | export class LoginResponseDto extends createZodDto(LoginCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/auth/dtos/oauth2/index.ts: -------------------------------------------------------------------------------- 1 | export * from './telegram-callback.dto'; 2 | -------------------------------------------------------------------------------- /src/modules/auth/dtos/oauth2/telegram-callback.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { TelegramCallbackCommand } from '@libs/contracts/commands'; 4 | 5 | export class TelegramCallbackRequestDto extends createZodDto( 6 | TelegramCallbackCommand.RequestSchema, 7 | ) {} 8 | export class TelegramCallbackResponseDto extends createZodDto( 9 | TelegramCallbackCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/auth/dtos/register.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { RegisterCommand } from '@libs/contracts/commands'; 4 | 5 | export class RegisterRequestDto extends createZodDto(RegisterCommand.RequestSchema) {} 6 | export class RegisterResponseDto extends createZodDto(RegisterCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/auth/interfaces/auth.interfaces.ts: -------------------------------------------------------------------------------- 1 | import { TRolesKeys } from '@libs/contracts/constants'; 2 | 3 | export interface IJWTAuthPayload { 4 | role: TRolesKeys; 5 | username: null | string; 6 | uuid: null | string; 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/auth/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './auth.interfaces'; 2 | export * from './login.interface'; 3 | export * from './register.interface'; 4 | -------------------------------------------------------------------------------- /src/modules/auth/interfaces/login.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ILogin { 2 | password: string; 3 | username: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/modules/auth/interfaces/register.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IRegister { 2 | password: string; 3 | username: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/modules/auth/model/auth-response.model.ts: -------------------------------------------------------------------------------- 1 | export class AuthResponseModel { 2 | public readonly accessToken: string; 3 | 4 | constructor(data: AuthResponseModel) { 5 | this.accessToken = data.accessToken; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/auth/model/index.ts: -------------------------------------------------------------------------------- 1 | export * from './auth-response.model'; 2 | export * from './get-status.response.model'; 3 | export * from './register.response.model'; 4 | -------------------------------------------------------------------------------- /src/modules/auth/model/register.response.model.ts: -------------------------------------------------------------------------------- 1 | export class RegisterResponseModel { 2 | public readonly accessToken: string; 3 | 4 | constructor(data: { accessToken: string }) { 5 | this.accessToken = data.accessToken; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/auth/strategies/index.ts: -------------------------------------------------------------------------------- 1 | export * from './jwt.strategy'; 2 | -------------------------------------------------------------------------------- /src/modules/hosts/controllers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './hosts-bulk-actions.controller'; 2 | export * from './hosts.controller'; 3 | -------------------------------------------------------------------------------- /src/modules/hosts/dtos/create-host.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { CreateHostCommand } from '@libs/contracts/commands'; 4 | 5 | export class CreateHostRequestDto extends createZodDto(CreateHostCommand.RequestSchema) {} 6 | export class CreateHostResponseDto extends createZodDto(CreateHostCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/hosts/dtos/delete-host.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { DeleteHostCommand } from '@libs/contracts/commands'; 4 | 5 | export class DeleteHostRequestDto extends createZodDto(DeleteHostCommand.RequestSchema) {} 6 | export class DeleteHostResponseDto extends createZodDto(DeleteHostCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/hosts/dtos/get-all-hosts.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetAllHostsCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetAllHostsResponseDto extends createZodDto(GetAllHostsCommand.ResponseSchema) {} 6 | -------------------------------------------------------------------------------- /src/modules/hosts/dtos/get-one.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetOneHostCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetOneHostRequestDto extends createZodDto(GetOneHostCommand.RequestSchema) {} 6 | export class GetOneHostResponseDto extends createZodDto(GetOneHostCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/hosts/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-operations.dto'; 2 | export * from './create-host.dto'; 3 | export * from './delete-host.dto'; 4 | export * from './get-all-hosts.dto'; 5 | export * from './get-one.dto'; 6 | export * from './reorder-hosts.dto'; 7 | export * from './update-host.dto'; 8 | -------------------------------------------------------------------------------- /src/modules/hosts/dtos/reorder-hosts.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { ReorderHostCommand } from '@libs/contracts/commands'; 4 | 5 | export class ReorderHostRequestDto extends createZodDto(ReorderHostCommand.RequestSchema) {} 6 | export class ReorderHostResponseDto extends createZodDto(ReorderHostCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/hosts/dtos/update-host.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { UpdateHostCommand } from '@libs/contracts/commands'; 4 | 5 | export class UpdateHostRequestDto extends createZodDto(UpdateHostCommand.RequestSchema) {} 6 | export class UpdateHostResponseDto extends createZodDto(UpdateHostCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/hosts/entities/host-with-inbound-tag.entity.ts: -------------------------------------------------------------------------------- 1 | import { InboundsEntity } from '../../inbounds/entities/inbounds.entity'; 2 | import { HostsEntity } from './hosts.entity'; 3 | 4 | export class HostWithInboundTagEntity extends HostsEntity { 5 | public inboundTag: InboundsEntity; 6 | 7 | constructor(data: HostWithInboundTagEntity) { 8 | super(data); 9 | this.inboundTag = data.inboundTag; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/hosts/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/hosts.entity'; 2 | export * from './controllers/hosts.controller'; 3 | export * from './hosts.module'; 4 | export * from './hosts.service'; 5 | export * from './repositories/hosts.repository'; 6 | -------------------------------------------------------------------------------- /src/modules/hosts/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reorder-host.interface'; 2 | -------------------------------------------------------------------------------- /src/modules/hosts/interfaces/reorder-host.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IReorderHost { 2 | uuid: string; 3 | viewPosition: number; 4 | } 5 | -------------------------------------------------------------------------------- /src/modules/hosts/models/delete-host.response.model.ts: -------------------------------------------------------------------------------- 1 | export class DeleteHostResponseModel { 2 | public isDeleted: boolean; 3 | 4 | constructor(data: DeleteHostResponseModel) { 5 | this.isDeleted = data.isDeleted; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/hosts/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-host.response.model'; 2 | export * from './delete-host.response.model'; 3 | export * from './get-all-hosts.response.model'; 4 | export * from './get-one-host.response.model'; 5 | export * from './update-host.response.model'; 6 | -------------------------------------------------------------------------------- /src/modules/hosts/queries/get-hosts-for-user/get-hosts-for-user.query.ts: -------------------------------------------------------------------------------- 1 | export class GetHostsForUserQuery { 2 | constructor(public readonly userUuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/hosts/queries/get-hosts-for-user/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-hosts-for-user.handler'; 2 | export * from './get-hosts-for-user.query'; 3 | -------------------------------------------------------------------------------- /src/modules/hosts/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetHostsForUserHandler } from './get-hosts-for-user'; 2 | 3 | export const QUERIES = [GetHostsForUserHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/commands/create-hwid-user-device/create-hwid-user-device.command.ts: -------------------------------------------------------------------------------- 1 | import { HwidUserDeviceEntity } from '../../entities/hwid-user-device.entity'; 2 | 3 | export class CreateHwidUserDeviceCommand { 4 | constructor(public readonly hwidUserDevice: HwidUserDeviceEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/commands/create-hwid-user-device/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-hwid-user-device.command'; 2 | export * from './create-hwid-user-device.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateHwidUserDeviceHandler } from './create-hwid-user-device'; 2 | import { UpsertHwidUserDeviceHandler } from './upsert-hwid-user-device'; 3 | 4 | export const COMMANDS = [CreateHwidUserDeviceHandler, UpsertHwidUserDeviceHandler]; 5 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/commands/upsert-hwid-user-device/index.ts: -------------------------------------------------------------------------------- 1 | export * from './upsert-hwid-user-device.command'; 2 | export * from './upsert-hwid-user-device.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/commands/upsert-hwid-user-device/upsert-hwid-user-device.command.ts: -------------------------------------------------------------------------------- 1 | import { HwidUserDeviceEntity } from '../../entities/hwid-user-device.entity'; 2 | 3 | export class UpsertHwidUserDeviceCommand { 4 | constructor(public readonly hwidUserDevice: HwidUserDeviceEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/dtos/create-user-hwid-device.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { CreateUserHwidDeviceCommand } from '@contract/commands'; 4 | 5 | export class CreateUserHwidDeviceRequestDto extends createZodDto( 6 | CreateUserHwidDeviceCommand.RequestSchema, 7 | ) {} 8 | 9 | export class CreateUserHwidDeviceResponseDto extends createZodDto( 10 | CreateUserHwidDeviceCommand.ResponseSchema, 11 | ) {} 12 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/dtos/delete-user-hwid-device.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { DeleteUserHwidDeviceCommand } from '@contract/commands'; 4 | 5 | export class DeleteUserHwidDeviceRequestDto extends createZodDto( 6 | DeleteUserHwidDeviceCommand.RequestSchema, 7 | ) {} 8 | 9 | export class DeleteUserHwidDeviceResponseDto extends createZodDto( 10 | DeleteUserHwidDeviceCommand.ResponseSchema, 11 | ) {} 12 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/dtos/get-user-hwid-devices.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserHwidDevicesCommand } from '@contract/commands'; 4 | 5 | export class GetUserHwidDevicesRequestDto extends createZodDto( 6 | GetUserHwidDevicesCommand.RequestSchema, 7 | ) {} 8 | 9 | export class GetUserHwidDevicesResponseDto extends createZodDto( 10 | GetUserHwidDevicesCommand.ResponseSchema, 11 | ) {} 12 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-user-hwid-device.dto'; 2 | export * from './delete-user-hwid-device.dto'; 3 | export * from './get-user-hwid-devices.dto'; 4 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/hwid-user-device.entity'; 2 | export * from './hwid-user-devices.module'; 3 | export * from './repositories/hwid-user-devices.repository'; 4 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './base-user-hwid-devices.response.model'; 2 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/queries/check-hwid-exists/check-hwid-exists.query.ts: -------------------------------------------------------------------------------- 1 | export class CheckHwidExistsQuery { 2 | constructor( 3 | public readonly hwid: string, 4 | public readonly userUuid: string, 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/queries/check-hwid-exists/index.ts: -------------------------------------------------------------------------------- 1 | export * from './check-hwid-exists.handler'; 2 | export * from './check-hwid-exists.query'; 3 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/queries/count-users-devices/count-users-devices.query.ts: -------------------------------------------------------------------------------- 1 | export class CountUsersDevicesQuery { 2 | constructor(public readonly userUuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/queries/count-users-devices/index.ts: -------------------------------------------------------------------------------- 1 | export * from './count-users-devices.handler'; 2 | export * from './count-users-devices.query'; 3 | -------------------------------------------------------------------------------- /src/modules/hwid-user-devices/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { CountUsersDevicesHandler } from './count-users-devices/count-users-devices.handler'; 2 | import { CheckHwidExistsHandler } from './check-hwid-exists/check-hwid-exists.handler'; 3 | 4 | export const QUERIES = [CountUsersDevicesHandler, CheckHwidExistsHandler]; 5 | -------------------------------------------------------------------------------- /src/modules/inbounds/builders/add-inbound-to-nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './add-inbound-to-nodes.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/inbounds/builders/add-inbound-to-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './add-inbound-to-users.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/inbounds/builders/add-inbounds-to-users-by-uuids/index.ts: -------------------------------------------------------------------------------- 1 | export * from './add-inbounds-to-users-by-uuids.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/inbounds/builders/get-inbound-stats-by-uuid/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-inbound-stats-by-uuid.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/inbounds/builders/remove-inbound-from-nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './remove-inbound-from-nodes.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/inbounds/builders/remove-inbound-from-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './remove-inbound-from-users.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/inbounds/builders/remove-inbounds-from-users-by-uuids/index.ts: -------------------------------------------------------------------------------- 1 | export * from './remove-inbounds-from-users-by-uuids.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/add-inbounds-to-users-by-uuids/add-inbounds-to-users-by-uuids.command.ts: -------------------------------------------------------------------------------- 1 | export class AddInboundsToUsersByUuidsCommand { 2 | constructor( 3 | public readonly userUuids: string[], 4 | public readonly inboundUuids: string[], 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/add-inbounds-to-users-by-uuids/index.ts: -------------------------------------------------------------------------------- 1 | export * from './add-inbounds-to-users-by-uuids.command'; 2 | export * from './add-inbounds-to-users-by-uuids.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/create-many-inbounds/create-many-inbounds.command.ts: -------------------------------------------------------------------------------- 1 | import { InboundsWithTagsAndType } from '../../interfaces/inbounds-with-tags-and-type.interface'; 2 | 3 | export class CreateManyInboundsCommand { 4 | constructor(public readonly inbounds: InboundsWithTagsAndType[]) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/create-many-inbounds/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-many-inbounds.command'; 2 | export * from './create-many-inbounds.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/create-many-user-active-inbounds/create-many-user-active-inbounds.command.ts: -------------------------------------------------------------------------------- 1 | export class CreateManyUserActiveInboundsCommand { 2 | constructor( 3 | public readonly userUuid: string, 4 | public readonly inboundUuids: string[], 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/create-many-user-active-inbounds/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-many-user-active-inbounds.command'; 2 | export * from './create-many-user-active-inbounds.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/delete-many-active-inbounds-by-user-uuid/delete-many-active-inbounds-by-user-uuid.command.ts: -------------------------------------------------------------------------------- 1 | export class DeleteManyActiveInboundsByUserUuidCommand { 2 | constructor(public readonly userUuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/delete-many-active-inbounds-by-user-uuid/index.ts: -------------------------------------------------------------------------------- 1 | export * from './delete-many-active-inbounds-by-user-uuid.command'; 2 | export * from './delete-many-active-inbounds-by-user-uuid.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/delete-many-inbounds/delete-many-inbounds.command.ts: -------------------------------------------------------------------------------- 1 | export class DeleteManyInboundsCommand { 2 | constructor(public readonly tags: string[]) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/delete-many-inbounds/index.ts: -------------------------------------------------------------------------------- 1 | export * from './delete-many-inbounds.command'; 2 | export * from './delete-many-inbounds.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/remove-inbounds-from-users-by-uuids/index.ts: -------------------------------------------------------------------------------- 1 | export * from './remove-inbounds-from-users-by-uuids.command'; 2 | export * from './remove-inbounds-from-users-by-uuids.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/remove-inbounds-from-users-by-uuids/remove-inbounds-from-users-by-uuids.command.ts: -------------------------------------------------------------------------------- 1 | export class RemoveInboundsFromUsersByUuidsCommand { 2 | constructor(public readonly userUuids: string[]) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/reset-node-inbound-exclusions-by-node-uuid/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reset-node-inbound-exclusions-by-node-uuid.command'; 2 | export * from './reset-node-inbound-exclusions-by-node-uuid.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/reset-node-inbound-exclusions-by-node-uuid/reset-node-inbound-exclusions-by-node-uuid.command.ts: -------------------------------------------------------------------------------- 1 | export class ResetNodeInboundExclusionsByNodeUuidCommand { 2 | constructor( 3 | public readonly nodeUuid: string, 4 | public readonly excludedInbounds: string[], 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/update-inbound/index.ts: -------------------------------------------------------------------------------- 1 | export * from './update-inbound.command'; 2 | export * from './update-inbound.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/commands/update-inbound/update-inbound.command.ts: -------------------------------------------------------------------------------- 1 | import { InboundsEntity } from '../../entities/inbounds.entity'; 2 | 3 | export class UpdateInboundCommand { 4 | constructor(public readonly inbound: InboundsEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/inbounds/controllers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './inbounds-bulk-actions.controller'; 2 | export * from './inbounds.controller'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/converters/index.ts: -------------------------------------------------------------------------------- 1 | export * from './active-user-inbounds.converter'; 2 | export * from './inbounds.converter'; 3 | export * from './node-inbound-exclusions.converter'; 4 | -------------------------------------------------------------------------------- /src/modules/inbounds/dtos/get-full-inbounds.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetFullInboundsCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetFullInboundsResponseDto extends createZodDto( 6 | GetFullInboundsCommand.ResponseSchema, 7 | ) {} 8 | -------------------------------------------------------------------------------- /src/modules/inbounds/dtos/get-inbounds.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetInboundsCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetInboundsResponseDto extends createZodDto(GetInboundsCommand.ResponseSchema) {} 6 | -------------------------------------------------------------------------------- /src/modules/inbounds/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-operations.dto'; 2 | export * from './get-full-inbounds.dto'; 3 | export * from './get-inbounds.dto'; 4 | -------------------------------------------------------------------------------- /src/modules/inbounds/entities/active-user-inbound.entity.ts: -------------------------------------------------------------------------------- 1 | import { ActiveUserInbounds } from '@prisma/client'; 2 | 3 | export class ActiveUserInboundEntity implements ActiveUserInbounds { 4 | userUuid: string; 5 | inboundUuid: string; 6 | 7 | constructor(activeUserInbound: Partial) { 8 | Object.assign(this, activeUserInbound); 9 | return this; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/inbounds/entities/base-inbound.entity.ts: -------------------------------------------------------------------------------- 1 | import { InboundsEntity } from './inbounds.entity'; 2 | 3 | export class BaseInboundEntity extends InboundsEntity { 4 | public port: number; 5 | 6 | constructor(entity: InboundsEntity, port: number) { 7 | super(entity); 8 | this.port = port; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/modules/inbounds/entities/inbounds.entity.ts: -------------------------------------------------------------------------------- 1 | import { Inbounds } from '@prisma/client'; 2 | 3 | export class InboundsEntity implements Inbounds { 4 | public uuid: string; 5 | public tag: string; 6 | public type: string; 7 | public network: string | null; 8 | public security: string | null; 9 | 10 | constructor(inbound: Partial) { 11 | Object.assign(this, inbound); 12 | return this; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/modules/inbounds/entities/index.ts: -------------------------------------------------------------------------------- 1 | export * from './active-user-inbound.entity'; 2 | export * from './base-inbound.entity'; 3 | export * from './inbound-with-stats.entity'; 4 | export * from './inbounds.entity'; 5 | export * from './node-inbound-exclusion.entity'; 6 | -------------------------------------------------------------------------------- /src/modules/inbounds/entities/node-inbound-exclusion.entity.ts: -------------------------------------------------------------------------------- 1 | import { NodeInboundExclusions } from '@prisma/client'; 2 | 3 | export class NodeInboundExclusionEntity implements NodeInboundExclusions { 4 | nodeUuid: string; 5 | inboundUuid: string; 6 | 7 | constructor(nodeInboundExclusion: Partial) { 8 | Object.assign(this, nodeInboundExclusion); 9 | return this; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/inbounds/interfaces/inbounds-with-tags-and-type.interface.ts: -------------------------------------------------------------------------------- 1 | export interface InboundsWithTagsAndType { 2 | tag: string; 3 | type: string; 4 | network: string | null; 5 | security: string | null; 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/inbounds/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './inbounds-with-tags-and-type.interface'; 2 | -------------------------------------------------------------------------------- /src/modules/inbounds/models/bulk-operation.response.model.ts: -------------------------------------------------------------------------------- 1 | export class BulkOperationResponseModel { 2 | isSuccess: boolean; 3 | 4 | constructor(isSuccess: boolean) { 5 | this.isSuccess = isSuccess; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/inbounds/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-operation.response.model'; 2 | export * from './get-base-inbounds.response.model'; 3 | export * from './get-full-inbounds.response.model'; 4 | export * from './get-inbounds.response.model'; 5 | -------------------------------------------------------------------------------- /src/modules/inbounds/queries/get-all-inbounds/get-all-inbounds.query.ts: -------------------------------------------------------------------------------- 1 | export class GetAllInboundsQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/inbounds/queries/get-all-inbounds/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-all-inbounds.handler'; 2 | export * from './get-all-inbounds.query'; 3 | -------------------------------------------------------------------------------- /src/modules/inbounds/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetAllInboundsHandler } from './get-all-inbounds'; 2 | 3 | export const QUERIES = [GetAllInboundsHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/keygen/commands/get-node-jwt/get-node-jwt.command.ts: -------------------------------------------------------------------------------- 1 | export class GetNodeJwtCommand { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/keygen/commands/get-node-jwt/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-node-jwt.command'; 2 | export * from './get-node-jwt.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/keygen/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { GetNodeJwtHandler } from './get-node-jwt'; 2 | 3 | export const COMMANDS = [GetNodeJwtHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/keygen/dtos/get-pubkey-dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetPubKeyCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetPubKeyResponseDto extends createZodDto(GetPubKeyCommand.ResponseSchema) {} 6 | -------------------------------------------------------------------------------- /src/modules/keygen/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-pubkey-dto'; 2 | -------------------------------------------------------------------------------- /src/modules/keygen/model/index.ts: -------------------------------------------------------------------------------- 1 | export * from './keygen-response.model'; 2 | -------------------------------------------------------------------------------- /src/modules/keygen/model/keygen-response.model.ts: -------------------------------------------------------------------------------- 1 | export class KeygenResponseModel { 2 | public pubKey: string; 3 | 4 | constructor(payload: string) { 5 | this.pubKey = payload; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/nodes-traffic-usage-history/commands/create-node-traffic-usage-history/create-node-traffic-usage-history.command.ts: -------------------------------------------------------------------------------- 1 | import { NodesTrafficUsageHistoryEntity } from '../../entities/nodes-traffic-usage-history.entity'; 2 | 3 | export class CreateNodeTrafficUsageHistoryCommand { 4 | constructor(public readonly nodeTrafficUsageHistory: NodesTrafficUsageHistoryEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes-traffic-usage-history/commands/create-node-traffic-usage-history/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-node-traffic-usage-history.command'; 2 | export * from './create-node-traffic-usage-history.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-traffic-usage-history/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateNodeTrafficUsageHistoryHandler } from './create-node-traffic-usage-history'; 2 | 3 | export const COMMANDS = [CreateNodeTrafficUsageHistoryHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/nodes-traffic-usage-history/entities/nodes-traffic-usage-history.entity.ts: -------------------------------------------------------------------------------- 1 | import { NodesTrafficUsageHistory } from '@prisma/client'; 2 | 3 | export class NodesTrafficUsageHistoryEntity implements NodesTrafficUsageHistory { 4 | id: bigint; 5 | nodeUuid: string; 6 | trafficBytes: bigint; 7 | resetAt: Date; 8 | 9 | constructor(history: Partial) { 10 | Object.assign(this, history); 11 | return this; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/modules/nodes-traffic-usage-history/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/nodes-traffic-usage-history.entity'; 2 | export * from './nodes-traffic-usage-history.module'; 3 | export * from './repositories/nodes-traffic-usage-history.repository'; 4 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/builders/get-7days-stats/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-7days-stats.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-7days-stats'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { UpsertHistoryEntryHandler } from './upsert-history-entry'; 2 | 3 | export const COMMANDS = [UpsertHistoryEntryHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/commands/upsert-history-entry/index.ts: -------------------------------------------------------------------------------- 1 | export * from './upsert-history-entry.command'; 2 | export * from './upsert-history-entry.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/commands/upsert-history-entry/upsert-history-entry.command.ts: -------------------------------------------------------------------------------- 1 | import { NodesUsageHistoryEntity } from '../../entities/nodes-usage-history.entity'; 2 | 3 | export class UpsertHistoryEntryCommand { 4 | constructor(public readonly nodeUsageHistory: NodesUsageHistoryEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './nodes-usage-by-range.dto'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/dtos/nodes-usage-by-range.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetNodesUsageByRangeCommand } from '@contract/commands'; 4 | 5 | export class GetNodesUsageByRangeRequestQueryDto extends createZodDto( 6 | GetNodesUsageByRangeCommand.RequestQuerySchema, 7 | ) {} 8 | export class GetNodesUsageByRangeResponseDto extends createZodDto( 9 | GetNodesUsageByRangeCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/entities/index.ts: -------------------------------------------------------------------------------- 1 | export * from './nodes-usage-history.entity'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/entities/nodes-usage-history.entity.ts: -------------------------------------------------------------------------------- 1 | import { NodesUsageHistory } from '@prisma/client'; 2 | 3 | export class NodesUsageHistoryEntity implements NodesUsageHistory { 4 | public nodeUuid: string; 5 | public downloadBytes: bigint; 6 | public uploadBytes: bigint; 7 | public totalBytes: bigint; 8 | public createdAt: Date; 9 | 10 | constructor(history: Partial) { 11 | Object.assign(this, history); 12 | return this; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/nodes-usage-history.entity'; 2 | export * from './nodes-usage-history.module'; 3 | export * from './repositories/nodes-usage-history.repository'; 4 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/interfaces/get-7days-stats.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IGet7DaysStats { 2 | date: string; 3 | nodeName: string; 4 | totalBytes: bigint; 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/interfaces/get-nodes-usage-by-range.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IGetNodesUsageByRange { 2 | nodeName: string; 3 | nodeUuid: string; 4 | total: bigint; 5 | totalDownload: bigint; 6 | totalUpload: bigint; 7 | date: string; 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-7days-stats.interface'; 2 | export * from './get-nodes-usage-by-range.interface'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-nodes-usage-by-range.response.model'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/queries/get-7days-stats/get-7days-stats.query.ts: -------------------------------------------------------------------------------- 1 | export class Get7DaysStatsQuery {} 2 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/queries/get-7days-stats/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-7days-stats.handler'; 2 | export * from './get-7days-stats.query'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/queries/get-sum-by-dt-range/get-sum-by-dt-range.query.ts: -------------------------------------------------------------------------------- 1 | export class GetSumByDtRangeQuery { 2 | constructor( 3 | public readonly start: Date, 4 | public readonly end: Date, 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/queries/get-sum-by-dt-range/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-sum-by-dt-range.handler'; 2 | export * from './get-sum-by-dt-range.query'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-usage-history/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetSumByDtRangeHandler } from './get-sum-by-dt-range/get-sum-by-dt-range.handler'; 2 | import { Get7DaysStatsHandler } from './get-7days-stats/get-7days-stats.handler'; 3 | 4 | export const QUERIES = [GetSumByDtRangeHandler, Get7DaysStatsHandler]; 5 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/builders/bulk-upsert-history-entry/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-upsert-history-entry.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/builders/get-node-users-usage-by-range/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-node-users-usage-by-range.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/builders/get-nodes-realtime-usage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-nodes-realtime-usage.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/builders/get-user-usage-by-range/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-user-usage-by-range.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/commands/bulk-upsert-user-history-entry/bulk-upsert-user-history-entry.command.ts: -------------------------------------------------------------------------------- 1 | import { NodesUserUsageHistoryEntity } from '../../entities/nodes-user-usage-history.entity'; 2 | 3 | export class BulkUpsertUserHistoryEntryCommand { 4 | constructor(public readonly userUsageHistoryList: NodesUserUsageHistoryEntity[]) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/commands/bulk-upsert-user-history-entry/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-upsert-user-history-entry.command'; 2 | export * from './bulk-upsert-user-history-entry.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { BulkUpsertUserHistoryEntryHandler } from './bulk-upsert-user-history-entry'; 2 | import { UpsertUserHistoryEntryHandler } from './upsert-user-history-entry'; 3 | 4 | export const COMMANDS = [UpsertUserHistoryEntryHandler, BulkUpsertUserHistoryEntryHandler]; 5 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/commands/upsert-user-history-entry/index.ts: -------------------------------------------------------------------------------- 1 | export * from './upsert-user-history-entry.command'; 2 | export * from './upsert-user-history-entry.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/commands/upsert-user-history-entry/upsert-user-history-entry.command.ts: -------------------------------------------------------------------------------- 1 | import { NodesUserUsageHistoryEntity } from '../../entities/nodes-user-usage-history.entity'; 2 | 3 | export class UpsertUserHistoryEntryCommand { 4 | constructor(public readonly userUsageHistory: NodesUserUsageHistoryEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './node-user-usage-by-range.dto'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/dtos/nodes-realtime-usage.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetNodesRealtimeUsageCommand } from '@contract/commands'; 4 | 5 | export class GetNodesRealtimeUsageResponseDto extends createZodDto( 6 | GetNodesRealtimeUsageCommand.ResponseSchema, 7 | ) {} 8 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/entities/index.ts: -------------------------------------------------------------------------------- 1 | export * from './nodes-user-usage-history.entity'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/entities/nodes-user-usage-history.entity.ts: -------------------------------------------------------------------------------- 1 | import { NodesUserUsageHistory } from '@prisma/client'; 2 | 3 | export class NodesUserUsageHistoryEntity implements NodesUserUsageHistory { 4 | nodeUuid: string; 5 | userUuid: string; 6 | downloadBytes: bigint; 7 | uploadBytes: bigint; 8 | totalBytes: bigint; 9 | createdAt: Date; 10 | updatedAt: Date; 11 | 12 | constructor(history: Partial) { 13 | Object.assign(this, history); 14 | return this; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/nodes-user-usage-history.entity'; 2 | export * from './nodes-user-usage-history.module'; 3 | export * from './repositories/nodes-user-usage-history.repository'; 4 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/interfaces/get-node-users-usage-by-range.ts: -------------------------------------------------------------------------------- 1 | export interface IGetNodeUserUsageByRange { 2 | userUuid: string; 3 | nodeUuid: string; 4 | username: string; 5 | total: bigint; 6 | date: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/interfaces/get-nodes-realtime-usage.ts: -------------------------------------------------------------------------------- 1 | export interface IGetNodesRealtimeUsage { 2 | nodeUuid: string; 3 | nodeName: string; 4 | countryCode: string; 5 | downloadBytes: bigint; 6 | uploadBytes: bigint; 7 | totalBytes: bigint; 8 | downloadSpeedBps: bigint; 9 | uploadSpeedBps: bigint; 10 | totalSpeedBps: bigint; 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-node-users-usage-by-range'; 2 | export * from './get-nodes-realtime-usage'; 3 | export * from './last-connected-node'; 4 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/interfaces/last-connected-node.ts: -------------------------------------------------------------------------------- 1 | export interface ILastConnectedNode { 2 | nodeName: string; 3 | connectedAt: Date; 4 | } 5 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-node-user-usage-by-range.response.model'; 2 | export * from './get-nodes-realtime-usage.response.model'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/queries/get-user-last-connected-node/get-user-last-connected-node.query.ts: -------------------------------------------------------------------------------- 1 | export class GetUserLastConnectedNodeQuery { 2 | constructor(public readonly userUuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/queries/get-user-last-connected-node/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-user-last-connected-node.handler'; 2 | export * from './get-user-last-connected-node.query'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/queries/get-user-usage-by-range/get-user-usage-by-range.query.ts: -------------------------------------------------------------------------------- 1 | export class GetUserUsageByRangeQuery { 2 | constructor( 3 | public readonly userUuid: string, 4 | public readonly start: Date, 5 | public readonly end: Date, 6 | ) {} 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/queries/get-user-usage-by-range/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-user-usage-by-range.handler'; 2 | export * from './get-user-usage-by-range.query'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes-user-usage-history/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetUserLastConnectedNodeHandler } from './get-user-last-connected-node'; 2 | import { GetUserUsageByRangeHandler } from './get-user-usage-by-range'; 3 | 4 | export const QUERIES = [GetUserLastConnectedNodeHandler, GetUserUsageByRangeHandler]; 5 | -------------------------------------------------------------------------------- /src/modules/nodes/commands/increment-used-traffic/increment-used-traffic.command.ts: -------------------------------------------------------------------------------- 1 | export class IncrementUsedTrafficCommand { 2 | constructor( 3 | public readonly nodeUuid: string, 4 | public readonly bytes: bigint, 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/nodes/commands/increment-used-traffic/index.ts: -------------------------------------------------------------------------------- 1 | export * from './increment-used-traffic.command'; 2 | export * from './increment-used-traffic.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { IncrementUsedTrafficHandler } from './increment-used-traffic'; 2 | import { UpdateNodeHandler } from './update-node'; 3 | 4 | export const COMMANDS = [UpdateNodeHandler, IncrementUsedTrafficHandler]; 5 | -------------------------------------------------------------------------------- /src/modules/nodes/commands/update-node/index.ts: -------------------------------------------------------------------------------- 1 | export * from './update-node.command'; 2 | export * from './update-node.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/commands/update-node/update-node.command.ts: -------------------------------------------------------------------------------- 1 | import { NodesEntity } from '../../entities/nodes.entity'; 2 | 3 | export class UpdateNodeCommand { 4 | constructor(public readonly node: Partial) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/create-node.request.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { CreateNodeCommand } from '@contract/commands'; 4 | 5 | export class CreateNodeRequestDto extends createZodDto(CreateNodeCommand.RequestSchema) {} 6 | export class CreateNodeResponseDto extends createZodDto(CreateNodeCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/delete-node.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { DeleteNodeCommand } from '@contract/commands'; 4 | 5 | export class DeleteNodeRequestParamDto extends createZodDto(DeleteNodeCommand.RequestSchema) {} 6 | export class DeleteNodeResponseDto extends createZodDto(DeleteNodeCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/disable-node.request.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { DisableNodeCommand } from '@contract/commands'; 4 | 5 | export class DisableNodeRequestParamDto extends createZodDto(DisableNodeCommand.RequestSchema) {} 6 | export class DisableNodeResponseDto extends createZodDto(DisableNodeCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/enable-node.request.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { EnableNodeCommand } from '@contract/commands'; 4 | 5 | export class EnableNodeRequestParamDto extends createZodDto(EnableNodeCommand.RequestSchema) {} 6 | export class EnableNodeResponseDto extends createZodDto(EnableNodeCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/get-all-nodes.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetAllNodesCommand } from '@contract/commands'; 4 | 5 | export class GetAllNodesResponseDto extends createZodDto(GetAllNodesCommand.ResponseSchema) {} 6 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/get-one-node.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetOneNodeCommand } from '@contract/commands'; 4 | 5 | export class GetOneNodeRequestParamDto extends createZodDto(GetOneNodeCommand.RequestSchema) {} 6 | export class GetOneNodeResponseDto extends createZodDto(GetOneNodeCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-node.request.dto'; 2 | export * from './delete-node.dto'; 3 | export * from './disable-node.request.dto'; 4 | export * from './enable-node.request.dto'; 5 | export * from './get-all-nodes.dto'; 6 | export * from './get-one-node.dto'; 7 | export * from './reorder.dto'; 8 | export * from './restart-all.dto'; 9 | export * from './restart-node.request.dto'; 10 | export * from './update-node.dto'; 11 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/reorder.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { ReorderNodeCommand } from '@contract/commands'; 4 | 5 | export class ReorderNodeRequestDto extends createZodDto(ReorderNodeCommand.RequestSchema) {} 6 | export class ReorderNodeResponseDto extends createZodDto(ReorderNodeCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/restart-all.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { RestartAllNodesCommand } from '@contract/commands'; 4 | 5 | export class RestartAllNodesResponseDto extends createZodDto( 6 | RestartAllNodesCommand.ResponseSchema, 7 | ) {} 8 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/restart-node.request.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { RestartNodeCommand } from '@contract/commands'; 4 | 5 | export class RestartNodeRequestDto extends createZodDto(RestartNodeCommand.RequestSchema) {} 6 | export class RestartNodeResponseDto extends createZodDto(RestartNodeCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/nodes/dtos/update-node.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { UpdateNodeCommand } from '@contract/commands'; 4 | 5 | export class UpdateNodeRequestDto extends createZodDto(UpdateNodeCommand.RequestSchema) {} 6 | export class UpdateNodeResponseDto extends createZodDto(UpdateNodeCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/nodes/entities/index.ts: -------------------------------------------------------------------------------- 1 | export * from './nodes.entity'; 2 | -------------------------------------------------------------------------------- /src/modules/nodes/events/add-user-to-node/add-user-to-node.event.ts: -------------------------------------------------------------------------------- 1 | import { UserWithActiveInboundsEntity } from '../../../users/entities/user-with-active-inbounds.entity'; 2 | 3 | export class AddUserToNodeEvent { 4 | constructor(public readonly user: UserWithActiveInboundsEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes/events/add-user-to-node/index.ts: -------------------------------------------------------------------------------- 1 | export * from './add-user-to-node.event'; 2 | export * from './add-user-to-node.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/events/index.ts: -------------------------------------------------------------------------------- 1 | import { RemoveUserFromNodeHandler } from './remove-user-from-node'; 2 | import { AddUserToNodeHandler } from './add-user-to-node'; 3 | 4 | export const EVENTS = [AddUserToNodeHandler, RemoveUserFromNodeHandler]; 5 | -------------------------------------------------------------------------------- /src/modules/nodes/events/remove-user-from-node/index.ts: -------------------------------------------------------------------------------- 1 | export * from './remove-user-from-node.event'; 2 | export * from './remove-user-from-node.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/events/remove-user-from-node/remove-user-from-node.event.ts: -------------------------------------------------------------------------------- 1 | import { UserWithActiveInboundsEntity } from '../../../users/entities/user-with-active-inbounds.entity'; 2 | 3 | export class RemoveUserFromNodeEvent { 4 | constructor(public readonly user: UserWithActiveInboundsEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/nodes.entity'; 2 | export * from './nodes.controller'; 3 | export * from './nodes.module'; 4 | export * from './nodes.service'; 5 | export * from './repositories/nodes.repository'; 6 | -------------------------------------------------------------------------------- /src/modules/nodes/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './node-with-excluded-inbounds.interface'; 2 | export * from './reorder-node.interface'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/interfaces/reorder-node.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IReorderNode { 2 | uuid: string; 3 | viewPosition: number; 4 | } 5 | -------------------------------------------------------------------------------- /src/modules/nodes/models/delete-node.response.model.ts: -------------------------------------------------------------------------------- 1 | export class DeleteNodeResponseModel { 2 | public isDeleted: boolean; 3 | 4 | constructor(data: DeleteNodeResponseModel) { 5 | this.isDeleted = data.isDeleted; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/nodes/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-node.response.model'; 2 | export * from './delete-node.response.model'; 3 | export * from './get-all-nodes.response.model'; 4 | export * from './get-one-node.response.model'; 5 | export * from './restart-node.response.model'; 6 | -------------------------------------------------------------------------------- /src/modules/nodes/models/restart-node.response.model.ts: -------------------------------------------------------------------------------- 1 | export class RestartNodeResponseModel { 2 | public eventSent: boolean; 3 | 4 | constructor(eventSent: boolean) { 5 | this.eventSent = eventSent; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/get-all-nodes/get-all-nodes.query.ts: -------------------------------------------------------------------------------- 1 | export class GetAllNodesQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/get-all-nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-all-nodes.handler'; 2 | export * from './get-all-nodes.query'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/get-enabled-nodes/get-enabled-nodes.query.ts: -------------------------------------------------------------------------------- 1 | export class GetEnabledNodesQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/get-enabled-nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-enabled-nodes.handler'; 2 | export * from './get-enabled-nodes.query'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/get-nodes-by-criteria/get-nodes-by-criteria.query.ts: -------------------------------------------------------------------------------- 1 | import { NodesEntity } from '../../entities'; 2 | 3 | export class GetNodesByCriteriaQuery { 4 | constructor(public readonly criteria: Partial) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/get-nodes-by-criteria/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-nodes-by-criteria.handler'; 2 | export * from './get-nodes-by-criteria.query'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/get-online-nodes/get-online-nodes.query.ts: -------------------------------------------------------------------------------- 1 | export class GetOnlineNodesQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/get-online-nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-online-nodes.handler'; 2 | export * from './get-online-nodes.query'; 3 | -------------------------------------------------------------------------------- /src/modules/nodes/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetNodesByCriteriaHandler } from './get-nodes-by-criteria'; 2 | import { GetEnabledNodesHandler } from './get-enabled-nodes'; 3 | import { GetOnlineNodesHandler } from './get-online-nodes'; 4 | import { GetAllNodesHandler } from './get-all-nodes'; 5 | 6 | export const QUERIES = [ 7 | GetEnabledNodesHandler, 8 | GetOnlineNodesHandler, 9 | GetNodesByCriteriaHandler, 10 | GetAllNodesHandler, 11 | ]; 12 | -------------------------------------------------------------------------------- /src/modules/remnawave-service/remnawave-service.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | 3 | import { RemnawaveServiceService } from './remnawave-service.service'; 4 | 5 | @Module({ 6 | imports: [], 7 | controllers: [], 8 | providers: [RemnawaveServiceService], 9 | }) 10 | export class RemnawaveServiceModule {} 11 | -------------------------------------------------------------------------------- /src/modules/subscription-settings/dtos/get-subscription-settings.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetSubscriptionSettingsCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetSubscriptionSettingsResponseDto extends createZodDto( 6 | GetSubscriptionSettingsCommand.ResponseSchema, 7 | ) {} 8 | -------------------------------------------------------------------------------- /src/modules/subscription-settings/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-subscription-settings.dto'; 2 | export * from './update-subscription-settings.dto'; 3 | -------------------------------------------------------------------------------- /src/modules/subscription-settings/dtos/update-subscription-settings.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { UpdateSubscriptionSettingsCommand } from '@libs/contracts/commands'; 4 | 5 | export class UpdateSubscriptionSettingsRequestDto extends createZodDto( 6 | UpdateSubscriptionSettingsCommand.RequestSchema, 7 | ) {} 8 | 9 | export class UpdateSubscriptionSettingsResponseDto extends createZodDto( 10 | UpdateSubscriptionSettingsCommand.ResponseSchema, 11 | ) {} 12 | -------------------------------------------------------------------------------- /src/modules/subscription-settings/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/subscription-settings.entity'; 2 | export * from './repositories/subscription-settings.repository'; 3 | export * from './subscription-settings.controller'; 4 | export * from './subscription-settings.module'; 5 | export * from './subscription-settings.service'; 6 | -------------------------------------------------------------------------------- /src/modules/subscription-settings/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-subscription-settings.response.model'; 2 | -------------------------------------------------------------------------------- /src/modules/subscription-settings/queries/get-subscription-settings/get-subscription-settings.query.ts: -------------------------------------------------------------------------------- 1 | export class GetSubscriptionSettingsQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/subscription-settings/queries/get-subscription-settings/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-subscription-settings.handler'; 2 | export * from './get-subscription-settings.query'; 3 | -------------------------------------------------------------------------------- /src/modules/subscription-settings/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetSubscriptionSettingsHandler } from './get-subscription-settings'; 2 | 3 | export const QUERIES = [GetSubscriptionSettingsHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/subscription-template/constants/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/modules/subscription-template/constants/index.ts -------------------------------------------------------------------------------- /src/modules/subscription-template/dtos/get-template.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetSubscriptionTemplateCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetTemplateResponseDto extends createZodDto( 6 | GetSubscriptionTemplateCommand.ResponseSchema, 7 | ) {} 8 | 9 | export class GetTemplateRequestDto extends createZodDto( 10 | GetSubscriptionTemplateCommand.RequestSchema, 11 | ) {} 12 | -------------------------------------------------------------------------------- /src/modules/subscription-template/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-template.dto'; 2 | export * from './update-template.dto'; 3 | -------------------------------------------------------------------------------- /src/modules/subscription-template/dtos/update-template.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { UpdateSubscriptionTemplateCommand } from '@libs/contracts/commands'; 4 | 5 | export class UpdateTemplateRequestDto extends createZodDto( 6 | UpdateSubscriptionTemplateCommand.RequestSchema, 7 | ) {} 8 | 9 | export class UpdateTemplateResponseDto extends createZodDto( 10 | UpdateSubscriptionTemplateCommand.ResponseSchema, 11 | ) {} 12 | -------------------------------------------------------------------------------- /src/modules/subscription-template/generators/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './formatted-hosts.interface'; 2 | -------------------------------------------------------------------------------- /src/modules/subscription-template/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/subscription-template.entity'; 2 | export * from './repositories/subscription-template.repository'; 3 | export * from './subscription-template.controller'; 4 | export * from './subscription-template.module'; 5 | export * from './subscription-template.service'; 6 | -------------------------------------------------------------------------------- /src/modules/subscription-template/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './generate-subscription-by-client-type.interface'; 2 | export * from './generate-subscription.interface'; 3 | -------------------------------------------------------------------------------- /src/modules/subscription-template/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-template.response.model'; 2 | export * from './update-subscription.response.model'; 3 | -------------------------------------------------------------------------------- /src/modules/subscription/controllers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './subscription.controller'; 2 | export * from './subscriptions.controller'; 3 | -------------------------------------------------------------------------------- /src/modules/subscription/dto/get-all-subscriptions.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetAllSubscriptionsCommand } from '@libs/contracts/commands/subscriptions'; 4 | 5 | export class GetAllSubscriptionsQueryDto extends createZodDto( 6 | GetAllSubscriptionsCommand.RequestQuerySchema, 7 | ) {} 8 | 9 | export class GetAllSubscriptionsResponseDto extends createZodDto( 10 | GetAllSubscriptionsCommand.ResponseSchema, 11 | ) {} 12 | -------------------------------------------------------------------------------- /src/modules/subscription/dto/get-outline-subscription.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetOutlineSubscriptionByShortUuidCommand } from '@libs/contracts/commands/subscription'; 4 | 5 | export class GetOutlineSubscriptionRequestDto extends createZodDto( 6 | GetOutlineSubscriptionByShortUuidCommand.RequestSchema, 7 | ) {} 8 | -------------------------------------------------------------------------------- /src/modules/subscription/dto/get-subscription-by-client-type.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetSubscriptionByShortUuidByClientTypeCommand } from '@libs/contracts/commands/subscription'; 4 | 5 | export class GetSubscriptionByShortUuidByClientTypeRequestDto extends createZodDto( 6 | GetSubscriptionByShortUuidByClientTypeCommand.RequestSchema, 7 | ) {} 8 | -------------------------------------------------------------------------------- /src/modules/subscription/dto/get-subscription-by-username.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetSubscriptionByUsernameCommand } from '@libs/contracts/commands/subscriptions'; 4 | 5 | export class GetSubscriptionByUsernameRequestDto extends createZodDto( 6 | GetSubscriptionByUsernameCommand.RequestSchema, 7 | ) {} 8 | 9 | export class GetSubscriptionByUsernameResponseDto extends createZodDto( 10 | GetSubscriptionByUsernameCommand.ResponseSchema, 11 | ) {} 12 | -------------------------------------------------------------------------------- /src/modules/subscription/dto/get-subscription-info.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetSubscriptionInfoByShortUuidCommand } from '@libs/contracts/commands/subscription'; 4 | 5 | export class GetSubscriptionInfoRequestDto extends createZodDto( 6 | GetSubscriptionInfoByShortUuidCommand.RequestSchema, 7 | ) {} 8 | export class GetSubscriptionInfoResponseDto extends createZodDto( 9 | GetSubscriptionInfoByShortUuidCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/subscription/dto/get-subscription.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetSubscriptionByShortUuidCommand } from '@libs/contracts/commands/subscription'; 4 | 5 | export class GetSubscriptionByShortUuidRequestDto extends createZodDto( 6 | GetSubscriptionByShortUuidCommand.RequestSchema, 7 | ) {} 8 | -------------------------------------------------------------------------------- /src/modules/subscription/dto/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-all-subscriptions.dto'; 2 | export * from './get-outline-subscription.dto'; 3 | export * from './get-subscription-by-client-type.dto'; 4 | export * from './get-subscription-by-username.dto'; 5 | export * from './get-subscription-info.dto'; 6 | export * from './get-subscription.dto'; 7 | -------------------------------------------------------------------------------- /src/modules/subscription/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './subscription-headers.interface'; 2 | -------------------------------------------------------------------------------- /src/modules/subscription/interfaces/subscription-headers.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ISubscriptionHeaders { 2 | 'content-disposition': string; 3 | 'profile-title': string; 4 | 'profile-update-interval': string; 5 | 'profile-web-page-url'?: string; 6 | 'subscription-userinfo': string; 7 | 'support-url': string; 8 | announce?: string; 9 | routing?: string; 10 | [key: string]: string | undefined; 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/subscription/models/all-subscription.response.model.ts: -------------------------------------------------------------------------------- 1 | import { SubscriptionRawResponse } from './subscription-raw.response.model'; 2 | 3 | export class AllSubscriptionsResponseModel { 4 | public readonly subscriptions: SubscriptionRawResponse[]; 5 | public readonly total: number; 6 | 7 | constructor(data: AllSubscriptionsResponseModel) { 8 | this.total = data.total; 9 | this.subscriptions = data.subscriptions; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/subscription/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './all-subscription.response.model'; 2 | export * from './subscription-not-found.response.model'; 3 | export * from './subscription-raw.response.model'; 4 | export * from './subscription-with-config.response.model'; 5 | -------------------------------------------------------------------------------- /src/modules/subscription/models/subscription-not-found.response.model.ts: -------------------------------------------------------------------------------- 1 | export class SubscriptionNotFoundResponse { 2 | public isFound: boolean; 3 | public statusCode: number; 4 | public message: string; 5 | 6 | constructor() { 7 | this.isFound = false; 8 | this.statusCode = 404; 9 | this.message = 'Resource not found'; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/subscription/models/subscription-with-config.response.model.ts: -------------------------------------------------------------------------------- 1 | import { ISubscriptionHeaders } from '../interfaces/subscription-headers.interface'; 2 | 3 | export class SubscriptionWithConfigResponse { 4 | headers: ISubscriptionHeaders; 5 | contentType: string; 6 | body: unknown; 7 | 8 | constructor(data: SubscriptionWithConfigResponse) { 9 | this.headers = data.headers; 10 | this.contentType = data.contentType; 11 | this.body = data.body; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/modules/subscription/utils/parse-sing-box-version.ts: -------------------------------------------------------------------------------- 1 | export function parseSingBoxVersion(userAgent: string): null | string { 2 | const versionRegex = /(?:SFA|SFI|SFM|SFT|[Rr]abbit[Hh]ole)\/(\d+)\.(\d+)\.(\d+)(?:-beta\.\d+)?/; 3 | const match = userAgent.match(versionRegex); 4 | if (!match) return null; 5 | 6 | return `${match[1]}.${match[2]}.${match[3]}`; 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/system/dtos/get-bandwidth-stats.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetBandwidthStatsCommand } from '@contract/commands'; 4 | 5 | export class GetBandwidthStatsRequestQueryDto extends createZodDto( 6 | GetBandwidthStatsCommand.RequestQuerySchema, 7 | ) {} 8 | export class GetBandwidthStatsResponseDto extends createZodDto( 9 | GetBandwidthStatsCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/system/dtos/get-nodes-statistics.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetNodesStatisticsCommand } from '@contract/commands'; 4 | 5 | export class GetNodesStatisticsRequestQueryDto extends createZodDto( 6 | GetNodesStatisticsCommand.RequestQuerySchema, 7 | ) {} 8 | export class GetNodesStatisticsResponseDto extends createZodDto( 9 | GetNodesStatisticsCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/system/dtos/get-stats.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetStatsCommand } from '@contract/commands'; 4 | 5 | export class GetStatsRequestQueryDto extends createZodDto(GetStatsCommand.RequestQuerySchema) {} 6 | export class GetStatsResponseDto extends createZodDto(GetStatsCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/system/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-bandwidth-stats.dto'; 2 | export * from './get-nodes-statistics.dto'; 3 | export * from './get-stats.dto'; 4 | -------------------------------------------------------------------------------- /src/modules/system/index.ts: -------------------------------------------------------------------------------- 1 | export * from './system.controller'; 2 | export * from './system.module'; 3 | export * from './system.service'; 4 | -------------------------------------------------------------------------------- /src/modules/system/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-bandwidth-stats.response.model'; 2 | export * from './get-nodes-statistics.response.model'; 3 | export * from './get-stats.response.model'; 4 | -------------------------------------------------------------------------------- /src/modules/system/system.module.ts: -------------------------------------------------------------------------------- 1 | import { CqrsModule } from '@nestjs/cqrs'; 2 | import { Module } from '@nestjs/common'; 3 | 4 | import { SystemController } from './system.controller'; 5 | import { SystemService } from './system.service'; 6 | 7 | @Module({ 8 | imports: [CqrsModule], 9 | controllers: [SystemController], 10 | providers: [SystemService], 11 | }) 12 | export class SystemModule {} 13 | -------------------------------------------------------------------------------- /src/modules/user-traffic-history/commands/create-user-traffic-history/create-user-traffic-history.command.ts: -------------------------------------------------------------------------------- 1 | import { UserTrafficHistoryEntity } from '../../entities/user-traffic-history.entity'; 2 | 3 | export class CreateUserTrafficHistoryCommand { 4 | constructor(public readonly userTrafficHistory: UserTrafficHistoryEntity) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/user-traffic-history/commands/create-user-traffic-history/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-user-traffic-history.command'; 2 | export * from './create-user-traffic-history.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/user-traffic-history/commands/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateUserTrafficHistoryHandler } from './create-user-traffic-history'; 2 | 3 | export const COMMANDS = [CreateUserTrafficHistoryHandler]; 4 | -------------------------------------------------------------------------------- /src/modules/user-traffic-history/entities/user-traffic-history.entity.ts: -------------------------------------------------------------------------------- 1 | import { UserTrafficHistory } from '@prisma/client'; 2 | 3 | export class UserTrafficHistoryEntity implements UserTrafficHistory { 4 | id: bigint; 5 | userUuid: string; 6 | usedBytes: bigint; 7 | resetAt: Date; 8 | createdAt: Date; 9 | 10 | constructor(history: Partial) { 11 | Object.assign(this, history); 12 | return this; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/modules/user-traffic-history/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/user-traffic-history.entity'; 2 | export * from './repositories/user-traffic-history.repository'; 3 | export * from './user-traffic-history.module'; 4 | -------------------------------------------------------------------------------- /src/modules/users/builders/batch-reset-limited-users-usage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './batch-reset-limited-users-usage.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/users/builders/batch-reset-users-usage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './batch-reset-users-usage.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/users/builders/bulk-delete-by-status/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-delete-by-status.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/users/builders/bulk-update-user-used-traffic/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-update-user-used-traffic.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/users/builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from './batch-reset-limited-users-usage'; 2 | export * from './batch-reset-users-usage'; 3 | export * from './bulk-delete-by-status'; 4 | export * from './bulk-update-user-used-traffic'; 5 | export * from './sum-lifetime-usage'; 6 | export * from './users-with-inbound-tag'; 7 | -------------------------------------------------------------------------------- /src/modules/users/builders/last-connected-node/index.ts: -------------------------------------------------------------------------------- 1 | export * from './last-connected-node.builder'; 2 | export * from './last-connected-node.interface'; 3 | -------------------------------------------------------------------------------- /src/modules/users/builders/last-connected-node/last-connected-node.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ILastConnectedNodeFromBuilder { 2 | userUuid: string; 3 | nodeName: string; 4 | connectedAt: Date; 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/users/builders/sum-lifetime-usage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './sum-lifetime-usage.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/users/builders/trigger-threshold-notifications-builder/index.ts: -------------------------------------------------------------------------------- 1 | export * from './trigger-threshold-notifications-builder.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/users/builders/users-with-inbound-tag/index.ts: -------------------------------------------------------------------------------- 1 | export * from './users-with-inbound-tag.builder'; 2 | -------------------------------------------------------------------------------- /src/modules/users/commands/batch-reset-limited-users-traffic/batch-reset-limited-users-traffic.command.ts: -------------------------------------------------------------------------------- 1 | import { TResetPeriods } from '@libs/contracts/constants'; 2 | 3 | export class BatchResetLimitedUsersTrafficCommand { 4 | constructor(public readonly strategy: TResetPeriods) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/users/commands/batch-reset-limited-users-traffic/index.ts: -------------------------------------------------------------------------------- 1 | export * from './batch-reset-limited-users-traffic.command'; 2 | export * from './batch-reset-limited-users-traffic.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/batch-reset-user-traffic/batch-reset-user-traffic.command.ts: -------------------------------------------------------------------------------- 1 | import { TResetPeriods } from '@libs/contracts/constants'; 2 | 3 | export class BatchResetUserTrafficCommand { 4 | constructor(public readonly strategy: TResetPeriods) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/users/commands/batch-reset-user-traffic/index.ts: -------------------------------------------------------------------------------- 1 | export * from './batch-reset-user-traffic.command'; 2 | export * from './batch-reset-user-traffic.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/bulk-delete-by-status/bulk-delete-by-status.command.ts: -------------------------------------------------------------------------------- 1 | import { TUsersStatus } from '@libs/contracts/constants'; 2 | 3 | export class BulkDeleteByStatusCommand { 4 | constructor( 5 | public readonly status: TUsersStatus, 6 | public readonly limit?: number, 7 | ) {} 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/users/commands/bulk-delete-by-status/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-delete-by-status.command'; 2 | export * from './bulk-delete-by-status.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/bulk-increment-used-traffic/bulk-increment-used-traffic.command.ts: -------------------------------------------------------------------------------- 1 | interface IBulkUpdateUsedTraffic { 2 | u: string; 3 | b: string; 4 | } 5 | 6 | export class BulkIncrementUsedTrafficCommand { 7 | constructor(public readonly userUsageList: IBulkUpdateUsedTraffic[]) {} 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/users/commands/bulk-increment-used-traffic/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-increment-used-traffic.command'; 2 | export * from './bulk-increment-used-traffic.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/change-user-status/change-user-status.command.ts: -------------------------------------------------------------------------------- 1 | import { TUsersStatus } from '@contract/constants'; 2 | 3 | export class ChangeUserStatusCommand { 4 | constructor( 5 | public readonly userUuid: string, 6 | public readonly status: TUsersStatus, 7 | ) {} 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/users/commands/change-user-status/index.ts: -------------------------------------------------------------------------------- 1 | export * from './change-user-status.command'; 2 | export * from './change-user-status.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/increment-used-traffic/increment-used-traffic.command.ts: -------------------------------------------------------------------------------- 1 | export class IncrementUsedTrafficCommand { 2 | constructor( 3 | public readonly userUuid: string, 4 | public readonly bytes: bigint, 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/users/commands/increment-used-traffic/index.ts: -------------------------------------------------------------------------------- 1 | export * from './increment-used-traffic.command'; 2 | export * from './increment-used-traffic.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/reset-user-traffic/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reset-user-traffic.command'; 2 | export * from './reset-user-traffic.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/reset-user-traffic/reset-user-traffic.command.ts: -------------------------------------------------------------------------------- 1 | export class ResetUserTrafficCommand { 2 | constructor(public readonly uuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/commands/revoke-user-subscription/index.ts: -------------------------------------------------------------------------------- 1 | export * from './revoke-user-subscription.command'; 2 | export * from './revoke-user-subscription.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/revoke-user-subscription/revoke-user-subscription.command.ts: -------------------------------------------------------------------------------- 1 | export class RevokeUserSubscriptionCommand { 2 | constructor(public readonly uuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/commands/trigger-threshold-notification/index.ts: -------------------------------------------------------------------------------- 1 | export * from './trigger-threshold-notification.command'; 2 | export * from './trigger-threshold-notification.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/trigger-threshold-notification/trigger-threshold-notification.command.ts: -------------------------------------------------------------------------------- 1 | export class TriggerThresholdNotificationCommand { 2 | constructor(public readonly percentages: number[]) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-exceeded-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './update-exceeded-users.command'; 2 | export * from './update-exceeded-users.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-exceeded-users/update-exceeded-users.command.ts: -------------------------------------------------------------------------------- 1 | export class UpdateExceededTrafficUsersCommand { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-expired-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './update-expired-users.command'; 2 | export * from './update-expired-users.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-expired-users/update-expired-users.command.ts: -------------------------------------------------------------------------------- 1 | export class UpdateExpiredUsersCommand { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-status-and-traffic-and-reset-at/index.ts: -------------------------------------------------------------------------------- 1 | export * from './update-status-and-traffic-and-reset-at.command'; 2 | export * from './update-status-and-traffic-and-reset-at.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-status-and-traffic-and-reset-at/update-status-and-traffic-and-reset-at.command.ts: -------------------------------------------------------------------------------- 1 | import { TUsersStatus } from '@libs/contracts/constants'; 2 | 3 | export class UpdateStatusAndTrafficAndResetAtCommand { 4 | constructor( 5 | public readonly userUuid: string, 6 | public readonly lastResetAt: Date, 7 | public readonly status?: TUsersStatus, 8 | ) {} 9 | } 10 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-sub-last-opened-and-user-agent/index.ts: -------------------------------------------------------------------------------- 1 | export * from './update-sub-last-opened-and-user-agent.command'; 2 | export * from './update-sub-last-opened-and-user-agent.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-sub-last-opened-and-user-agent/update-sub-last-opened-and-user-agent.command.ts: -------------------------------------------------------------------------------- 1 | export class UpdateSubLastOpenedAndUserAgentCommand { 2 | constructor( 3 | public readonly userUuid: string, 4 | public readonly subLastOpenedAt: Date, 5 | public readonly subLastUserAgent: string, 6 | ) {} 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-user-with-service/index.ts: -------------------------------------------------------------------------------- 1 | export * from './update-user-with-service.command'; 2 | export * from './update-user-with-service.handler'; 3 | -------------------------------------------------------------------------------- /src/modules/users/commands/update-user-with-service/update-user-with-service.command.ts: -------------------------------------------------------------------------------- 1 | import { UpdateUserRequestDto } from '@modules/users/dtos'; 2 | 3 | export class UpdateUserWithServiceCommand { 4 | constructor(public readonly dto: UpdateUserRequestDto) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/users/controllers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './users-bulk-actions.controller'; 2 | export * from './users-stats.controller'; 3 | export * from './users.controller'; 4 | -------------------------------------------------------------------------------- /src/modules/users/dtos/activate-all-inbounds.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { ActivateAllInboundsCommand } from '@libs/contracts/commands'; 4 | 5 | export class ActivateAllInboundsRequestDto extends createZodDto( 6 | ActivateAllInboundsCommand.RequestSchema, 7 | ) {} 8 | export class ActivateAllInboundsResponseDto extends createZodDto( 9 | ActivateAllInboundsCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/users/dtos/bulk/bulk-delete-users-by-status.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { BulkDeleteUsersByStatusCommand } from '@libs/contracts/commands'; 4 | 5 | export class BulkDeleteUsersByStatusRequestDto extends createZodDto( 6 | BulkDeleteUsersByStatusCommand.RequestSchema, 7 | ) {} 8 | export class BulkDeleteUsersByStatusResponseDto extends createZodDto( 9 | BulkDeleteUsersByStatusCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/users/dtos/bulk/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-delete-users-by-status.dto'; 2 | export * from './bulk-operations.dto'; 3 | -------------------------------------------------------------------------------- /src/modules/users/dtos/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { CreateUserCommand } from '@libs/contracts/commands/users/create-user.command'; 4 | 5 | export class CreateUserRequestDto extends createZodDto(CreateUserCommand.RequestSchema) {} 6 | export class CreateUserResponseDto extends createZodDto(CreateUserCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/dtos/delete-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { DeleteUserCommand } from '@libs/contracts/commands'; 4 | 5 | export class DeleteUserRequestDto extends createZodDto(DeleteUserCommand.RequestSchema) {} 6 | export class DeleteUserResponseDto extends createZodDto(DeleteUserCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/dtos/disable-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { DisableUserCommand } from '@libs/contracts/commands'; 4 | 5 | export class DisableUserRequestDto extends createZodDto(DisableUserCommand.RequestSchema) {} 6 | export class DisableUserResponseDto extends createZodDto(DisableUserCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/dtos/enable-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { EnableUserCommand } from '@libs/contracts/commands'; 4 | 5 | export class EnableUserRequestDto extends createZodDto(EnableUserCommand.RequestSchema) {} 6 | export class EnableUserResponseDto extends createZodDto(EnableUserCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-all-users-v2.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetAllUsersCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetAllUsersQueryDto extends createZodDto(GetAllUsersCommand.RequestQuerySchema) {} 6 | export class GetAllUsersResponseDto extends createZodDto(GetAllUsersCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-user-by-email.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserByEmailCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetUserByEmailRequestDto extends createZodDto(GetUserByEmailCommand.RequestSchema) {} 6 | export class GetUserByEmailResponseDto extends createZodDto(GetUserByEmailCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-user-by-short-uuid.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserByShortUuidCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetUserByShortUuidRequestDto extends createZodDto( 6 | GetUserByShortUuidCommand.RequestSchema, 7 | ) {} 8 | export class GetUserByShortUuidResponseDto extends createZodDto( 9 | GetUserByShortUuidCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-user-by-subscription-uuid.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserBySubscriptionUuidCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetUserBySubscriptionUuidRequestDto extends createZodDto( 6 | GetUserBySubscriptionUuidCommand.RequestSchema, 7 | ) {} 8 | export class GetUserBySubscriptionUuidResponseDto extends createZodDto( 9 | GetUserBySubscriptionUuidCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-user-by-telegram-id.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserByTelegramIdCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetUserByTelegramIdRequestDto extends createZodDto( 6 | GetUserByTelegramIdCommand.RequestSchema, 7 | ) {} 8 | export class GetUserByTelegramIdResponseDto extends createZodDto( 9 | GetUserByTelegramIdCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-user-by-username.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserByUsernameCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetUserByUsernameRequestDto extends createZodDto( 6 | GetUserByUsernameCommand.RequestSchema, 7 | ) {} 8 | export class GetUserByUsernameResponseDto extends createZodDto( 9 | GetUserByUsernameCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-user-by-uuid.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserByUuidCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetUserByUuidRequestDto extends createZodDto(GetUserByUuidCommand.RequestSchema) {} 6 | export class GetUserByUuidResponseDto extends createZodDto(GetUserByUuidCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-user-usage-by-range.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserUsageByRangeCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetUserUsageByRangeRequestQueryDto extends createZodDto( 6 | GetUserUsageByRangeCommand.RequestQuerySchema, 7 | ) {} 8 | 9 | export class GetUserUsageByRangeRequestDto extends createZodDto( 10 | GetUserUsageByRangeCommand.RequestSchema, 11 | ) {} 12 | export class GetUserUsageByRangeResponseDto extends createZodDto( 13 | GetUserUsageByRangeCommand.ResponseSchema, 14 | ) {} 15 | -------------------------------------------------------------------------------- /src/modules/users/dtos/get-users-by-tag.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetUserByTagCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetUserByTagRequestDto extends createZodDto(GetUserByTagCommand.RequestSchema) {} 6 | export class GetUserByTagResponseDto extends createZodDto(GetUserByTagCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/dtos/reset-user-traffic.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { ResetUserTrafficCommand } from '@libs/contracts/commands'; 4 | 5 | export class ResetUserTrafficRequestDto extends createZodDto( 6 | ResetUserTrafficCommand.RequestSchema, 7 | ) {} 8 | export class ResetUserTrafficResponseDto extends createZodDto( 9 | ResetUserTrafficCommand.ResponseSchema, 10 | ) {} 11 | -------------------------------------------------------------------------------- /src/modules/users/dtos/tags/get-all-tags.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetAllTagsCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetAllTagsResponseDto extends createZodDto(GetAllTagsCommand.ResponseSchema) {} 6 | -------------------------------------------------------------------------------- /src/modules/users/dtos/tags/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-all-tags.dto'; 2 | -------------------------------------------------------------------------------- /src/modules/users/dtos/update-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { UpdateUserCommand } from '@libs/contracts/commands'; 4 | 5 | export class UpdateUserRequestDto extends createZodDto(UpdateUserCommand.RequestSchema) {} 6 | export class UpdateUserResponseDto extends createZodDto(UpdateUserCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/users/entities/index.ts: -------------------------------------------------------------------------------- 1 | export * from './user-with-active-inbounds-and-last-connected-node.entity'; 2 | export * from './user-with-active-inbounds.entity'; 3 | export * from './user-with-ai-and-lcn-raw.entity'; 4 | export * from './users-for-config'; 5 | export * from './users.entity'; 6 | -------------------------------------------------------------------------------- /src/modules/users/entities/users-for-config.ts: -------------------------------------------------------------------------------- 1 | export class UserForConfigEntity { 2 | public username: string; 3 | public trojanPassword: string; 4 | public vlessUuid: string; 5 | public ssPassword: string; 6 | public tags: string[]; 7 | 8 | constructor(data: UserForConfigEntity) { 9 | this.username = data.username; 10 | this.trojanPassword = data.trojanPassword; 11 | this.vlessUuid = data.vlessUuid; 12 | this.ssPassword = data.ssPassword; 13 | this.tags = data.tags; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/modules/users/events/index.ts: -------------------------------------------------------------------------------- 1 | export const EVENTS = []; 2 | -------------------------------------------------------------------------------- /src/modules/users/interfaces/get-user-by-unique.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IGetUserByUnique { 2 | username?: string; 3 | subscriptionUuid?: string; 4 | uuid?: string; 5 | shortUuid?: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/users/interfaces/get-user-usage-by-range.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IGetUserUsageByRange { 2 | userUuid: string; 3 | nodeUuid: string; 4 | nodeName: string; 5 | total: bigint; 6 | date: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/users/interfaces/get-user-with-last-connected-node.interface.ts: -------------------------------------------------------------------------------- 1 | import { ILastConnectedNode } from '@modules/nodes-user-usage-history/interfaces'; 2 | 3 | import { UserWithActiveInboundsEntity } from '../entities/user-with-active-inbounds.entity'; 4 | 5 | export interface IGetUserWithLastConnectedNode { 6 | user: UserWithActiveInboundsEntity; 7 | lastConnectedNode: ILastConnectedNode | null; 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/users/interfaces/get-users-by-telegram-id-or-email.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IGetUsersByTelegramIdOrEmail { 2 | email?: string; 3 | telegramId?: string; 4 | tag?: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/users/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-user-by-unique.interface'; 2 | export * from './get-user-usage-by-range.interface'; 3 | export * from './get-user-with-last-connected-node.interface'; 4 | export * from './get-users-by-telegram-id-or-email.interface'; 5 | export * from './user-stats.interface'; 6 | export * from './user-status-count.interface'; 7 | export * from './user-with-active-inbounds-and-last-connected-node.interface'; 8 | export * from './user-with-active-inbounds.interface'; 9 | export * from './user-with-lifetime-traffic.interface'; 10 | -------------------------------------------------------------------------------- /src/modules/users/interfaces/user-stats.interface.ts: -------------------------------------------------------------------------------- 1 | import { TUsersStatus } from '@libs/contracts/constants'; 2 | 3 | export interface IUserOnlineStats { 4 | lastDay: number; 5 | lastWeek: number; 6 | neverOnline: number; 7 | onlineNow: number; 8 | } 9 | 10 | export interface IUserStats { 11 | statusCounts: Record; 12 | totalTrafficBytes: bigint; 13 | totalUsers: number; 14 | } 15 | 16 | export interface ShortUserStats { 17 | onlineStats: IUserOnlineStats; 18 | statusCounts: IUserStats; 19 | } 20 | -------------------------------------------------------------------------------- /src/modules/users/interfaces/user-status-count.interface.ts: -------------------------------------------------------------------------------- 1 | import { TUsersStatus } from '@libs/contracts/constants'; 2 | 3 | export interface IUserStatusCount { 4 | count: number; 5 | status: TUsersStatus; 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/users/models/bulk/bulk-all.response.model.ts: -------------------------------------------------------------------------------- 1 | export class BulkAllResponseModel { 2 | public readonly eventSent: boolean; 3 | 4 | constructor(eventSent: boolean) { 5 | this.eventSent = eventSent; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/users/models/bulk/bulk-delete-by-status.response.model.ts: -------------------------------------------------------------------------------- 1 | export class BulkDeleteByStatusResponseModel { 2 | public readonly affectedRows: number; 3 | 4 | constructor(affectedRows: number) { 5 | this.affectedRows = affectedRows; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/users/models/bulk/bulk-operation.response.model.ts: -------------------------------------------------------------------------------- 1 | export class BulkOperationResponseModel { 2 | public readonly affectedRows: number; 3 | 4 | constructor(affectedRows: number) { 5 | this.affectedRows = affectedRows; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/users/models/bulk/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-all.response.model'; 2 | export * from './bulk-delete-by-status.response.model'; 3 | export * from './bulk-operation.response.model'; 4 | -------------------------------------------------------------------------------- /src/modules/users/models/delete-user.response.model.ts: -------------------------------------------------------------------------------- 1 | export class DeleteUserResponseModel { 2 | public readonly isDeleted: boolean; 3 | 4 | constructor(isDeleted: boolean) { 5 | this.isDeleted = isDeleted; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/users/models/get-all-tags.response.model.ts: -------------------------------------------------------------------------------- 1 | export class GetAllTagsResponseModel { 2 | public readonly tags: string[]; 3 | 4 | constructor(data: GetAllTagsResponseModel) { 5 | this.tags = data.tags; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/users/models/get-all-users.response.model.ts: -------------------------------------------------------------------------------- 1 | import { GetFullUserResponseModel } from './get-full-user.response.model'; 2 | 3 | export class GetAllUsersResponseModel { 4 | public readonly total: number; 5 | public readonly users: GetFullUserResponseModel[]; 6 | 7 | constructor(data: GetAllUsersResponseModel) { 8 | this.total = data.total; 9 | this.users = data.users; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/users/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk'; 2 | export * from './create-user.response.model'; 3 | export * from './delete-user.response.model'; 4 | export * from './get-all-tags.response.model'; 5 | export * from './get-all-users.response.model'; 6 | export * from './get-full-user.response.model'; 7 | export * from './get-user-usage-by-range.response.model'; 8 | export * from './get-user.response.model'; 9 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-active-users/get-active-users.query.ts: -------------------------------------------------------------------------------- 1 | export class GetActiveUsersQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-active-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-active-users.handler'; 2 | export * from './get-active-users.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-all-users/get-all-users.query.ts: -------------------------------------------------------------------------------- 1 | export class GetAllUsersQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-all-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-all-users.handler'; 2 | export * from './get-all-users.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-exceeded-traffic-usage-users/get-exceeded-traffic-usage-users.query.ts: -------------------------------------------------------------------------------- 1 | export class GetExceededTrafficUsageUsersQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-exceeded-traffic-usage-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-exceeded-traffic-usage-users.handler'; 2 | export * from './get-exceeded-traffic-usage-users.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-expired-users/get-expired-users.query.ts: -------------------------------------------------------------------------------- 1 | export class GetExpiredUsersQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-expired-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-expired-users.handler'; 2 | export * from './get-expired-users.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-prepared-config-with-users/get-prepared-config-with-users.query.ts: -------------------------------------------------------------------------------- 1 | import { InboundsEntity } from '@modules/inbounds/entities'; 2 | 3 | export class GetPreparedConfigWithUsersQuery { 4 | constructor( 5 | public readonly excludedInbounds: InboundsEntity[], 6 | public readonly excludeInboundsFromConfig: boolean = true, 7 | ) {} 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-prepared-config-with-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-prepared-config-with-users.handler'; 2 | export * from './get-prepared-config-with-users.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-short-user-stats/get-short-user-stats.query.ts: -------------------------------------------------------------------------------- 1 | export class GetShortUserStatsQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-short-user-stats/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-short-user-stats.handler'; 2 | export * from './get-short-user-stats.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-user-by-short-uuid/get-user-by-short-uuid.query.ts: -------------------------------------------------------------------------------- 1 | export class GetUserByShortUuidQuery { 2 | constructor(public readonly shortUuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-user-by-short-uuid/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-user-by-short-uuid.handler'; 2 | export * from './get-user-by-short-uuid.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-user-by-username/get-user-by-username.query.ts: -------------------------------------------------------------------------------- 1 | export class GetUserByUsernameQuery { 2 | constructor(public readonly username: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-user-by-username/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-user-by-username.handler'; 2 | export * from './get-user-by-username.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-user-by-uuid/get-user-by-uuid.query.ts: -------------------------------------------------------------------------------- 1 | export class GetUserByUuidQuery { 2 | constructor(public readonly uuid: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-user-by-uuid/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-user-by-uuid.handler'; 2 | export * from './get-user-by-uuid.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-by-expire-at/get-users-by-expire-at.query.ts: -------------------------------------------------------------------------------- 1 | export class GetUsersByExpireAtQuery { 2 | constructor( 3 | public readonly start: Date, 4 | public readonly end: Date, 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-by-expire-at/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-users-by-expire-at.handler'; 2 | export * from './get-users-by-expire-at.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-by-traffic-strategy-and-status/get-users-by-traffic-strategy-and-status.query.ts: -------------------------------------------------------------------------------- 1 | import { TResetPeriods, TUsersStatus } from '@libs/contracts/constants'; 2 | 3 | export class GetUsersByTrafficStrategyAndStatusQuery { 4 | constructor( 5 | public readonly strategy: TResetPeriods, 6 | public readonly status: TUsersStatus, 7 | ) {} 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-by-traffic-strategy-and-status/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-users-by-traffic-strategy-and-status.handler'; 2 | export * from './get-users-by-traffic-strategy-and-status.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-for-config-batch/get-users-for-config-batch.query.ts: -------------------------------------------------------------------------------- 1 | import { InboundsEntity } from '@modules/inbounds/entities'; 2 | 3 | export class GetUsersForConfigBatchQuery { 4 | constructor( 5 | public readonly excludedInbounds: InboundsEntity[], 6 | public readonly limit: number, 7 | public readonly offset: number, 8 | ) {} 9 | } 10 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-for-config-batch/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-users-for-config-batch.handler'; 2 | export * from './get-users-for-config-batch.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-for-config/get-users-for-config.query.ts: -------------------------------------------------------------------------------- 1 | import { InboundsEntity } from '@modules/inbounds/entities'; 2 | 3 | export class GetUsersForConfigQuery { 4 | constructor(public readonly excludedInbounds: InboundsEntity[]) {} 5 | } 6 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-for-config/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-users-for-config.handler'; 2 | export * from './get-users-for-config.query'; 3 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-with-pagination/get-users-with-pagination.query.ts: -------------------------------------------------------------------------------- 1 | export class GetUsersWithPaginationQuery { 2 | constructor( 3 | public readonly start: number, 4 | public readonly size: number, 5 | ) {} 6 | } 7 | -------------------------------------------------------------------------------- /src/modules/users/queries/get-users-with-pagination/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-users-with-pagination.handler'; 2 | export * from './get-users-with-pagination.query'; 3 | -------------------------------------------------------------------------------- /src/modules/xray-config/dtos/get-config.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { GetXrayConfigCommand } from '@libs/contracts/commands'; 4 | 5 | export class GetConfigResponseDto extends createZodDto(GetXrayConfigCommand.ResponseSchema) {} 6 | -------------------------------------------------------------------------------- /src/modules/xray-config/dtos/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-config.dto'; 2 | export * from './update-config.dto'; 3 | -------------------------------------------------------------------------------- /src/modules/xray-config/dtos/update-config.dto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from 'nestjs-zod'; 2 | 3 | import { UpdateXrayConfigCommand } from '@libs/contracts/commands'; 4 | 5 | export class UpdateConfigRequestDto extends createZodDto(UpdateXrayConfigCommand.RequestSchema) {} 6 | export class UpdateConfigResponseDto extends createZodDto(UpdateXrayConfigCommand.ResponseSchema) {} 7 | -------------------------------------------------------------------------------- /src/modules/xray-config/entities/xray-config.entity.ts: -------------------------------------------------------------------------------- 1 | import { XrayConfig } from '@prisma/client'; 2 | 3 | export class XrayConfigEntity implements XrayConfig { 4 | uuid: string; 5 | config: null | object; 6 | updatedAt: Date; 7 | 8 | constructor(config: Partial) { 9 | Object.assign(this, config); 10 | return this; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/modules/xray-config/index.ts: -------------------------------------------------------------------------------- 1 | export * from './entities/xray-config.entity'; 2 | export * from './repositories/xray-config.repository'; 3 | export * from './xray-config.controller'; 4 | export * from './xray-config.module'; 5 | export * from './xray-config.service'; 6 | -------------------------------------------------------------------------------- /src/modules/xray-config/models/get-config.response.model.ts: -------------------------------------------------------------------------------- 1 | export class GetConfigResponseModel { 2 | public config: object; 3 | 4 | constructor(config: object) { 5 | this.config = config; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/modules/xray-config/queries/get-validated-config/get-validated-config.query.ts: -------------------------------------------------------------------------------- 1 | export class GetValidatedConfigQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/xray-config/queries/get-validated-config/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-validated-config.handler'; 2 | export * from './get-validated-config.query'; 3 | -------------------------------------------------------------------------------- /src/modules/xray-config/queries/get-xray-config/get-xray-config.query.ts: -------------------------------------------------------------------------------- 1 | export class GetXrayConfigQuery { 2 | constructor() {} 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/xray-config/queries/get-xray-config/index.ts: -------------------------------------------------------------------------------- 1 | export * from './get-xray-config.handler'; 2 | export * from './get-xray-config.query'; 3 | -------------------------------------------------------------------------------- /src/modules/xray-config/queries/index.ts: -------------------------------------------------------------------------------- 1 | import { GetValidatedConfigHandler } from './get-validated-config'; 2 | import { GetXrayConfigHandler } from './get-xray-config'; 3 | 4 | export const QUERIES = [GetValidatedConfigHandler, GetXrayConfigHandler]; 5 | -------------------------------------------------------------------------------- /src/queue/bulk-user-operations/enums/bulk-user-operations-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum BulkUserOperationsJobNames { 2 | resetUsersTraffic = 'resetUsersTraffic', 3 | revokeUsersSubscription = 'revokeUsersSubscription', 4 | updateUsers = 'updateUsers', 5 | } 6 | -------------------------------------------------------------------------------- /src/queue/bulk-user-operations/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './bulk-user-operations-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/bulk-user-operations/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './bulk-user-operations.service'; 3 | -------------------------------------------------------------------------------- /src/queue/expire-user-notifications/enums/expire-user-notifications-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum ExpireUserNotificationsJobNames { 2 | expireUserNotifications = 'expireUserNotifications', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/expire-user-notifications/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './expire-user-notifications-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/expire-user-notifications/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './expire-user-notifications.service'; 3 | -------------------------------------------------------------------------------- /src/queue/first-connected-users/enums/first-connected-users-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum FirstConnectedUsersJobNames { 2 | handleFirstConnectedUsers = 'handleFirstConnectedUsers', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/first-connected-users/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './first-connected-users-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/first-connected-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './first-connected-users.service'; 3 | -------------------------------------------------------------------------------- /src/queue/index.ts: -------------------------------------------------------------------------------- 1 | export * from './start-all-nodes'; 2 | -------------------------------------------------------------------------------- /src/queue/node-health-check/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './node-health-check-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/node-health-check/enums/node-health-check-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum NodeHealthCheckJobNames { 2 | checkNodeHealth = 'checkNodeHealth', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/node-health-check/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './node-health-check.service'; 3 | -------------------------------------------------------------------------------- /src/queue/node-health-check/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './node-health-check.interface'; 2 | -------------------------------------------------------------------------------- /src/queue/node-health-check/interfaces/node-health-check.interface.ts: -------------------------------------------------------------------------------- 1 | export interface NodeHealthCheckPayload { 2 | nodeUuid: string; 3 | nodeAddress: string; 4 | nodePort: number | null; 5 | isConnected: boolean; 6 | isConnecting: boolean; 7 | } 8 | -------------------------------------------------------------------------------- /src/queue/node-users/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './node-users-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/node-users/enums/node-users-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum NodeUsersJobNames { 2 | addUserToNode = 'addUserToNode', 3 | removeUserFromNode = 'removeUserFromNode', 4 | } 5 | -------------------------------------------------------------------------------- /src/queue/node-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './node-users.service'; 3 | -------------------------------------------------------------------------------- /src/queue/node-users/interfaces/add-user-to-node.payload.interface.ts: -------------------------------------------------------------------------------- 1 | import { AddUserCommand as AddUserToNodeCommandSdk } from '@remnawave/node-contract/build/commands'; 2 | 3 | export interface IAddUserToNodePayload { 4 | data: AddUserToNodeCommandSdk.Request; 5 | node: { 6 | address: string; 7 | port: number | null; 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /src/queue/node-users/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './add-user-to-node.payload.interface'; 2 | export * from './remove-user-from-node.payload.interface'; 3 | -------------------------------------------------------------------------------- /src/queue/node-users/interfaces/remove-user-from-node.payload.interface.ts: -------------------------------------------------------------------------------- 1 | import { RemoveUserCommand as RemoveUserFromNodeCommandSdk } from '@remnawave/node-contract/build/commands'; 2 | 3 | export interface IRemoveUserFromNodePayload { 4 | data: RemoveUserFromNodeCommandSdk.Request; 5 | node: { 6 | address: string; 7 | port: number | null; 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /src/queue/notifications/notifications-modules.ts: -------------------------------------------------------------------------------- 1 | import { TelegramBotLoggerQueueModule } from './telegram-bot-logger/telegram-bot-logger.module'; 2 | import { WebhookLoggerQueueModule } from './webhook-logger/webhook-logger.module'; 3 | 4 | export const NOTIFICATIONS_MODULES = [TelegramBotLoggerQueueModule, WebhookLoggerQueueModule]; 5 | -------------------------------------------------------------------------------- /src/queue/notifications/telegram-bot-logger/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './telegram-bot-logger-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/notifications/telegram-bot-logger/enums/telegram-bot-logger-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum TelegramBotLoggerJobNames { 2 | sendTelegramMessage = 'sendTelegramMessage', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/notifications/telegram-bot-logger/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './telegram-bot-logger.service'; 3 | -------------------------------------------------------------------------------- /src/queue/notifications/webhook-logger/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './webhook-logger-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/notifications/webhook-logger/enums/webhook-logger-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum WebhookLoggerJobNames { 2 | sendWebhook = 'sendWebhook', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/notifications/webhook-logger/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './webhook-logger.service'; 3 | -------------------------------------------------------------------------------- /src/queue/notifications/webhook-logger/interfaces/base-webhook-logger.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IBaseWebhookLogger { 2 | payload: string; 3 | timestamp: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/queue/notifications/webhook-logger/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './base-webhook-logger.interface'; 2 | -------------------------------------------------------------------------------- /src/queue/record-node-usage/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './record-node-usage-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/record-node-usage/enums/record-node-usage-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum RecordNodeUsageJobNames { 2 | recordNodeUsage = 'recordNodeUsage', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/record-node-usage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './record-node-usage.service'; 3 | -------------------------------------------------------------------------------- /src/queue/record-node-usage/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './record-node-usage.interface'; 2 | -------------------------------------------------------------------------------- /src/queue/record-node-usage/interfaces/record-node-usage.interface.ts: -------------------------------------------------------------------------------- 1 | export interface RecordNodeUsagePayload { 2 | nodeUuid: string; 3 | nodeAddress: string; 4 | nodePort: number | null; 5 | } 6 | -------------------------------------------------------------------------------- /src/queue/record-user-usage/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './record-user-usage-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/record-user-usage/enums/record-user-usage-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum RecordUserUsageJobNames { 2 | recordUserUsage = 'recordUserUsage', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/record-user-usage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './record-user-usage.service'; 3 | -------------------------------------------------------------------------------- /src/queue/record-user-usage/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './record-user-usage.interface'; 2 | -------------------------------------------------------------------------------- /src/queue/record-user-usage/interfaces/record-user-usage.interface.ts: -------------------------------------------------------------------------------- 1 | export interface RecordUserUsagePayload { 2 | nodeUuid: string; 3 | nodeAddress: string; 4 | nodePort: number | null; 5 | consumptionMultiplier: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/queue/reset-user-traffic/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reset-user-traffic-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/reset-user-traffic/enums/reset-user-traffic-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum ResetUserTrafficJobNames { 2 | resetDailyUserTraffic = 'resetDailyUserTraffic', 3 | resetMonthlyUserTraffic = 'resetMonthlyUserTraffic', 4 | resetNoResetUserTraffic = 'resetNoResetUserTraffic', 5 | resetWeeklyUserTraffic = 'resetWeeklyUserTraffic', 6 | } 7 | -------------------------------------------------------------------------------- /src/queue/reset-user-traffic/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './reset-user-traffic.service'; 3 | -------------------------------------------------------------------------------- /src/queue/start-all-nodes/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './start-all-nodes-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/start-all-nodes/enums/start-all-nodes-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum StartAllNodesJobNames { 2 | startAllNodes = 'startAllNodes', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/start-all-nodes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './start-all-nodes.service'; 3 | -------------------------------------------------------------------------------- /src/queue/start-node/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './start-node-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/start-node/enums/start-node-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum StartNodeJobNames { 2 | startNode = 'startNode', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/start-node/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './start-node.service'; 3 | -------------------------------------------------------------------------------- /src/queue/stop-node/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './stop-node-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/stop-node/enums/stop-node-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum StopNodeJobNames { 2 | stopNode = 'stopNode', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/stop-node/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './stop-node.service'; 3 | -------------------------------------------------------------------------------- /src/queue/update-users-usage/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './update-users-usage-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/update-users-usage/enums/update-users-usage-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum UpdateUsersUsageJobNames { 2 | UpdateUsersUsage = 'updateUsersUsage', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/update-users-usage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './update-users-usage.service'; 3 | -------------------------------------------------------------------------------- /src/queue/user-actions/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './user-actions-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/user-actions/enums/user-actions-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum UserActionsJobNames { 2 | bulkDeleteByStatus = 'bulkDeleteByStatus', 3 | } 4 | -------------------------------------------------------------------------------- /src/queue/user-actions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './user-actions.service'; 3 | -------------------------------------------------------------------------------- /src/queue/user-jobs/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './user-jobs-job-names.enum'; 2 | -------------------------------------------------------------------------------- /src/queue/user-jobs/enums/user-jobs-job-names.enum.ts: -------------------------------------------------------------------------------- 1 | export enum UserJobsJobNames { 2 | findExceededUsers = 'findExceededUsers', 3 | findExpiredUsers = 'findExpiredUsers', 4 | findUsersForThresholdNotification = 'findUsersForThresholdNotification', 5 | } 6 | -------------------------------------------------------------------------------- /src/queue/user-jobs/index.ts: -------------------------------------------------------------------------------- 1 | export * from './enums'; 2 | export * from './user-jobs.service'; 3 | -------------------------------------------------------------------------------- /src/scheduler/enqueue/node-health-check/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/scheduler/enqueue/node-health-check/index.ts -------------------------------------------------------------------------------- /src/scheduler/enqueue/record-nodes-usage/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/scheduler/enqueue/record-nodes-usage/index.ts -------------------------------------------------------------------------------- /src/scheduler/enqueue/record-user-usage/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/scheduler/enqueue/record-user-usage/index.ts -------------------------------------------------------------------------------- /src/scheduler/enqueue/reset-user-traffic-jobs/index.ts: -------------------------------------------------------------------------------- 1 | import { ResetUserTrafficCalendarMonthTask } from './reset-user-traffic-month'; 2 | import { ResetUserTrafficCalendarWeekTask } from './reset-user-traffic-week'; 3 | import { ResetUserTrafficCalendarDayTask } from './reset-user-traffic-day'; 4 | 5 | export const RESET_USER_TRAFFIC_TASKS = [ 6 | ResetUserTrafficCalendarMonthTask, 7 | ResetUserTrafficCalendarWeekTask, 8 | ResetUserTrafficCalendarDayTask, 9 | ]; 10 | -------------------------------------------------------------------------------- /src/scheduler/enqueue/reset-user-traffic-jobs/reset-user-traffic-day/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reset-user-traffic-day.task'; 2 | -------------------------------------------------------------------------------- /src/scheduler/enqueue/reset-user-traffic-jobs/reset-user-traffic-month/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reset-user-traffic-month.task'; 2 | -------------------------------------------------------------------------------- /src/scheduler/enqueue/reset-user-traffic-jobs/reset-user-traffic-week/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reset-user-traffic-week.task'; 2 | -------------------------------------------------------------------------------- /src/scheduler/enqueue/users-jobs/find-exceeded-usage-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './find-exceeded-usage-users.task'; 2 | -------------------------------------------------------------------------------- /src/scheduler/enqueue/users-jobs/find-expired-users/index.ts: -------------------------------------------------------------------------------- 1 | export * from './find-expired-users.task'; 2 | -------------------------------------------------------------------------------- /src/scheduler/enqueue/users-jobs/find-users-for-expire-notifications/index.ts: -------------------------------------------------------------------------------- 1 | export * from './find-users-for-expire-notifications.task'; 2 | -------------------------------------------------------------------------------- /src/scheduler/enqueue/users-jobs/find-users-for-threshold-notification/index.ts: -------------------------------------------------------------------------------- 1 | export * from './find-users-for-threshold-notification.task'; 2 | -------------------------------------------------------------------------------- /src/scheduler/tasks/index.ts: -------------------------------------------------------------------------------- 1 | import { ResetNodeTrafficTask } from './reset-node-traffic/reset-node-traffic.service'; 2 | import { ExportMetricsTask } from './export-metrics/export-metrics.task'; 3 | import { ReviewNodesTask } from './review-nodes/review-nodes.task'; 4 | 5 | export const JOBS_SERVICES = [ResetNodeTrafficTask, ReviewNodesTask, ExportMetricsTask]; 6 | -------------------------------------------------------------------------------- /src/scheduler/tasks/reset-node-traffic/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/scheduler/tasks/reset-node-traffic/index.ts -------------------------------------------------------------------------------- /src/scheduler/tasks/review-nodes/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remnawave/backend/fac1c811a4aa3dc3340bcd40ea9e709da56d942e/src/scheduler/tasks/review-nodes/index.ts -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | --------------------------------------------------------------------------------