stop hardcoding URLs you idiot

This commit is contained in:
NotAShelf 2022-01-24 17:58:43 +03:00
parent d7c86e1885
commit 9718546526
No known key found for this signature in database
GPG key ID: 2E4615E792DA9BAA

View file

@ -5,6 +5,8 @@ const fs = require('fs');
require('dotenv').config(); require('dotenv').config();
const port = process.env.PORT; const port = process.env.PORT;
const customurl = process.env.CUSTOMURL;
app.listen(port, () => { app.listen(port, () => {
console.log('App listening at http://localhost:' + port); console.log('App listening at http://localhost:' + port);
console.log('Godspeed, little fella!'); console.log('Godspeed, little fella!');
@ -46,7 +48,7 @@ app.get('/api/:id', (req, res) => {
if (image) { if (image) {
return res.json({ return res.json({
id: parseInt(req.params.id), id: parseInt(req.params.id),
url: 'https://cat.frozendev.tk' + req.params.id, url: 'https://' + customurl + req.params.id,
}); });
} else { } else {
return res.json({ return res.json({
@ -91,6 +93,6 @@ const getRandomImageApi = () => {
const id = path.substring(0, path.length - 4).split('-')[1]; const id = path.substring(0, path.length - 4).split('-')[1];
return { return {
id: parseInt(id), id: parseInt(id),
url: 'https://cat.frozendev.tk' + id, url: 'https://' + customurl + id,
}; };
}; };