Skip to content

Commit

Permalink
add logging on requests
Browse files Browse the repository at this point in the history
  • Loading branch information
petertimwalker committed May 24, 2024
1 parent e1edfdd commit 3d219b5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ app.use(cors());
// Store your API key securely in an environment variable
const API_KEY = process.env.API_KEY || 'API_KEY not defined';

// Middleware to log requests to the terminal
app.use((req, res, next) => {
console.log(`${req.method} ${req.url}`);
next();
});

app.get('/', (req, res) => {
console.log(`request from ${req}`);
res.send('Hi from api.peterwalker.xyz');
});

app.get('/api/key', (req, res) => {
console.log(`request from ${req}`);
res.json({ apiKey: API_KEY });
Expand Down

0 comments on commit 3d219b5

Please sign in to comment.