Skip to content

Commit

Permalink
Configuring for run test
Browse files Browse the repository at this point in the history
  • Loading branch information
sAchin-680 committed Sep 23, 2024
1 parent aa5c39c commit d9ce454
Show file tree
Hide file tree
Showing 4 changed files with 11,080 additions and 2,492 deletions.
14 changes: 13 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const cookieParser = require('cookie-parser');
const setupSwagger = require('./swagger');
const compression = require('compression');
const { getProductById } = require('./controllers/productController');

const { getHerokuApps } = require('./herokuApi');
dotenv.config();

const app = express();
Expand All @@ -35,6 +35,18 @@ server.start().then(() => {
server.applyMiddleware({ app });
});

const main = async () => {
try {
const apps = await getHerokuApps(); // Call the function
console.log(apps); // Log the response data
} catch (error) {
console.error('Failed to get Heroku apps:', error);
}
};

// Run the main function
main();

setupSwagger(app);

module.exports = app;
25 changes: 25 additions & 0 deletions herokuApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const axios = require('axios');
require('dotenv').config();

// Function to get apps from Heroku
const getHerokuApps = async () => {
try {
const herokuToken = process.env.HEROKU_API_TOKEN;

const response = await axios.get('https://api.heroku.com/apps', {
headers: {
Authorization: `Bearer ${herokuToken}`,
Accept: 'application/vnd.heroku+json; version=3',
},
});

return response.data;
} catch (error) {
console.error('Error fetching apps from Heroku:', error);
throw error;
}
};

module.exports = {
getHerokuApps,
};
Loading

0 comments on commit d9ce454

Please sign in to comment.