Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build-deploy-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
run: yarn install
working-directory: ./bs3

- name: Lint web
run: yarn lint
working-directory: ./bs3

- name: Build web
run: yarn build
working-directory: ./bs3
Expand All @@ -37,6 +41,10 @@ jobs:
run: yarn install
working-directory: ./bs3-functions/node-functions

- name: Lint functions
run: yarn lint
working-directory: ./bs3-functions/node-functions

- name: Install Firebase CLI
run: npm install -g firebase-tools

Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
run: yarn install
working-directory: ./bs3

- name: Lint web
run: yarn lint
working-directory: ./bs3

- name: Build web
run: yarn build
working-directory: ./bs3
Expand All @@ -38,6 +42,10 @@ jobs:
run: yarn install
working-directory: ./bs3-functions/node-functions

- name: Lint functions
run: yarn lint
working-directory: ./bs3-functions/node-functions

- name: Build functions
run: yarn build
working-directory: ./bs3-functions/node-functions
Expand Down
4 changes: 2 additions & 2 deletions bs3-functions/node-functions/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { RawAxiosRequestHeaders } from "axios";
import axios, { RawAxiosRequestHeaders, isAxiosError } from "axios";
import Ajv, { JSONSchemaType } from "ajv";
import addFormats from "ajv-formats";

Expand Down Expand Up @@ -150,7 +150,7 @@ export class Perplexity {
const response = await client.getHeadlines();
console.log(JSON.stringify(response, null, 2));
} catch (error) {
if (axios.isAxiosError(error) && error.response) {
if (isAxiosError(error) && error.response) {
console.error(
"API Error Response:",
JSON.stringify(error.response.data, null, 2),
Expand Down
16 changes: 11 additions & 5 deletions bs3-functions/node-functions/src/archiveExpiredPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ import { onSchedule } from "firebase-functions/v2/scheduler";

const firestore = admin.firestore();

type Expiry = '24h' | '3d' | '7d';
type Expiry = "24h" | "3d" | "7d";
const EXPIRY_MS: Record<Expiry, number> = {
'24h': 24 * 60 * 60 * 1000,
'3d': 3 * 24 * 60 * 60 * 1000,
'7d': 7 * 24 * 60 * 60 * 1000
"24h": 24 * 60 * 60 * 1000,
"3d": 3 * 24 * 60 * 60 * 1000,
"7d": 7 * 24 * 60 * 60 * 1000,
};

/**
* Computes the Unix timestamp (ms) at which a given timestamp expires, based on the expiry period.
* @param {string} timestamp - The original timestamp (ISO format)
* @param {Expiry} [expiry] - The expiry period (default is "7d")
* @return {number} The expiration time as Unix ms since epoch
*/
function expiresAt(timestamp: string, expiry?: Expiry): number {
const msAdd = EXPIRY_MS[expiry || '7d'] ?? EXPIRY_MS['7d'];
const msAdd = EXPIRY_MS[expiry || "7d"] ?? EXPIRY_MS["7d"];
return new Date(timestamp).getTime() + msAdd;
}

Expand Down
3 changes: 2 additions & 1 deletion bs3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@
"@typescript-eslint/eslint-plugin": "^8.29.1",
"@typescript-eslint/parser": "^8.29.1",
"env-cmd": "^10.1.0",
"eslint": "^9.24.0",
"eslint": "^8.57.0",
"eslint-config-react-app": "^7.0.1",
"typescript": "^5.8.3"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx src/",
"start": "react-scripts start",
"start:dev": "env-cmd -f .env.development.local yarn start",
"start:prod": "env-cmd -f .env.production yarn start",
Expand Down
Loading