mirror of
https://github.com/NotAShelf/catApi.git
synced 2024-11-26 16:56:49 +00:00
stop hardcoding URLs you idiot
This commit is contained in:
parent
d7c86e1885
commit
9718546526
1 changed files with 4 additions and 2 deletions
6
index.js
6
index.js
|
@ -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,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue