Create index.ts
This commit is contained in:
		
							parent
							
								
									d8f22c6819
								
							
						
					
					
						commit
						e1d06e35ef
					
				
							
								
								
									
										15
									
								
								src/routes/users/#id/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/routes/users/#id/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | |||||||
|  | import { Router, Request, Response } from "express"; | ||||||
|  | import { UserModel } from "@fosscord/server-util"; | ||||||
|  | import { HTTPError } from "lambert-server"; | ||||||
|  | 
 | ||||||
|  | const router: Router = Router(); | ||||||
|  | 
 | ||||||
|  | router.get("/", async (req: Request, res: Response) => { | ||||||
|  | 	const { id } = req.params; | ||||||
|  | 	const user = await UserModel.findOne({ id: id }).exec(); | ||||||
|  | 	if (!user) throw new HTTPError("User not found", 404); | ||||||
|  | 
 | ||||||
|  | 	res.json(user); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export default router; | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Intevel ツ
						Intevel ツ