feat: update json method in Response interface to accept JSON type
This commit is contained in:
		
							
								
								
									
										2
									
								
								dist/router.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/router.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -18,7 +18,7 @@ export interface Response extends ServerResponse {
 | 
			
		||||
        body: string;
 | 
			
		||||
    }) => void;
 | 
			
		||||
    status: (code: number) => Response;
 | 
			
		||||
    json: (body: string, code?: number) => void;
 | 
			
		||||
    json: (body: JSON, code?: number) => void;
 | 
			
		||||
    html: (body: string, code?: number) => void;
 | 
			
		||||
    redirect: (target: string, code?: number) => void;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -191,7 +191,7 @@ export default class Flummpress {
 | 
			
		||||
      return res.writeHead(code);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    res.json = (body, code = 200) => {
 | 
			
		||||
    res.json = (body: JSON, code = 200) => {
 | 
			
		||||
      res.reply({ code, type: "application/json", body: JSON.stringify(body) });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ export interface Request extends Omit<IncomingMessage, 'url'> {
 | 
			
		||||
export interface Response extends ServerResponse {
 | 
			
		||||
  reply: (options: { code?: number; type?: string; body: string }) => void;
 | 
			
		||||
  status: (code: number) => Response;
 | 
			
		||||
  json: (body: string, code?: number) => void;
 | 
			
		||||
  json: (body: JSON, code?: number) => void;
 | 
			
		||||
  html: (body: string, code?: number) => void;
 | 
			
		||||
  redirect: (target: string, code?: number) => void;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user