github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/cmd/server/container/container.go (about) 1 // This file is part of the Smart Home 2 // Program complex distribution https://github.com/e154/smart-home 3 // Copyright (C) 2016-2023, Filippov Alex 4 // 5 // This library is free software: you can redistribute it and/or 6 // modify it under the terms of the GNU Lesser General Public 7 // License as published by the Free Software Foundation; either 8 // version 3 of the License, or (at your option) any later version. 9 // 10 // This library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 // Library General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public 16 // License along with this library. If not, see 17 // <https://www.gnu.org/licenses/>. 18 19 package container 20 21 import ( 22 "github.com/e154/smart-home/adaptors" 23 "github.com/e154/smart-home/api" 24 "github.com/e154/smart-home/api/controllers" 25 "github.com/e154/smart-home/common/web" 26 "github.com/e154/smart-home/endpoint" 27 "github.com/e154/smart-home/system/access_list" 28 "github.com/e154/smart-home/system/automation" 29 "github.com/e154/smart-home/system/backup" 30 "github.com/e154/smart-home/system/bus" 31 "github.com/e154/smart-home/system/gate/client" 32 "github.com/e154/smart-home/system/initial" 33 localMigrations "github.com/e154/smart-home/system/initial/local_migrations" 34 "github.com/e154/smart-home/system/jwt_manager" 35 "github.com/e154/smart-home/system/logging" 36 "github.com/e154/smart-home/system/logging_db" 37 "github.com/e154/smart-home/system/logging_ws" 38 "github.com/e154/smart-home/system/media" 39 "github.com/e154/smart-home/system/migrations" 40 "github.com/e154/smart-home/system/mqtt" 41 "github.com/e154/smart-home/system/mqtt_authenticator" 42 "github.com/e154/smart-home/system/orm" 43 "github.com/e154/smart-home/system/rbac" 44 "github.com/e154/smart-home/system/scheduler" 45 "github.com/e154/smart-home/system/scripts" 46 "github.com/e154/smart-home/system/storage" 47 "github.com/e154/smart-home/system/stream" 48 "github.com/e154/smart-home/system/stream/handlers" 49 "github.com/e154/smart-home/system/supervisor" 50 "github.com/e154/smart-home/system/terminal" 51 "github.com/e154/smart-home/system/validation" 52 "github.com/e154/smart-home/system/zigbee2mqtt" 53 "go.uber.org/fx" 54 ) 55 56 // BuildContainer ... 57 func BuildContainer(opt fx.Option) (app *fx.App) { 58 59 app = fx.New( 60 fx.Provide( 61 ReadConfig, 62 validation.NewValidate, 63 NewOrmConfig, 64 bus.NewBus, 65 orm.NewOrm, 66 backup.NewBackup, 67 NewMigrationsConfig, 68 migrations.NewMigrations, 69 web.New, 70 adaptors.NewAdaptors, 71 scheduler.NewScheduler, 72 NewLoggerConfig, 73 logging.NewLogger, 74 logging_db.NewLogDbSaver, 75 logging_ws.NewLogWsSaver, 76 terminal.GetTerminalCommands, 77 terminal.NewTerminal, 78 scripts.NewScriptService, 79 MigrationList, 80 localMigrations.NewMigrations, 81 NewDemo, 82 media.NewMedia, 83 initial.NewInitial, 84 NewMqttConfig, 85 mqtt_authenticator.NewAuthenticator, 86 mqtt.NewMqtt, 87 access_list.NewAccessListService, 88 rbac.NewEchoAccessFilter, 89 NewZigbee2mqttConfig, 90 zigbee2mqtt.NewZigbee2mqtt, 91 storage.NewStorage, 92 supervisor.NewSupervisor, 93 automation.NewAutomation, 94 endpoint.NewCommonEndpoint, 95 endpoint.NewEndpoint, 96 NewApiConfig, 97 api.NewApi, 98 controllers.NewControllers, 99 stream.NewStreamService, 100 handlers.NewEventHandler, 101 NewBackupConfig, 102 client.NewGateClient, 103 jwt_manager.NewJwtManager, 104 ), 105 fx.Logger(NewPrinter()), 106 opt, 107 ) 108 109 return 110 }