fix: microorm: metedataerror & err module not found
This commit is contained in:
		
							parent
							
								
									44a433e8c9
								
							
						
					
					
						commit
						66587a36bf
					
				
					 3 changed files with 34 additions and 8 deletions
				
			
		|  | @ -1,6 +1,6 @@ | ||||||
| import { Entity, Enum, ManyToOne } from '@mikro-orm/core'; | import { Entity, Enum, ManyToOne } from '@mikro-orm/core'; | ||||||
| import { Student } from '../users/student.entity'; | import { Student } from '../users/student.entity.js'; | ||||||
| import { Class } from './class.entity'; | import { Class } from './class.entity.js'; | ||||||
| 
 | 
 | ||||||
| @Entity() | @Entity() | ||||||
| export class ClassJoinRequest { | export class ClassJoinRequest { | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'; | import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'; | ||||||
| import { Question } from './question.entity'; | import { Question } from './question.entity.js'; | ||||||
| import { Teacher } from '../users/teacher.entity'; | import { Teacher } from '../users/teacher.entity.js'; | ||||||
| 
 | 
 | ||||||
| @Entity() | @Entity() | ||||||
| export class Answer { | export class Answer { | ||||||
|  |  | ||||||
|  | @ -3,15 +3,41 @@ import { PostgreSqlDriver } from '@mikro-orm/postgresql'; | ||||||
| import { EnvVars, getEnvVar, getNumericEnvVar } from './util/envvars.js'; | import { EnvVars, getEnvVar, getNumericEnvVar } from './util/envvars.js'; | ||||||
| import { SqliteDriver } from '@mikro-orm/sqlite'; | import { SqliteDriver } from '@mikro-orm/sqlite'; | ||||||
| 
 | 
 | ||||||
| const entities = ['dist/**/*.entity.js']; | // Import alle entity-bestanden handmatig
 | ||||||
| const entitiesTs = ['src/**/*.entity.ts']; | import { User } from './entities/users/user.entity.js'; | ||||||
|  | import { Student } from './entities/users/student.entity.js'; | ||||||
|  | import { Teacher } from './entities/users/teacher.entity.js'; | ||||||
|  | 
 | ||||||
|  | import { Assignment } from './entities/assignments/assignment.entity.js'; | ||||||
|  | import { Group } from './entities/assignments/group.entity.js'; | ||||||
|  | import { Submission } from './entities/assignments/submission.entity.js'; | ||||||
|  | 
 | ||||||
|  | import { Class } from './entities/classes/class.entity.js'; | ||||||
|  | import { ClassJoinRequest } from './entities/classes/class-join-request.entity.js'; | ||||||
|  | import { TeacherInvitation } from './entities/classes/teacher-invitation.entity.js'; | ||||||
|  | 
 | ||||||
|  | import { Attachment } from './entities/content/attachment.entity.js'; | ||||||
|  | import { LearningObject } from './entities/content/learning-object.entity.js'; | ||||||
|  | import { LearningPath } from './entities/content/learning-path.entity.js'; | ||||||
|  | 
 | ||||||
|  | import { Answer } from './entities/questions/answer.entity.js'; | ||||||
|  | import { Question } from './entities/questions/question.entity.js'; | ||||||
|  | 
 | ||||||
|  | const entities = [ | ||||||
|  |     User, Student, Teacher, | ||||||
|  |     Assignment, Group, Submission, | ||||||
|  |     Class, ClassJoinRequest, TeacherInvitation, | ||||||
|  |     Attachment, LearningObject, LearningPath, | ||||||
|  |     Answer, Question | ||||||
|  | ]; | ||||||
|  | 
 | ||||||
| function config(testingMode: boolean = false): Options { | function config(testingMode: boolean = false): Options { | ||||||
|     if (testingMode) { |     if (testingMode) { | ||||||
|         return { |         return { | ||||||
|             driver: SqliteDriver, |             driver: SqliteDriver, | ||||||
|             dbName: getEnvVar(EnvVars.DbName), |             dbName: getEnvVar(EnvVars.DbName), | ||||||
|             entities: entities, |             entities: entities, | ||||||
|             entitiesTs: entitiesTs, |             // entitiesTs: entitiesTs,
 | ||||||
| 
 | 
 | ||||||
|             // Workaround: vitest: `TypeError: Unknown file extension ".ts"` (ERR_UNKNOWN_FILE_EXTENSION)
 |             // Workaround: vitest: `TypeError: Unknown file extension ".ts"` (ERR_UNKNOWN_FILE_EXTENSION)
 | ||||||
|             // (see https://mikro-orm.io/docs/guide/project-setup#testing-the-endpoint)
 |             // (see https://mikro-orm.io/docs/guide/project-setup#testing-the-endpoint)
 | ||||||
|  | @ -26,7 +52,7 @@ function config(testingMode: boolean = false): Options { | ||||||
|             user: getEnvVar(EnvVars.DbUsername), |             user: getEnvVar(EnvVars.DbUsername), | ||||||
|             password: getEnvVar(EnvVars.DbPassword), |             password: getEnvVar(EnvVars.DbPassword), | ||||||
|             entities: entities, |             entities: entities, | ||||||
|             entitiesTs: entitiesTs, |             //entitiesTs: entitiesTs,
 | ||||||
|             debug: true, |             debug: true, | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl