aboutsummaryrefslogtreecommitdiff
path: root/src/server/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/index.ts')
-rw-r--r--src/server/index.ts42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index fca90a585..3940bbd58 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -42,10 +42,8 @@ var AdmZip = require('adm-zip');
import * as YoutubeApi from "./apis/youtube/youtubeApiSample";
import { Response } from 'express-serve-static-core';
import { GoogleApiServerUtils } from "./apis/google/GoogleApiServerUtils";
-import { GaxiosResponse } from 'gaxios';
-import { Opt } from '../new_fields/Doc';
-import { docs_v1 } from 'googleapis';
-import { Endpoint } from 'googleapis-common';
+import { GooglePhotos } from './apis/google/GooglePhotosServerUtils';
+import { GooglePhotosUploadUtils } from './apis/google/GooglePhotosUploadUtils';
const MongoStore = require('connect-mongo')(session);
const mongoose = require('mongoose');
const probe = require("probe-image-size");
@@ -194,7 +192,7 @@ app.get("/version", (req, res) => {
// SEARCH
const solrURL = "http://localhost:8983/solr/#/dash";
-// GETTERS
+// GETTERSÃ¥
app.get("/search", async (req, res) => {
const solrQuery: any = {};
@@ -447,7 +445,7 @@ function LoadPage(file: string, pageNumber: number, res: Response) {
console.log(pageNumber);
pdf.getPage(pageNumber).then((page: Pdfjs.PDFPageProxy) => {
console.log("reading " + page);
- let viewport = page.getViewport({ scale: 1 });
+ let viewport = page.getViewport(1);
let canvasAndContext = factory.create(viewport.width, viewport.height);
let renderContext = {
canvasContext: canvasAndContext.context,
@@ -827,6 +825,38 @@ app.post(RouteStore.googleDocs + "/:sector/:action", (req, res) => {
});
});
+app.post(RouteStore.googlePhotosQuery, (req, res) => {
+ GoogleApiServerUtils.RetrieveAccessToken({ credentials, token }).then(
+ token => {
+ GooglePhotos.ExecuteQuery({ token, query: req.body })
+ .then(response => {
+ if (response === undefined) {
+ res.send("Error: unable to build suffix for Google Photos API request");
+ return;
+ }
+ res.send(response);
+ })
+ .catch(error => {
+ res.send(`Error: an exception occurred in the execution of this Google Photos API request\n${error}`);
+ });
+ },
+ error => res.send(error)
+ );
+});
+
+app.post(RouteStore.googlePhotosMediaUpload, (req, res) => {
+ GoogleApiServerUtils.RetrieveAccessToken({ credentials, token }).then(
+ token => {
+ GooglePhotosUploadUtils.SubmitUpload({ token, ...req.body })
+ .then(response => {
+ res.send(response);
+ }).catch(error => {
+ res.send(`Error: an exception occurred in uploading the given media\n${error}`);
+ });
+ },
+ error => res.send(error));
+});
+
const suffixMap: { [type: string]: (string | [string, string | ((json: any) => any)]) } = {
"number": "_n",
"string": "_t",