w test piece
This commit is contained in:
parent
dbf96d5341
commit
bdb40fedce
|
@ -20,6 +20,7 @@ const reviewTasksDb = nano.db.use("review-tasks");
|
||||||
// TODO: get new env vars on server (remember base64 for key)
|
// TODO: get new env vars on server (remember base64 for key)
|
||||||
|
|
||||||
const auth = new google.auth.GoogleAuth({
|
const auth = new google.auth.GoogleAuth({
|
||||||
|
// TODO: THESE CREDENTIALS ARE NOT WORKING SOMEHOW !!
|
||||||
credentials: {
|
credentials: {
|
||||||
private_key: Buffer.from(env.lingdocsServiceAccountKey, "base64").toString(
|
private_key: Buffer.from(env.lingdocsServiceAccountKey, "base64").toString(
|
||||||
"ascii"
|
"ascii"
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import express, { Response } from "express";
|
import express, { Response } from "express";
|
||||||
import * as T from "../../../website/src/types/account-types";
|
import * as T from "../../../website/src/types/account-types";
|
||||||
import { receiveSubmissions } from "../lib/submissions";
|
import { receiveSubmissions } from "../lib/submissions";
|
||||||
|
import { google } from "googleapis";
|
||||||
|
import {
|
||||||
|
getEntriesFromSheet,
|
||||||
|
Sheets,
|
||||||
|
} from "../../../functions/lib/spreadsheet-tools";
|
||||||
|
import env from "../lib/env-vars";
|
||||||
|
|
||||||
// TODO: ADD PROPER ERROR HANDLING THAT WILL RETURN JSON ALWAYS
|
// TODO: ADD PROPER ERROR HANDLING THAT WILL RETURN JSON ALWAYS
|
||||||
|
|
||||||
|
@ -10,6 +16,33 @@ function sendResponse(res: Response, payload: T.APIResponse) {
|
||||||
|
|
||||||
const submissionsRouter = express.Router();
|
const submissionsRouter = express.Router();
|
||||||
|
|
||||||
|
const auth = new google.auth.GoogleAuth({
|
||||||
|
// TODO: THESE CREDENTIALS ARE NOT WORKING SOMEHOW !!
|
||||||
|
credentials: {
|
||||||
|
private_key: Buffer.from(env.lingdocsServiceAccountKey, "base64").toString(
|
||||||
|
"ascii"
|
||||||
|
),
|
||||||
|
client_email: env.lingdocsServiceAccountEmail,
|
||||||
|
},
|
||||||
|
scopes: [
|
||||||
|
"https://www.googleapis.com/auth/spreadsheets",
|
||||||
|
"https://www.googleapis.com/auth/drive.file",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const { spreadsheets } = google.sheets({
|
||||||
|
version: "v4",
|
||||||
|
auth,
|
||||||
|
});
|
||||||
|
const sheets: Sheets = {
|
||||||
|
spreadsheetId: env.lingdocsDictionarySpreadsheet,
|
||||||
|
spreadsheets,
|
||||||
|
};
|
||||||
|
|
||||||
|
submissionsRouter.get("/", async (req, res, next) => {
|
||||||
|
const r = await getEntriesFromSheet(sheets);
|
||||||
|
res.send(r);
|
||||||
|
});
|
||||||
|
|
||||||
// Guard all api with authentication
|
// Guard all api with authentication
|
||||||
submissionsRouter.use((req, res, next) => {
|
submissionsRouter.use((req, res, next) => {
|
||||||
if (req.isAuthenticated()) {
|
if (req.isAuthenticated()) {
|
||||||
|
|
|
@ -3,8 +3,8 @@ import { Types as T, validateEntry } from "@lingdocs/inflect";
|
||||||
const title = "LingDocs Pashto Dictionary";
|
const title = "LingDocs Pashto Dictionary";
|
||||||
const license = `Copyright © ${new Date().getFullYear()} lingdocs.com All Rights Reserved - Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License - https://creativecommons.org/licenses/by-nc-sa/4.0/`;
|
const license = `Copyright © ${new Date().getFullYear()} lingdocs.com All Rights Reserved - Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License - https://creativecommons.org/licenses/by-nc-sa/4.0/`;
|
||||||
const baseUrl = `https://storage.lingdocs.com/dictionary/`;
|
const baseUrl = `https://storage.lingdocs.com/dictionary/`;
|
||||||
export const dictionaryFilename = "dictionary2";
|
export const dictionaryFilename = "dictionary";
|
||||||
export const dictionaryInfoFilename = "dictionary-info2";
|
export const dictionaryInfoFilename = "dictionary-info";
|
||||||
// const hunspellAffFileFilename = "ps_AFF.aff";
|
// const hunspellAffFileFilename = "ps_AFF.aff";
|
||||||
// const hunspellDicFileFilename = "ps_AFF.dic";
|
// const hunspellDicFileFilename = "ps_AFF.dic";
|
||||||
const allWordsJsonFilename = "all-words-dictionary.json";
|
const allWordsJsonFilename = "all-words-dictionary.json";
|
||||||
|
|
Loading…
Reference in New Issue