1
0
Fork 0

Removed Tailwind css, moved api to v1 dir

This commit is contained in:
Neshura 2023-06-08 21:21:34 +02:00
parent c8f96eb694
commit c9fba4666e
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
18 changed files with 195 additions and 453 deletions
app/api/v1/empires

View file

@ -0,0 +1,29 @@
import { google } from 'googleapis';
import { NextResponse } from 'next/server';
export async function GET() {
const target = ['https://www.googleapis.com/auth/spreadsheets.readonly'];
const jwt = new google.auth.JWT(
process.env.API_EMAIL,
undefined,
(process.env.API_KEY || '').replace(/\\n/g, '\n'),
target
);
const sheets = google.sheets({version: 'v4', auth: jwt});
const response = await sheets.spreadsheets.values.get({
spreadsheetId: process.env.SPREADSHEET_ID,
range: 'Overview',
});
const rows = response.data.values;
if (rows?.length) {
let empireCount: number = rows[0][1];
console.log("New Google Data loaded " + Intl.DateTimeFormat('en-UK', {hour: 'numeric', minute: 'numeric', hour12: false}).format(Date.now()));
return NextResponse.json({ empireCount });
}
else {
return NextResponse.json({ status: 500 })
}
}