Merge branch 'feat/endpoints-in-backend-om-eigen-leerpaden-en-leerobjecten-toe-te-voegen-aan-de-databank-#248' of https://github.com/SELab-2/Dwengo-1 into feat/endpoints-in-backend-om-eigen-leerpaden-en-leerobjecten-toe-te-voegen-aan-de-databank-#248
This commit is contained in:
		
						commit
						211ddaed75
					
				
					 5 changed files with 17 additions and 19 deletions
				
			
		|  | @ -1,8 +1,8 @@ | ||||||
| import { Language } from '@dwengo-1/common/util/language'; | import { Language } from '@dwengo-1/common/util/language'; | ||||||
| import learningObjectService from '../../../services/learning-objects/learning-object-service'; | import learningObjectService from '../../../services/learning-objects/learning-object-service.js'; | ||||||
| import { authorize } from '../auth'; | import { authorize } from '../auth.js'; | ||||||
| import { AuthenticatedRequest } from '../authenticated-request'; | import { AuthenticatedRequest } from '../authenticated-request.js'; | ||||||
| import { AuthenticationInfo } from '../authentication-info'; | import { AuthenticationInfo } from '../authentication-info.js'; | ||||||
| 
 | 
 | ||||||
| export const onlyAdminsForLearningObject = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => { | export const onlyAdminsForLearningObject = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => { | ||||||
|     const { hruid } = req.params; |     const { hruid } = req.params; | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| import { Language } from '@dwengo-1/common/util/language'; | import { Language } from '@dwengo-1/common/util/language'; | ||||||
| import learningPathService from '../../../services/learning-paths/learning-path-service'; | import learningPathService from '../../../services/learning-paths/learning-path-service.js'; | ||||||
| import { authorize } from '../auth'; | import { authorize } from '../auth.js'; | ||||||
| import { AuthenticatedRequest } from '../authenticated-request'; | import { AuthenticatedRequest } from '../authenticated-request.js'; | ||||||
| import { AuthenticationInfo } from '../authentication-info'; | import { AuthenticationInfo } from '../authentication-info.js'; | ||||||
| 
 | 
 | ||||||
| export const onlyAdminsForLearningPath = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => { | export const onlyAdminsForLearningPath = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => { | ||||||
|     const adminsForLearningPath = await learningPathService.getAdmins({ |     const adminsForLearningPath = await learningPathService.getAdmins({ | ||||||
|  |  | ||||||
|  | @ -116,10 +116,8 @@ const databaseLearningObjectProvider: LearningObjectProvider = { | ||||||
|     async getLearningObjectsAdministratedBy(adminUsername: string): Promise<FilteredLearningObject[]> { |     async getLearningObjectsAdministratedBy(adminUsername: string): Promise<FilteredLearningObject[]> { | ||||||
|         const learningObjectRepo = getLearningObjectRepository(); |         const learningObjectRepo = getLearningObjectRepository(); | ||||||
|         const learningObjects = await learningObjectRepo.findAllByAdmin(adminUsername); |         const learningObjects = await learningObjectRepo.findAllByAdmin(adminUsername); | ||||||
|         return learningObjects |         return learningObjects.map((it) => convertLearningObject(it)).filter((it) => it !== null); | ||||||
|                 .map(it => convertLearningObject(it)) |     }, | ||||||
|                 .filter(it => it !== null); |  | ||||||
|     } |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export default databaseLearningObjectProvider; | export default databaseLearningObjectProvider; | ||||||
|  |  | ||||||
|  | @ -3,9 +3,9 @@ import { LearningObjectProvider } from './learning-object-provider.js'; | ||||||
| import { envVars, getEnvVar } from '../../util/envVars.js'; | import { envVars, getEnvVar } from '../../util/envVars.js'; | ||||||
| import databaseLearningObjectProvider from './database-learning-object-provider.js'; | import databaseLearningObjectProvider from './database-learning-object-provider.js'; | ||||||
| import { FilteredLearningObject, LearningObjectIdentifierDTO, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | import { FilteredLearningObject, LearningObjectIdentifierDTO, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||||
| import { getLearningObjectRepository, getTeacherRepository } from '../../data/repositories'; | import { getLearningObjectRepository, getTeacherRepository } from '../../data/repositories.js'; | ||||||
| import { processLearningObjectZip } from './learning-object-zip-processing-service'; | import { processLearningObjectZip } from './learning-object-zip-processing-service.js'; | ||||||
| import { LearningObject } from '../../entities/content/learning-object.entity'; | import { LearningObject } from '../../entities/content/learning-object.entity.js'; | ||||||
| import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier.js'; | import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier.js'; | ||||||
| import { NotFoundException } from '../../exceptions/not-found-exception.js'; | import { NotFoundException } from '../../exceptions/not-found-exception.js'; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,10 +1,10 @@ | ||||||
| import unzipper from 'unzipper'; | import unzipper from 'unzipper'; | ||||||
| import mime from 'mime-types'; | import mime from 'mime-types'; | ||||||
| import { LearningObject } from '../../entities/content/learning-object.entity'; | import { LearningObject } from '../../entities/content/learning-object.entity.js'; | ||||||
| import { getAttachmentRepository, getLearningObjectRepository } from '../../data/repositories'; | import { getAttachmentRepository, getLearningObjectRepository } from '../../data/repositories.js'; | ||||||
| import { BadRequestException } from '../../exceptions/bad-request-exception'; | import { BadRequestException } from '../../exceptions/bad-request-exception.js'; | ||||||
| import { LearningObjectMetadata } from '@dwengo-1/common/interfaces/learning-content'; | import { LearningObjectMetadata } from '@dwengo-1/common/interfaces/learning-content'; | ||||||
| import { DwengoContentType } from './processing/content-type'; | import { DwengoContentType } from './processing/content-type.js'; | ||||||
| 
 | 
 | ||||||
| const METADATA_PATH_REGEX = /.*[/^]metadata\.json$/; | const METADATA_PATH_REGEX = /.*[/^]metadata\.json$/; | ||||||
| const CONTENT_PATH_REGEX = /.*[/^]content\.[a-zA-Z]*$/; | const CONTENT_PATH_REGEX = /.*[/^]content\.[a-zA-Z]*$/; | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger