mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	[Server] Fix bug
This commit is contained in:
		
							parent
							
								
									e15de4af4d
								
							
						
					
					
						commit
						9d72ff12b9
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -93,9 +93,12 @@ function send(data: Buffer, type: string, req: express.Request, res: express.Res
 | 
				
			||||||
app.get('/:id', async (req, res): Promise<void> => {
 | 
					app.get('/:id', async (req, res): Promise<void> => {
 | 
				
			||||||
	const file = await File.findOne({_id: new mongodb.ObjectID(req.params.id)});
 | 
						const file = await File.findOne({_id: new mongodb.ObjectID(req.params.id)});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (file === null) {
 | 
						if (file == null) {
 | 
				
			||||||
		res.status(404).sendFile(__dirname + '/resources/dummy.png');
 | 
							res.status(404).sendFile(__dirname + '/resources/dummy.png');
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
						} else if (file.data == null) {
 | 
				
			||||||
 | 
							res.status(400);
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	send(file.data.buffer, file.type, req, res);
 | 
						send(file.data.buffer, file.type, req, res);
 | 
				
			||||||
| 
						 | 
					@ -104,9 +107,12 @@ app.get('/:id', async (req, res): Promise<void> => {
 | 
				
			||||||
app.get('/:id/:name', async (req, res): Promise<void> => {
 | 
					app.get('/:id/:name', async (req, res): Promise<void> => {
 | 
				
			||||||
	const file = await File.findOne({_id: new mongodb.ObjectID(req.params.id)});
 | 
						const file = await File.findOne({_id: new mongodb.ObjectID(req.params.id)});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (file === null) {
 | 
						if (file == null) {
 | 
				
			||||||
		res.status(404).sendFile(__dirname + '/resources/dummy.png');
 | 
							res.status(404).sendFile(__dirname + '/resources/dummy.png');
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
						} else if (file.data == null) {
 | 
				
			||||||
 | 
							res.status(400);
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	send(file.data.buffer, file.type, req, res);
 | 
						send(file.data.buffer, file.type, req, res);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue