mirror of
				https://github.com/monkeytypegame/monkeytype.git
				synced 2025-11-01 03:39:15 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
	
		
			474 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
	
		
			474 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import ConfigurationClient from "../init/configuration";
 | |
| import { Response, NextFunction } from "express";
 | |
| 
 | |
| async function contextMiddleware(
 | |
|   req: MonkeyTypes.Request,
 | |
|   _res: Response,
 | |
|   next: NextFunction
 | |
| ): Promise<void> {
 | |
|   const configuration = await ConfigurationClient.getCachedConfiguration(true);
 | |
| 
 | |
|   req.ctx = {
 | |
|     configuration,
 | |
|     decodedToken: {
 | |
|       type: "None",
 | |
|       uid: "",
 | |
|       email: "",
 | |
|     },
 | |
|   };
 | |
| 
 | |
|   next();
 | |
| }
 | |
| 
 | |
| export default contextMiddleware;
 |