mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: convert schemas to typescript
This commit is contained in:
		
							parent
							
								
									dedec5c7d1
								
							
						
					
					
						commit
						ab4744e79b
					
				| @ -1,11 +1,9 @@ | ||||
| 'use strict'; | ||||
| import joi from 'joi'; | ||||
| import { nameType } from '../routes/util'; | ||||
| 
 | ||||
| const joi = require('joi'); | ||||
| const { nameType } = require('../routes/util'); | ||||
| export const nameSchema = joi.object().keys({ name: nameType }); | ||||
| 
 | ||||
| const nameSchema = joi.object().keys({ name: nameType }); | ||||
| 
 | ||||
| const contextSchema = joi | ||||
| export const contextSchema = joi | ||||
|     .object() | ||||
|     .keys({ | ||||
|         name: nameType, | ||||
| @ -19,5 +17,3 @@ const contextSchema = joi | ||||
|         stickiness: joi.boolean().optional().default(false), | ||||
|     }) | ||||
|     .options({ allowUnknown: false, stripUnknown: true }); | ||||
| 
 | ||||
| module.exports = { contextSchema, nameSchema }; | ||||
| @ -1,7 +1,7 @@ | ||||
| const joi = require('joi'); | ||||
| const { nameType } = require('../routes/util'); | ||||
| import joi from 'joi'; | ||||
| import { nameType } from '../routes/util'; | ||||
| 
 | ||||
| const projectSchema = joi | ||||
| export const projectSchema = joi | ||||
|     .object() | ||||
|     .keys({ | ||||
|         id: nameType, | ||||
| @ -9,5 +9,3 @@ const projectSchema = joi | ||||
|         description: joi.string().allow(null).allow('').optional(), | ||||
|     }) | ||||
|     .options({ allowUnknown: false, stripUnknown: true }); | ||||
| 
 | ||||
| module.exports = projectSchema; | ||||
| @ -3,7 +3,7 @@ import { AccessService } from './access-service'; | ||||
| import NameExistsError from '../error/name-exists-error'; | ||||
| import InvalidOperationError from '../error/invalid-operation-error'; | ||||
| import { nameType } from '../routes/util'; | ||||
| import schema from './project-schema'; | ||||
| import { projectSchema} from './project-schema'; | ||||
| import NotFoundError from '../error/notfound-error'; | ||||
| import { | ||||
|     FEATURE_PROJECT_CHANGE, | ||||
| @ -118,7 +118,7 @@ export default class ProjectService { | ||||
|     } | ||||
| 
 | ||||
|     async createProject(newProject: IProject, user: User): Promise<IProject> { | ||||
|         const data = await schema.validateAsync(newProject); | ||||
|         const data = await projectSchema.validateAsync(newProject); | ||||
|         await this.validateUniqueId(data.id); | ||||
| 
 | ||||
|         await this.store.create(data); | ||||
| @ -138,7 +138,7 @@ export default class ProjectService { | ||||
| 
 | ||||
|     async updateProject(updatedProject: IProject, user: User): Promise<void> { | ||||
|         await this.store.get(updatedProject.id); | ||||
|         const project = await schema.validateAsync(updatedProject); | ||||
|         const project = await projectSchema.validateAsync(updatedProject); | ||||
| 
 | ||||
|         await this.store.update(project); | ||||
| 
 | ||||
|  | ||||
| @ -3,7 +3,7 @@ import { featureSchema, featureTagSchema } from '../schema/feature-schema'; | ||||
| import strategySchema from './strategy-schema'; | ||||
| import { tagSchema } from './tag-schema'; | ||||
| import { tagTypeSchema } from './tag-type-schema'; | ||||
| import projectSchema from './project-schema'; | ||||
| import { projectSchema } from './project-schema'; | ||||
| import { nameType } from '../routes/util'; | ||||
| 
 | ||||
| export const featureStrategySchema = joi | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user