Convert backend code to ES modules
Bundling code now with Rollup for its flat bundling and tree shaking support. Front end code still goes through Webpack for browser support.
This commit is contained in:
1 parent
824639976f
commit
1e41c72d60
62 files changed
+718
-898
No files matched your search
@@ -18,12 +18,12 @@
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const url = require("url");
|
||||
const querystring = require("querystring");
|
||||
const mongodb = require("mongodb");
|
||||
const db = require("./db");
|
||||
import url from "url";
|
||||
import querystring from "querystring";
|
||||
import { GridFSBucket } from "mongodb";
|
||||
import * as db from "./db";
|
||||
|
||||
function listener(request, response) {
|
||||
export function listener(request, response) {
|
||||
const urlParts = url.parse(request.url, true);
|
||||
if (request.method === "GET") {
|
||||
const filename = querystring.unescape(urlParts.pathname.substring(1));
|
||||
@@ -45,7 +45,7 @@ function listener(request, response) {
|
||||
"Content-Length": file.length
|
||||
});
|
||||
|
||||
const bucket = new mongodb.GridFSBucket(db.client.db());
|
||||
const bucket = new GridFSBucket(db.client.db());
|
||||
const downloadStream = bucket.openDownloadStream(filename);
|
||||
downloadStream.pipe(response);
|
||||
});
|
||||
@@ -54,5 +54,3 @@ function listener(request, response) {
|
||||
response.end("405 Method Not Allowed");
|
||||
}
|
||||
}
|
||||
|
||||
exports.listener = listener;
|
||||
Reference in new issue
Block a user