Skip to content

Commit

Permalink
v1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeBild committed Sep 29, 2016
1 parent f7ff88a commit 2242b25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#### 1.1.3 - 09/29/16

* increase JSON limit to 5MB
* recognize document base64 content type

#### 1.1.0 - 08/29/16

* combining routes for functions and statics
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-pouch",
"version": "1.1.2",
"version": "1.1.3",
"description": "GraphQL-API runtime on top of PouchDB",
"author": "Mike Bild <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -48,6 +48,7 @@
"node-fetch": "^1.6.0",
"node-uuid": "^1.4.7",
"paint-console": "0.0.1",
"parse-data-url": "^0.1.2",
"pouchdb": "^5.4.5",
"pouchdb-find": "^0.10.2",
"response-time": "^2.3.1",
Expand Down
11 changes: 10 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const expressFavicon = require('serve-favicon');
const expressResponseTime = require('response-time');
const expressJWT = require('express-jwt');
const expressGraphQL = require('express-graphql');
const parseDataUrl = require('parse-data-url');
const logout = require('./logout')();

const graphqlPouch = require('./lib/pouch-graphql');
Expand All @@ -21,7 +22,7 @@ const functions = require('./lib/functions');
const app = express();
app.disable('x-powered-by');
app.use(expressResponseTime());
app.use(expressBodyParser.json());
app.use(expressBodyParser.json({limit: '5mb'}));
app.use(expressCors());
app.use(expressFavicon(path.join(__dirname, 'favicon.ico')));
app.get('/_status', (req, res, next) => res.status(200).send({memMB: Math.floor((process.memoryUsage().rss / 1048576))}));
Expand Down Expand Up @@ -77,6 +78,14 @@ app.all('/*', checkOptionalJWT, (req, res, next) => {
}))
.then(data => {
if(!data.content) return res.sendStatus(404);

const parsed = parseDataUrl(data.content);
if(parsed){
res.type(parsed.mediaType);
res.send(parsed.toBuffer());
return;
}

res.type(docid);
res.send(data.content);
})
Expand Down

0 comments on commit 2242b25

Please sign in to comment.