Starting to add ability to make admin API requests
							parent
							
								
									948ff11030
								
							
						
					
					
						commit
						ca7043be2a
					
				|  | @ -1,5 +1,5 @@ | |||
| node_modules/ | ||||
| data/ | ||||
| /config/settings-local.json | ||||
| /config/*-local.json | ||||
| .vscode | ||||
| **.DS_Store | ||||
|  |  | |||
							
								
								
									
										2
									
								
								app.js
								
								
								
								
							
							
						
						
									
										2
									
								
								app.js
								
								
								
								
							|  | @ -252,11 +252,11 @@ app.use((req, res, next) => { | |||
| 
 | ||||
| // update config when modified
 | ||||
| app.use((req, res, next) => { | ||||
|     next(); | ||||
|     if(res.configDirty){ | ||||
|         config = common.getConfig(); | ||||
|         app.config = config; | ||||
|     } | ||||
|     next(); | ||||
| }); | ||||
| 
 | ||||
| // Ran on all routes
 | ||||
|  |  | |||
|  | @ -11,7 +11,15 @@ router.get('/admin/orders', common.restrict, (req, res, next) => { | |||
|         if(err){ | ||||
|             console.info(err.stack); | ||||
|         } | ||||
|         res.render('orders', { | ||||
| 
 | ||||
|         // If API request, return json
 | ||||
|         if(req.apiAuthenticated){ | ||||
|             return res.status(200).json({ | ||||
|                 orders | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         return res.render('orders', { | ||||
|             title: 'Cart', | ||||
|             orders: orders, | ||||
|             admin: true, | ||||
|  | @ -39,7 +47,15 @@ router.get('/admin/orders/bystatus/:orderstatus', common.restrict, (req, res, ne | |||
|         if(err){ | ||||
|             console.info(err.stack); | ||||
|         } | ||||
|         res.render('orders', { | ||||
| 
 | ||||
|         // If API request, return json
 | ||||
|         if(req.apiAuthenticated){ | ||||
|             return res.status(200).json({ | ||||
|                 orders | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         return res.render('orders', { | ||||
|             title: 'Cart', | ||||
|             orders: orders, | ||||
|             admin: true, | ||||
|  | @ -91,7 +107,15 @@ router.get('/admin/orders/filter/:search', common.restrict, (req, res, next) => | |||
|         if(err){ | ||||
|             console.info(err.stack); | ||||
|         } | ||||
|         res.render('orders', { | ||||
| 
 | ||||
|         // If API request, return json
 | ||||
|         if(req.apiAuthenticated){ | ||||
|             return res.status(200).json({ | ||||
|                 orders | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         return res.render('orders', { | ||||
|             title: 'Order results', | ||||
|             orders: orders, | ||||
|             admin: true, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue