-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,703 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
# Use the official lightweight Node.js 14 image. | ||
# https://hub.docker.com/_/node | ||
FROM node:16.4-slim | ||
# Create and change to the app directory. | ||
WORKDIR /usr/src/app | ||
|
||
# Copy application dependency manifests to the container image. | ||
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available). | ||
# Copying this first prevents re-running npm install on every code change. | ||
COPY package*.json ./ | ||
|
||
# Install production dependencies. | ||
# If you add a package-lock.json, speed your build by switching to 'npm ci'. | ||
# RUN npm ci --only=production | ||
RUN npm install --only=production | ||
|
||
# Copy local code to the container image. | ||
COPY . ./ | ||
|
||
# Run the web service on container startup. | ||
CMD [ "node", "index.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Riot Games API is rate-limited and needs an authorized API key to access the limited endpoints. This inelegant code allows requests to be cached to a database, avoiding rate-limiting blocks without exposing the API key. | ||
|
||
I am publishing this API source code for transparency reasons only and don't guarantee that it will work in case you want to deploy it yourself. | ||
In case you do, though, you need to include the following environment variables: | ||
"riot_api_key", "DB_CONNECT" | ||
|
||
Riot Games API key can be obtained here (need to request full access key to increase rate-limiting): | ||
https://developer.riotgames.com/ | ||
|
||
"DB_CONNECT" is your MongoDB connection string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const express = require("express"); | ||
const app = express(); | ||
var bodyParser = require("body-parser"); | ||
const mongoose = require("mongoose"); | ||
require("dotenv").config(); | ||
|
||
mongoose.connect(process.env.DB_CONNECT, { useNewUrlParser: true }, () => { | ||
console.log("Connected to the database"); | ||
}); | ||
|
||
// import routes | ||
const riotRoute = require("./routes/Riot"); | ||
|
||
// use routes | ||
app.use("/riot", riotRoute); | ||
|
||
const port = process.env.PORT || 8080; | ||
app.listen(port, () => { | ||
console.log(`nodejs: listening on port ${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const cacheSchema = new mongoose.Schema({ | ||
jsonString: { | ||
type: String, | ||
}, | ||
timeFetched: { | ||
type: Date, | ||
}, | ||
endPoint: { | ||
type: String, | ||
}, | ||
region: { | ||
type: String, | ||
}, | ||
name: { type: String }, | ||
}); | ||
|
||
module.exports = mongoose.model("leagueApiCache", cacheSchema); |
Oops, something went wrong.