Skip to content

Commit

Permalink
la til botleneck
Browse files Browse the repository at this point in the history
  • Loading branch information
eilifjohansen committed May 22, 2024
1 parent d75f5e3 commit a2cb44e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const axios = require('axios');
const cors = require("cors");
const {config} = require("./config/config");
let app = express();
const Bottleneck = require('bottleneck');
const limiter = new Bottleneck({
minTime: 1000 // 1 request per second
});

app.use(cors())

Expand Down Expand Up @@ -55,11 +59,10 @@ app.get('/amplitude/100000244/api/*', (req, res) => {

// Amplitude Prosjekt: MEMU - prod
app.get('/amplitude/100002286/api/*', (req, res) => {
const requestUrl = req.url.replace(/\/amplitude\/100002286/, '')
const authToken = process.env.AMPLITUDE_100002286
amplitudeProxy(authToken, requestUrl, res)
const requestUrl = req.url.replace(/\/amplitude\/100002286/, '')
const authToken = process.env.AMPLITUDE_100002286
limiter.schedule(() => amplitudeProxy(authToken, requestUrl, res))
});

// Amplitude Prosjekt: Aksel - prod
app.get('/amplitude/100002016/api/*', (req, res) => {
const requestUrl = req.url.replace(/\/amplitude\/100002016/, '')
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"license": "MIT",
"dependencies": {
"axios": "^1.7.2",
"bottleneck": "^2.19.5",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2"
Expand Down

0 comments on commit a2cb44e

Please sign in to comment.