Skip to content

Commit

Permalink
Add caching
Browse files Browse the repository at this point in the history
  • Loading branch information
smikulcik committed Jan 29, 2018
1 parent c34388d commit 94c0fa7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules/
.tern-project
*.mca

5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ var colors=require("colors")
var anvil = new Anvil(".");

var express = require('express')
var apicache = require('apicache')

var app = express()
var cache = apicache.middleware

// var mcColors = {
// "water": colors.bgCyan,
Expand Down Expand Up @@ -160,7 +163,7 @@ function getChunkBlocks(chunk_x, chunk_z){
// });
// }

app.get('/chunks/:chunk_x/:chunk_z', function (req, res) {
app.get('/chunks/:chunk_x/:chunk_z', cache("2 hours"), function (req, res) {
var x = parseInt(req.params.chunk_x);
var z = parseInt(req.params.chunk_z);
console.log("GET /chunks/" + req.params.chunk_x + "/" + req.params.chunk_z )
Expand Down
5 changes: 5 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 @@ -9,6 +9,7 @@
"author": "smikulcik@gmail.com",
"license": "MIT",
"dependencies": {
"apicache": "^1.2.0",
"colors": "^1.1.2",
"express": "^4.16.2",
"minecraft-data": "^2.26.0",
Expand Down

0 comments on commit 94c0fa7

Please sign in to comment.