fix(server/utils): add isIdNan helper function
				
					
				
			This commit is contained in:
		
							parent
							
								
									be32464c93
								
							
						
					
					
						commit
						9ba432a8e0
					
				
							
								
								
									
										12
									
								
								lib/server/middlewareButNotReally/isIdNan.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								lib/server/middlewareButNotReally/isIdNan.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
import { EventHandlerRequest, H3Event } from "h3";
 | 
			
		||||
 | 
			
		||||
export default function (ev: H3Event<EventHandlerRequest>) {
 | 
			
		||||
	const id = parseInt(getRouterParam(ev, "id")!);
 | 
			
		||||
	if (Number.isNaN(id)) {
 | 
			
		||||
		throw createError({
 | 
			
		||||
			statusCode: 400,
 | 
			
		||||
			message: "Invalid id provided.",
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
	return id;
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user