w test piece

This commit is contained in:
adueck 2024-11-28 01:10:31 +05:00
parent dbf96d5341
commit bdb40fedce
4 changed files with 36 additions and 2 deletions

View File

View File

@ -20,6 +20,7 @@ const reviewTasksDb = nano.db.use("review-tasks");
// TODO: get new env vars on server (remember base64 for key)
const auth = new google.auth.GoogleAuth({
// TODO: THESE CREDENTIALS ARE NOT WORKING SOMEHOW !!
credentials: {
private_key: Buffer.from(env.lingdocsServiceAccountKey, "base64").toString(
"ascii"

View File

@ -1,6 +1,12 @@
import express, { Response } from "express";
import * as T from "../../../website/src/types/account-types";
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
@ -10,6 +16,33 @@ function sendResponse(res: Response, payload: T.APIResponse) {
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
submissionsRouter.use((req, res, next) => {
if (req.isAuthenticated()) {

View File

@ -3,8 +3,8 @@ import { Types as T, validateEntry } from "@lingdocs/inflect";
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 baseUrl = `https://storage.lingdocs.com/dictionary/`;
export const dictionaryFilename = "dictionary2";
export const dictionaryInfoFilename = "dictionary-info2";
export const dictionaryFilename = "dictionary";
export const dictionaryInfoFilename = "dictionary-info";
// const hunspellAffFileFilename = "ps_AFF.aff";
// const hunspellDicFileFilename = "ps_AFF.dic";
const allWordsJsonFilename = "all-words-dictionary.json";