mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 15:34:13 +00:00 
			
		
		
		
	refactor(server): fix type errors
This commit is contained in:
		
							parent
							
								
									8cab16c824
								
							
						
					
					
						commit
						520ed8cb4d
					
				
					 2 changed files with 24 additions and 12 deletions
				
			
		| 
						 | 
					@ -77,10 +77,16 @@ export class AntennaService implements OnApplicationShutdown {
 | 
				
			||||||
			const { type, body } = obj.message as StreamMessages['internal']['payload'];
 | 
								const { type, body } = obj.message as StreamMessages['internal']['payload'];
 | 
				
			||||||
			switch (type) {
 | 
								switch (type) {
 | 
				
			||||||
				case 'antennaCreated':
 | 
									case 'antennaCreated':
 | 
				
			||||||
					this.antennas.push(body);
 | 
										this.antennas.push({
 | 
				
			||||||
 | 
											...body,
 | 
				
			||||||
 | 
											createdAt: new Date(body.createdAt),
 | 
				
			||||||
 | 
										});
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				case 'antennaUpdated':
 | 
									case 'antennaUpdated':
 | 
				
			||||||
					this.antennas[this.antennas.findIndex(a => a.id === body.id)] = body;
 | 
										this.antennas[this.antennas.findIndex(a => a.id === body.id)] = {
 | 
				
			||||||
 | 
											...body,
 | 
				
			||||||
 | 
											createdAt: new Date(body.createdAt),
 | 
				
			||||||
 | 
										};
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				case 'antennaDeleted':
 | 
									case 'antennaDeleted':
 | 
				
			||||||
					this.antennas = this.antennas.filter(a => a.id !== body.id);
 | 
										this.antennas = this.antennas.filter(a => a.id !== body.id);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,10 +91,12 @@ export class RoleService implements OnApplicationShutdown {
 | 
				
			||||||
				case 'roleCreated': {
 | 
									case 'roleCreated': {
 | 
				
			||||||
					const cached = this.rolesCache.get(null);
 | 
										const cached = this.rolesCache.get(null);
 | 
				
			||||||
					if (cached) {
 | 
										if (cached) {
 | 
				
			||||||
						body.createdAt = new Date(body.createdAt);
 | 
											cached.push({
 | 
				
			||||||
						body.updatedAt = new Date(body.updatedAt);
 | 
												...body,
 | 
				
			||||||
						body.lastUsedAt = new Date(body.lastUsedAt);
 | 
												createdAt: new Date(body.createdAt),
 | 
				
			||||||
						cached.push(body);
 | 
												updatedAt: new Date(body.updatedAt),
 | 
				
			||||||
 | 
												lastUsedAt: new Date(body.lastUsedAt),
 | 
				
			||||||
 | 
											});
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -103,10 +105,12 @@ export class RoleService implements OnApplicationShutdown {
 | 
				
			||||||
					if (cached) {
 | 
										if (cached) {
 | 
				
			||||||
						const i = cached.findIndex(x => x.id === body.id);
 | 
											const i = cached.findIndex(x => x.id === body.id);
 | 
				
			||||||
						if (i > -1) {
 | 
											if (i > -1) {
 | 
				
			||||||
							body.createdAt = new Date(body.createdAt);
 | 
												cached[i] = {
 | 
				
			||||||
							body.updatedAt = new Date(body.updatedAt);
 | 
													...body,
 | 
				
			||||||
							body.lastUsedAt = new Date(body.lastUsedAt);
 | 
													createdAt: new Date(body.createdAt),
 | 
				
			||||||
							cached[i] = body;
 | 
													updatedAt: new Date(body.updatedAt),
 | 
				
			||||||
 | 
													lastUsedAt: new Date(body.lastUsedAt),
 | 
				
			||||||
 | 
												};
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
| 
						 | 
					@ -121,8 +125,10 @@ export class RoleService implements OnApplicationShutdown {
 | 
				
			||||||
				case 'userRoleAssigned': {
 | 
									case 'userRoleAssigned': {
 | 
				
			||||||
					const cached = this.roleAssignmentByUserIdCache.get(body.userId);
 | 
										const cached = this.roleAssignmentByUserIdCache.get(body.userId);
 | 
				
			||||||
					if (cached) {
 | 
										if (cached) {
 | 
				
			||||||
						body.createdAt = new Date(body.createdAt);
 | 
											cached.push({
 | 
				
			||||||
						cached.push(body);
 | 
												...body,
 | 
				
			||||||
 | 
												createdAt: new Date(body.createdAt),
 | 
				
			||||||
 | 
											});
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue