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