1 module konnexengine.app.data; 2 3 import konnexengine.modules.blueprint; 4 import vibe.data.json : Json; 5 6 struct UIData 7 { 8 string name; 9 string page; 10 string komponent = "home"; 11 12 bool[string] auth; 13 } 14 15 struct ContentData 16 { 17 Json videos; 18 Json currentVideo; 19 } 20 21 struct UserData 22 { 23 string _id; 24 string accessToken; 25 string username; 26 string email; 27 } 28 29 struct Data 30 { 31 auto ui = UIData(); 32 auto content = ContentData(); 33 auto user = UserData(); 34 } 35 36 /// AppDataInterface `interface` 37 interface AppDataInterface 38 { 39 40 } 41 42 /// AppData `struct` 43 struct AppData 44 { 45 string name = ""; 46 string namespace = ""; 47 string accessToken = ""; 48 string refreshToken = ""; 49 string page = ""; 50 string komponent = "home"; 51 string username = ""; 52 Json videos = Json(""); 53 Json currentVideo = Json(""); 54 string msg = ""; 55 string currentUser = ""; 56 } 57 /// 58 // unittest 59 // { 60 // import fastjwt.jwt; 61 // import vibe.data.json : Json; 62 63 // auto data = AppData("Test App", "Test Module", "token", "refreshToken", 64 // "crowdfunding", "user1", Json(""), Json("")); 65 66 // assert(is(typeof(data) == AppData)); 67 // assert(is(typeof(data.name) == string)); 68 // assert(is(typeof(data.namespace) == string)); 69 // assert(is(typeof(data.accessToken) == string)); 70 // assert(is(typeof(data.refreshToken) == string)); 71 // assert(is(typeof(data.page) == string)); 72 // assert(is(typeof(data.username) == string)); 73 // assert(is(typeof(data.videos) == Json)); 74 // assert(is(typeof(data.currentVideo) == Json)); 75 // assert(data.name == "Test App"); 76 // assert(data.namespace == "Test Module"); 77 // assert(data.accessToken == "token"); 78 // assert(data.refreshToken == "refreshToken"); 79 // assert(data.page == "crowdfunding"); 80 // assert(data.username == "user1"); 81 // assert(data.videos == Json("")); 82 // // assert(data.currentVideo == "vky56f6uykty"); 83 84 // } 85 86 /// AuthState `struct` 87 struct AuthState 88 { 89 /// signuo - `bool` 90 bool signup = false; 91 /// passwordRequired - `bool` 92 bool passwordRequired = false; 93 /// login - `bool` 94 bool login = false; 95 /// success - `bool` 96 bool success = false; 97 /// valid - `bool` 98 bool valid = false; 99 } 100 /// 101 unittest 102 { 103 auto state = AuthState(); 104 assert(is(typeof(state) == AuthState)); 105 assert(is(typeof(state.signup) == bool)); 106 assert(is(typeof(state.passwordRequired) == bool)); 107 assert(is(typeof(state.success) == bool)); 108 assert(is(typeof(state.login) == bool)); 109 assert(is(typeof(state.valid) == bool)); 110 assert(state.signup == false); 111 assert(state.passwordRequired == false); 112 assert(state.success == false); 113 assert(state.login == false); 114 assert(state.valid == false); 115 }