-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
server.js
executable file
·44 lines (38 loc) · 1.55 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
import express from 'express'
import cors from 'cors'
import 'dotenv/config'
import serverless from './serverless.js'
import requestIp from 'request-ip'
import rateLimit from 'express-rate-limit'
import swStats from 'swagger-stats'
import addonInterface from "./addon.js"
const app = express()
app.enable('trust proxy')
app.use(cors())
app.use(swStats.getMiddleware({
name: addonInterface.manifest.name,
version: addonInterface.manifest.version,
timelineBucketDuration: 60 * 60 * 1000,
apdexThreshold: 2000,
authentication: true,
onAuthenticate: (req, username, password) => {
return ((username === process.env.SWAGGER_USER
&& (password === process.env.SWAGGER_PASSWORD)))
},
}))
const rateLimiter = rateLimit({
windowMs: 60 * 60 * 1000, // 1 hours
limit: 300, // Limit each IP to 300 requests per window
standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
legacyHeaders: false, // Disable the `X-RateLimit-*` headers
keyGenerator: (req) => requestIp.getClientIp(req)
})
app.use(rateLimiter)
app.use((req, res, next) => serverless(req, res, next))
app.listen(process.env.PORT || 55771, () => {
console.log(`Started addon at: http://127.0.0.1:${process.env.PORT || 55771}`)
})
// https://stremio.github.io/stremio-publish-addon/index.html
// publishToCentral("https://68d69db7dc40-stremio-addon-debrid-search.baby-beamup.club/manifest.json")
// for more information on deploying, see: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/deploying/README.md