generated from nhcarrigan/template
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 867594efbe | |||
| 05634b9a4c | |||
| 970a31895d |
@@ -1,47 +0,0 @@
|
||||
name: Node.js CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
name: CI
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Source Files
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js v24
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 10
|
||||
|
||||
- name: Ensure Dependencies are Pinned
|
||||
uses: naomi-lgbt/dependency-pin-check@main
|
||||
with:
|
||||
language: javascript
|
||||
dev-dependencies: true
|
||||
peer-dependencies: true
|
||||
optional-dependencies: true
|
||||
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Lint Source Files
|
||||
run: pnpm run lint
|
||||
|
||||
- name: Verify Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Run Tests
|
||||
run: pnpm run test
|
||||
@@ -1,177 +0,0 @@
|
||||
name: Security Scan and Upload
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
schedule:
|
||||
- cron: '0 0 * * 1'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
security-audit:
|
||||
name: Security & DefectDojo Upload
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# --- AUTO-SETUP PROJECT ---
|
||||
- name: Ensure DefectDojo Product Exists
|
||||
env:
|
||||
DD_URL: ${{ secrets.DD_URL }}
|
||||
DD_TOKEN: ${{ secrets.DD_TOKEN }}
|
||||
PRODUCT_NAME: ${{ github.repository }}
|
||||
PRODUCT_TYPE_ID: 1
|
||||
run: |
|
||||
sudo apt-get install jq -y > /dev/null
|
||||
|
||||
echo "Checking connection to $DD_URL..."
|
||||
|
||||
# Check if product exists - capture HTTP code to debug connection issues
|
||||
RESPONSE=$(curl --write-out "%{http_code}" --silent --output /tmp/response.json \
|
||||
-H "Authorization: Token $DD_TOKEN" \
|
||||
"$DD_URL/api/v2/products/?name=$PRODUCT_NAME")
|
||||
|
||||
# If response is not 200, print error
|
||||
if [ "$RESPONSE" != "200" ]; then
|
||||
echo "::error::Failed to query DefectDojo. HTTP Code: $RESPONSE"
|
||||
cat /tmp/response.json
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COUNT=$(cat /tmp/response.json | jq -r '.count')
|
||||
|
||||
if [ "$COUNT" = "0" ]; then
|
||||
echo "Creating product '$PRODUCT_NAME'..."
|
||||
curl -s -X POST "$DD_URL/api/v2/products/" \
|
||||
-H "Authorization: Token $DD_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{ "name": "'"$PRODUCT_NAME"'", "description": "Auto-created by Gitea Actions", "prod_type": '$PRODUCT_TYPE_ID' }'
|
||||
else
|
||||
echo "Product '$PRODUCT_NAME' already exists."
|
||||
fi
|
||||
|
||||
# --- 1. TRIVY (Dependencies & Misconfig) ---
|
||||
- name: Install Trivy
|
||||
run: |
|
||||
sudo apt-get install wget apt-transport-https gnupg lsb-release -y
|
||||
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
|
||||
echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
|
||||
sudo apt-get update && sudo apt-get install trivy -y
|
||||
|
||||
- name: Run Trivy (FS Scan)
|
||||
run: |
|
||||
trivy fs . --scanners vuln,misconfig --format json --output trivy-results.json --exit-code 0
|
||||
|
||||
- name: Upload Trivy to DefectDojo
|
||||
env:
|
||||
DD_URL: ${{ secrets.DD_URL }}
|
||||
DD_TOKEN: ${{ secrets.DD_TOKEN }}
|
||||
run: |
|
||||
echo "Uploading Trivy results..."
|
||||
# Generate today's date in YYYY-MM-DD format
|
||||
TODAY=$(date +%Y-%m-%d)
|
||||
|
||||
HTTP_CODE=$(curl --write-out "%{http_code}" --output response.txt --silent -X POST "$DD_URL/api/v2/import-scan/" \
|
||||
-H "Authorization: Token $DD_TOKEN" \
|
||||
-F "active=true" \
|
||||
-F "verified=true" \
|
||||
-F "scan_type=Trivy Scan" \
|
||||
-F "engagement_name=CI/CD Pipeline" \
|
||||
-F "product_name=${{ github.repository }}" \
|
||||
-F "scan_date=$TODAY" \
|
||||
-F "auto_create_context=true" \
|
||||
-F "file=@trivy-results.json")
|
||||
|
||||
if [[ "$HTTP_CODE" != "200" && "$HTTP_CODE" != "201" ]]; then
|
||||
echo "::error::Upload Failed with HTTP $HTTP_CODE"
|
||||
echo "--- SERVER RESPONSE ---"
|
||||
cat response.txt
|
||||
echo "-----------------------"
|
||||
exit 1
|
||||
else
|
||||
echo "Upload Success!"
|
||||
fi
|
||||
|
||||
# --- 2. GITLEAKS (Secrets) ---
|
||||
- name: Install Gitleaks
|
||||
run: |
|
||||
wget -qO gitleaks.tar.gz https://github.com/gitleaks/gitleaks/releases/download/v8.18.0/gitleaks_8.18.0_linux_x64.tar.gz
|
||||
tar -xzf gitleaks.tar.gz
|
||||
sudo mv gitleaks /usr/local/bin/ && chmod +x /usr/local/bin/gitleaks
|
||||
|
||||
- name: Run Gitleaks
|
||||
run: gitleaks detect --source . -v --report-path gitleaks-results.json --report-format json --no-git || true
|
||||
|
||||
- name: Upload Gitleaks to DefectDojo
|
||||
env:
|
||||
DD_URL: ${{ secrets.DD_URL }}
|
||||
DD_TOKEN: ${{ secrets.DD_TOKEN }}
|
||||
run: |
|
||||
echo "Uploading Gitleaks results..."
|
||||
TODAY=$(date +%Y-%m-%d)
|
||||
|
||||
HTTP_CODE=$(curl --write-out "%{http_code}" --output response.txt --silent -X POST "$DD_URL/api/v2/import-scan/" \
|
||||
-H "Authorization: Token $DD_TOKEN" \
|
||||
-F "active=true" \
|
||||
-F "verified=true" \
|
||||
-F "scan_type=Gitleaks Scan" \
|
||||
-F "engagement_name=CI/CD Pipeline" \
|
||||
-F "product_name=${{ github.repository }}" \
|
||||
-F "scan_date=$TODAY" \
|
||||
-F "auto_create_context=true" \
|
||||
-F "file=@gitleaks-results.json")
|
||||
|
||||
if [[ "$HTTP_CODE" != "200" && "$HTTP_CODE" != "201" ]]; then
|
||||
echo "::error::Upload Failed with HTTP $HTTP_CODE"
|
||||
echo "--- SERVER RESPONSE ---"
|
||||
cat response.txt
|
||||
echo "-----------------------"
|
||||
exit 1
|
||||
else
|
||||
echo "Upload Success!"
|
||||
fi
|
||||
|
||||
# --- 3. SEMGREP (SAST) ---
|
||||
- name: Install Semgrep (via pipx)
|
||||
run: |
|
||||
sudo apt-get install pipx -y
|
||||
pipx install semgrep
|
||||
# Add pipx binary path to GITHUB_PATH so next steps can see 'semgrep'
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Run Semgrep
|
||||
run: semgrep scan --config=p/security-audit --config=p/owasp-top-ten --json --output semgrep-results.json . || true
|
||||
|
||||
- name: Upload Semgrep to DefectDojo
|
||||
env:
|
||||
DD_URL: ${{ secrets.DD_URL }}
|
||||
DD_TOKEN: ${{ secrets.DD_TOKEN }}
|
||||
run: |
|
||||
echo "Uploading Semgrep results..."
|
||||
TODAY=$(date +%Y-%m-%d)
|
||||
|
||||
HTTP_CODE=$(curl --write-out "%{http_code}" --output response.txt --silent -X POST "$DD_URL/api/v2/import-scan/" \
|
||||
-H "Authorization: Token $DD_TOKEN" \
|
||||
-F "active=true" \
|
||||
-F "verified=true" \
|
||||
-F "scan_type=Semgrep JSON Report" \
|
||||
-F "engagement_name=CI/CD Pipeline" \
|
||||
-F "product_name=${{ github.repository }}" \
|
||||
-F "scan_date=$TODAY" \
|
||||
-F "auto_create_context=true" \
|
||||
-F "file=@semgrep-results.json")
|
||||
|
||||
if [[ "$HTTP_CODE" != "200" && "$HTTP_CODE" != "201" ]]; then
|
||||
echo "::error::Upload Failed with HTTP $HTTP_CODE"
|
||||
echo "--- SERVER RESPONSE ---"
|
||||
cat response.txt
|
||||
echo "-----------------------"
|
||||
exit 1
|
||||
else
|
||||
echo "Upload Success!"
|
||||
fi
|
||||
@@ -1,2 +1 @@
|
||||
node_modules
|
||||
prod
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# Package Manager Configuration
|
||||
# Force pnpm usage - breaks npm/yarn intentionally
|
||||
node-linker=pnpm
|
||||
|
||||
# Security: Disable all lifecycle scripts
|
||||
ignore-scripts=true
|
||||
enable-pre-post-scripts=false
|
||||
|
||||
# Security: Require packages to be 10+ days old before installation
|
||||
minimum-release-age=14400
|
||||
|
||||
# Security: Verify package integrity hashes
|
||||
verify-store-integrity=true
|
||||
|
||||
# Security: Enforce strict trust policies
|
||||
trust-policy=strict
|
||||
|
||||
# Security: Strict peer dependency resolution
|
||||
strict-peer-dependencies=true
|
||||
|
||||
# Performance: Use symlinks for node_modules
|
||||
symlink=true
|
||||
|
||||
# Lockfile: Ensure lockfile is not modified during install
|
||||
frozen-lockfile=false
|
||||
@@ -18,7 +18,7 @@ This page is currently deployed. [View the live website.]
|
||||
|
||||
## Feedback and Bugs
|
||||
|
||||
If you have feedback or a bug report, please [log a ticket on our forum](https://support.nhcarrigan.com).
|
||||
If you have feedback or a bug report, please feel free to open a GitHub issue!
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"lint": "eslint src --max-warnings 0",
|
||||
"start": "op run --env-file=prod.env --no-masking -- node prod/index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 0"
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Naomi Carrigan",
|
||||
@@ -17,7 +17,7 @@
|
||||
"devDependencies": {
|
||||
"@nhcarrigan/eslint-config": "5.2.0",
|
||||
"@nhcarrigan/typescript-config": "4.0.0",
|
||||
"@types/node": "25.2.3",
|
||||
"@types/node": "22.13.9",
|
||||
"@types/node-schedule": "2.1.7",
|
||||
"eslint": "9.21.0",
|
||||
"typescript": "5.8.2"
|
||||
|
||||
Generated
+38
-48
@@ -35,13 +35,13 @@ importers:
|
||||
devDependencies:
|
||||
'@nhcarrigan/eslint-config':
|
||||
specifier: 5.2.0
|
||||
version: 5.2.0(@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(playwright@1.51.0)(react@19.0.0)(typescript@5.8.2)(vitest@3.0.8(@types/node@25.2.3))
|
||||
version: 5.2.0(@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(playwright@1.51.0)(react@19.0.0)(typescript@5.8.2)(vitest@3.0.8(@types/node@22.13.9))
|
||||
'@nhcarrigan/typescript-config':
|
||||
specifier: 4.0.0
|
||||
version: 4.0.0(typescript@5.8.2)
|
||||
'@types/node':
|
||||
specifier: 25.2.3
|
||||
version: 25.2.3
|
||||
specifier: 22.13.9
|
||||
version: 22.13.9
|
||||
'@types/node-schedule':
|
||||
specifier: 2.1.7
|
||||
version: 2.1.7
|
||||
@@ -426,61 +426,51 @@ packages:
|
||||
resolution: {integrity: sha512-88I+D3TeKItrw+Y/2ud4Tw0+3CxQ2kLgu3QvrogZ0OfkmX/DEppehus7L3TS2Q4lpB+hYyxhkQiYPJ6Mf5/dPg==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.34.9':
|
||||
resolution: {integrity: sha512-3qyfWljSFHi9zH0KgtEPG4cBXHDFhwD8kwg6xLfHQ0IWuH9crp005GfoUUh/6w9/FWGBwEHg3lxK1iHRN1MFlA==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-6TZjPHjKZUQKmVKMUowF3ewHxctrRR09eYyvT5eFv8w/fXarEra83A2mHTVJLA5xU91aCNOUnM+DWFMSbQ0Nxw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.34.9':
|
||||
resolution: {integrity: sha512-LD2fytxZJZ6xzOKnMbIpgzFOuIKlxVOpiMAXawsAZ2mHBPEYOnLRK5TTEsID6z4eM23DuO88X0Tq1mErHMVq0A==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-loongarch64-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-dRAgTfDsn0TE0HI6cmo13hemKpVHOEyeciGtvlBTkpx/F65kTvShtY/EVyZEIfxFkV5JJTuQ9tP5HGBS0hfxIg==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-powerpc64le-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-PHcNOAEhkoMSQtMf+rJofwisZqaU8iQ8EaSps58f5HYll9EAY5BSErCZ8qBDMVbq88h4UxaNPlbrKqfWP8RfJA==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-Z2i0Uy5G96KBYKjeQFKbbsB54xFOL5/y1P5wNBsbXB8yE+At3oh0DVMjQVzCJRJSfReiB2tX8T6HUFZ2k8iaKg==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-U+5SwTMoeYXoDzJX5dhDTxRltSrIax8KWwfaaYcynuJw8mT33W7oOgz0a+AaXtGuvhzTr2tVKh5UO8GVANTxyQ==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-FwBHNSOjUTQLP4MG7y6rR6qbGw4MFeQnIBrMe161QGaQoBQLqSUEKlHIiVgF3g/mb3lxlxzJOpIBhaP+C+KP2A==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.34.9':
|
||||
resolution: {integrity: sha512-cYRpV4650z2I3/s6+5/LONkjIz8MBeqrk+vPXV10ORBnshpn8S32bPqQ2Utv39jCiDcO2eJTuSlPXpnvmaIgRA==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.34.9':
|
||||
resolution: {integrity: sha512-z4mQK9dAN6byRA/vsSgQiPeuO63wdiDxZ9yg9iyX2QTzKuQM7T4xlBoeUP/J8uiFkqxkcWndWi+W7bXdPbt27Q==}
|
||||
@@ -580,8 +570,8 @@ packages:
|
||||
'@types/node-schedule@2.1.7':
|
||||
resolution: {integrity: sha512-G7Z3R9H7r3TowoH6D2pkzUHPhcJrDF4Jz1JOQ80AX0K2DWTHoN9VC94XzFAPNMdbW9TBzMZ3LjpFi7RYdbxtXA==}
|
||||
|
||||
'@types/node@25.2.3':
|
||||
resolution: {integrity: sha512-m0jEgYlYz+mDJZ2+F4v8D1AyQb+QzsNqRuI7xg1VQX/KlKS0qT9r1Mo16yo5F/MtifXFgaofIFsdFMox2SxIbQ==}
|
||||
'@types/node@22.13.9':
|
||||
resolution: {integrity: sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw==}
|
||||
|
||||
'@types/normalize-package-data@2.4.4':
|
||||
resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==}
|
||||
@@ -2451,8 +2441,8 @@ packages:
|
||||
resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
undici-types@7.16.0:
|
||||
resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
|
||||
undici-types@6.20.0:
|
||||
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
|
||||
|
||||
undici@6.21.1:
|
||||
resolution: {integrity: sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==}
|
||||
@@ -2884,7 +2874,7 @@ snapshots:
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.0': {}
|
||||
|
||||
'@nhcarrigan/eslint-config@5.2.0(@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(playwright@1.51.0)(react@19.0.0)(typescript@5.8.2)(vitest@3.0.8(@types/node@25.2.3))':
|
||||
'@nhcarrigan/eslint-config@5.2.0(@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(playwright@1.51.0)(react@19.0.0)(typescript@5.8.2)(vitest@3.0.8(@types/node@22.13.9))':
|
||||
dependencies:
|
||||
'@eslint-community/eslint-plugin-eslint-comments': 4.4.1(eslint@9.21.0)
|
||||
'@eslint/compat': 1.2.4(eslint@9.21.0)
|
||||
@@ -2893,7 +2883,7 @@ snapshots:
|
||||
'@stylistic/eslint-plugin': 2.12.1(eslint@9.21.0)(typescript@5.8.2)
|
||||
'@typescript-eslint/eslint-plugin': 8.19.0(@typescript-eslint/parser@8.19.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(typescript@5.8.2)
|
||||
'@typescript-eslint/parser': 8.19.0(eslint@9.21.0)(typescript@5.8.2)
|
||||
'@vitest/eslint-plugin': 1.1.24(@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(typescript@5.8.2)(vitest@3.0.8(@types/node@25.2.3))
|
||||
'@vitest/eslint-plugin': 1.1.24(@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(typescript@5.8.2)(vitest@3.0.8(@types/node@22.13.9))
|
||||
eslint: 9.21.0
|
||||
eslint-plugin-deprecation: 3.0.0(eslint@9.21.0)(typescript@5.8.2)
|
||||
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.19.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)
|
||||
@@ -2906,7 +2896,7 @@ snapshots:
|
||||
playwright: 1.51.0
|
||||
react: 19.0.0
|
||||
typescript: 5.8.2
|
||||
vitest: 3.0.8(@types/node@25.2.3)
|
||||
vitest: 3.0.8(@types/node@22.13.9)
|
||||
transitivePeerDependencies:
|
||||
- '@typescript-eslint/utils'
|
||||
- eslint-import-resolver-typescript
|
||||
@@ -3022,14 +3012,14 @@ snapshots:
|
||||
|
||||
'@slack/logger@4.0.0':
|
||||
dependencies:
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
|
||||
'@slack/oauth@3.0.2':
|
||||
dependencies:
|
||||
'@slack/logger': 4.0.0
|
||||
'@slack/web-api': 7.8.0
|
||||
'@types/jsonwebtoken': 9.0.9
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
jsonwebtoken: 9.0.2
|
||||
lodash.isstring: 4.0.1
|
||||
transitivePeerDependencies:
|
||||
@@ -3039,7 +3029,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@slack/logger': 4.0.0
|
||||
'@slack/web-api': 7.8.0
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
'@types/ws': 8.18.0
|
||||
eventemitter3: 5.0.1
|
||||
ws: 8.18.1
|
||||
@@ -3054,7 +3044,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@slack/logger': 4.0.0
|
||||
'@slack/types': 2.14.0
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
'@types/retry': 0.12.0
|
||||
axios: 1.8.2
|
||||
eventemitter3: 5.0.1
|
||||
@@ -3082,17 +3072,17 @@ snapshots:
|
||||
'@types/body-parser@1.19.5':
|
||||
dependencies:
|
||||
'@types/connect': 3.4.38
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
|
||||
'@types/connect@3.4.38':
|
||||
dependencies:
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
|
||||
'@types/estree@1.0.6': {}
|
||||
|
||||
'@types/express-serve-static-core@5.0.6':
|
||||
dependencies:
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
'@types/qs': 6.9.18
|
||||
'@types/range-parser': 1.2.7
|
||||
'@types/send': 0.17.4
|
||||
@@ -3113,7 +3103,7 @@ snapshots:
|
||||
'@types/jsonwebtoken@9.0.9':
|
||||
dependencies:
|
||||
'@types/ms': 2.1.0
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
|
||||
'@types/mime@1.3.5': {}
|
||||
|
||||
@@ -3121,11 +3111,11 @@ snapshots:
|
||||
|
||||
'@types/node-schedule@2.1.7':
|
||||
dependencies:
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
|
||||
'@types/node@25.2.3':
|
||||
'@types/node@22.13.9':
|
||||
dependencies:
|
||||
undici-types: 7.16.0
|
||||
undici-types: 6.20.0
|
||||
|
||||
'@types/normalize-package-data@2.4.4': {}
|
||||
|
||||
@@ -3138,17 +3128,17 @@ snapshots:
|
||||
'@types/send@0.17.4':
|
||||
dependencies:
|
||||
'@types/mime': 1.3.5
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
|
||||
'@types/serve-static@1.15.7':
|
||||
dependencies:
|
||||
'@types/http-errors': 2.0.4
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
'@types/send': 0.17.4
|
||||
|
||||
'@types/ws@8.18.0':
|
||||
dependencies:
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.19.0(@typescript-eslint/parser@8.19.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(typescript@5.8.2)':
|
||||
dependencies:
|
||||
@@ -3302,13 +3292,13 @@ snapshots:
|
||||
'@typescript-eslint/types': 8.26.0
|
||||
eslint-visitor-keys: 4.2.0
|
||||
|
||||
'@vitest/eslint-plugin@1.1.24(@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(typescript@5.8.2)(vitest@3.0.8(@types/node@25.2.3))':
|
||||
'@vitest/eslint-plugin@1.1.24(@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(typescript@5.8.2)(vitest@3.0.8(@types/node@22.13.9))':
|
||||
dependencies:
|
||||
'@typescript-eslint/utils': 8.26.0(eslint@9.21.0)(typescript@5.8.2)
|
||||
eslint: 9.21.0
|
||||
optionalDependencies:
|
||||
typescript: 5.8.2
|
||||
vitest: 3.0.8(@types/node@25.2.3)
|
||||
vitest: 3.0.8(@types/node@22.13.9)
|
||||
|
||||
'@vitest/expect@3.0.8':
|
||||
dependencies:
|
||||
@@ -3317,13 +3307,13 @@ snapshots:
|
||||
chai: 5.2.0
|
||||
tinyrainbow: 2.0.0
|
||||
|
||||
'@vitest/mocker@3.0.8(vite@6.2.1(@types/node@25.2.3))':
|
||||
'@vitest/mocker@3.0.8(vite@6.2.1(@types/node@22.13.9))':
|
||||
dependencies:
|
||||
'@vitest/spy': 3.0.8
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.17
|
||||
optionalDependencies:
|
||||
vite: 6.2.1(@types/node@25.2.3)
|
||||
vite: 6.2.1(@types/node@22.13.9)
|
||||
|
||||
'@vitest/pretty-format@3.0.8':
|
||||
dependencies:
|
||||
@@ -5339,7 +5329,7 @@ snapshots:
|
||||
has-symbols: 1.1.0
|
||||
which-boxed-primitive: 1.1.1
|
||||
|
||||
undici-types@7.16.0: {}
|
||||
undici-types@6.20.0: {}
|
||||
|
||||
undici@6.21.1: {}
|
||||
|
||||
@@ -5364,13 +5354,13 @@ snapshots:
|
||||
|
||||
vary@1.1.2: {}
|
||||
|
||||
vite-node@3.0.8(@types/node@25.2.3):
|
||||
vite-node@3.0.8(@types/node@22.13.9):
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
debug: 4.4.0
|
||||
es-module-lexer: 1.6.0
|
||||
pathe: 2.0.3
|
||||
vite: 6.2.1(@types/node@25.2.3)
|
||||
vite: 6.2.1(@types/node@22.13.9)
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- jiti
|
||||
@@ -5385,19 +5375,19 @@ snapshots:
|
||||
- tsx
|
||||
- yaml
|
||||
|
||||
vite@6.2.1(@types/node@25.2.3):
|
||||
vite@6.2.1(@types/node@22.13.9):
|
||||
dependencies:
|
||||
esbuild: 0.25.0
|
||||
postcss: 8.5.3
|
||||
rollup: 4.34.9
|
||||
optionalDependencies:
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
fsevents: 2.3.3
|
||||
|
||||
vitest@3.0.8(@types/node@25.2.3):
|
||||
vitest@3.0.8(@types/node@22.13.9):
|
||||
dependencies:
|
||||
'@vitest/expect': 3.0.8
|
||||
'@vitest/mocker': 3.0.8(vite@6.2.1(@types/node@25.2.3))
|
||||
'@vitest/mocker': 3.0.8(vite@6.2.1(@types/node@22.13.9))
|
||||
'@vitest/pretty-format': 3.0.8
|
||||
'@vitest/runner': 3.0.8
|
||||
'@vitest/snapshot': 3.0.8
|
||||
@@ -5413,11 +5403,11 @@ snapshots:
|
||||
tinyexec: 0.3.2
|
||||
tinypool: 1.0.2
|
||||
tinyrainbow: 2.0.0
|
||||
vite: 6.2.1(@types/node@25.2.3)
|
||||
vite-node: 3.0.8(@types/node@25.2.3)
|
||||
vite: 6.2.1(@types/node@22.13.9)
|
||||
vite-node: 3.0.8(@types/node@22.13.9)
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
'@types/node': 25.2.3
|
||||
'@types/node': 22.13.9
|
||||
transitivePeerDependencies:
|
||||
- jiti
|
||||
- less
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { AtpAgent } from "@atproto/api";
|
||||
import pkg from "@slack/bolt";
|
||||
import { Client, Events } from "discord.js";
|
||||
import { scheduleJob } from "node-schedule";
|
||||
import { serve } from "./server/serve.js";
|
||||
import { getMommy } from "./utils/getMommy.js";
|
||||
import { logger } from "./utils/logger.js";
|
||||
const { App, FileInstallationStore } = pkg;
|
||||
const discord = new Client({ intents: [] });
|
||||
discord.on(Events.ClientReady, () => {
|
||||
void logger.log("info", "Connected to Discord!");
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises -- This is intentional.
|
||||
discord.on(Events.InteractionCreate, async (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) {
|
||||
return;
|
||||
}
|
||||
await interaction.deferReply();
|
||||
const name = interaction.options.getString("name");
|
||||
const response = await getMommy(name ?? undefined);
|
||||
await interaction.editReply(response);
|
||||
});
|
||||
const slack = new App({
|
||||
clientId: process.env.SLACK_CLIENT_ID ?? "",
|
||||
clientSecret: process.env.SLACK_CLIENT_SECRET ?? "",
|
||||
installationStore: new FileInstallationStore(),
|
||||
installerOptions: {
|
||||
directInstall: true,
|
||||
},
|
||||
scopes: ["commands", "chat:write"],
|
||||
signingSecret: process.env.SLACK_SIGNING_SECRET ?? "",
|
||||
stateSecret: process.env.SLACK_STATE_SECRET ?? "",
|
||||
});
|
||||
slack.command("/mommy", async ({ ack, body, respond }) => {
|
||||
await ack();
|
||||
const response = await getMommy(body.text);
|
||||
await respond(response);
|
||||
});
|
||||
const bsky = new AtpAgent({
|
||||
service: "https://bsky.social",
|
||||
});
|
||||
await discord.login(process.env.DISCORD_TOKEN);
|
||||
await slack.start(8010);
|
||||
await logger.log("info", "Connected to Slack!");
|
||||
await bsky.login({
|
||||
identifier: "mommy.naomi.party",
|
||||
password: process.env.BSKY_PASSWORD ?? "",
|
||||
});
|
||||
await logger.log("info", "Connected to bsky.social!");
|
||||
scheduleJob("0 9 * * *", async () => {
|
||||
const response = await getMommy();
|
||||
await bsky.post({
|
||||
text: response,
|
||||
});
|
||||
await logger.log("info", "Posted to bsky.social!");
|
||||
});
|
||||
serve();
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import fastify from "fastify";
|
||||
import { logger } from "../utils/logger.js";
|
||||
const html = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Mommy Bot</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="Mommy loves you~!" />
|
||||
<script src="https://cdn.nhcarrigan.com/headers/index.js" async defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Mommy Bot</h1>
|
||||
<section>
|
||||
<p>Mommy loves you~!</p>
|
||||
<a href="https://slack.com/oauth/v2/authorize?client_id=8569765106322.8554301974567&scope=chat:write,commands&user_scope="><img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" /></a>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Links</h2>
|
||||
<p>
|
||||
<a href="https://git.nhcarrigan.com/nhcarrigan/mommy-bot">
|
||||
<i class="fa-solid fa-code"></i> Source Code
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://docs.nhcarrigan.com/">
|
||||
<i class="fa-solid fa-book"></i> Documentation
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://chat.nhcarrigan.com">
|
||||
<i class="fa-solid fa-circle-info"></i> Support
|
||||
</a>
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>`;
|
||||
/**
|
||||
* Starts up a web server for health monitoring.
|
||||
*/
|
||||
export const serve = () => {
|
||||
try {
|
||||
const server = fastify({
|
||||
logger: false,
|
||||
});
|
||||
server.get("/", (_request, response) => {
|
||||
response.header("Content-Type", "text/html");
|
||||
response.send(html);
|
||||
});
|
||||
server.listen({ port: 8009 }, (error) => {
|
||||
if (error) {
|
||||
void logger.error("instantiate server", error);
|
||||
return;
|
||||
}
|
||||
void logger.log("debug", "Server listening on port 8009.");
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error) {
|
||||
void logger.error("instantiate server", error);
|
||||
return;
|
||||
}
|
||||
void logger.error("instantiate server", new Error("Unknown error"));
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { isProfane } from "no-profanity";
|
||||
/**
|
||||
* Fetches a mommy quote from the API.
|
||||
* @param name - The user's name, if provided.
|
||||
* @returns The mommy quote.
|
||||
*/
|
||||
export const getMommy = async (name = "dear") => {
|
||||
const finalName = isProfane(name)
|
||||
? "dear"
|
||||
: name;
|
||||
const url = `https://mommy.nhcarrigan.com/api?name=${finalName}`;
|
||||
const request = await fetch(url);
|
||||
const response = await request.text();
|
||||
return response;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { Logger } from "@nhcarrigan/logger";
|
||||
export const logger = new Logger("Mommy", process.env.LOG_TOKEN ?? "");
|
||||
+6
-7
@@ -6,13 +6,12 @@
|
||||
|
||||
import { AtpAgent } from "@atproto/api";
|
||||
import pkg from "@slack/bolt";
|
||||
import { Client, Events, MessageFlags } from "discord.js";
|
||||
import { Client, Events } from "discord.js";
|
||||
import { scheduleJob } from "node-schedule";
|
||||
import { serve } from "./server/serve.js";
|
||||
import { getMommy } from "./utils/getMommy.js";
|
||||
import { logger } from "./utils/logger.js";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Classes.
|
||||
const { App, FileInstallationStore } = pkg;
|
||||
|
||||
const discord = new Client({ intents: [ ] });
|
||||
@@ -26,7 +25,7 @@ discord.on(Events.InteractionCreate, async(interaction) => {
|
||||
if (!interaction.isChatInputCommand()) {
|
||||
return;
|
||||
}
|
||||
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
||||
await interaction.deferReply();
|
||||
const name = interaction.options.getString("name");
|
||||
const response = await getMommy(name ?? undefined);
|
||||
await interaction.editReply(response);
|
||||
@@ -39,19 +38,19 @@ const slack = new App({
|
||||
installerOptions: {
|
||||
directInstall: true,
|
||||
},
|
||||
scopes: [ "commands" ],
|
||||
scopes: [ "commands", "chat:write" ],
|
||||
signingSecret: process.env.SLACK_SIGNING_SECRET ?? "",
|
||||
stateSecret: process.env.SLACK_STATE_SECRET ?? "",
|
||||
});
|
||||
|
||||
slack.command("/mommy", async({ ack, body, respond }) => {
|
||||
slack.command("/mommy", async({ ack, body, say }) => {
|
||||
await ack();
|
||||
const trimmed = body.text.trim();
|
||||
const name = trimmed.length > 0
|
||||
? trimmed
|
||||
: undefined;
|
||||
const response = await getMommy(name);
|
||||
await respond(response);
|
||||
await say(response);
|
||||
});
|
||||
|
||||
const bsky = new AtpAgent({
|
||||
@@ -74,7 +73,7 @@ scheduleJob("0 9 * * *", async() => {
|
||||
await bsky.post({
|
||||
text: response,
|
||||
});
|
||||
await logger.log("info", "Posted to bsky!");
|
||||
await logger.log("info", "Posted to bsky.social!");
|
||||
});
|
||||
|
||||
serve();
|
||||
|
||||
+28
-40
@@ -9,52 +9,40 @@ import { logger } from "../utils/logger.js";
|
||||
|
||||
const html = `<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Mommy Bot</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="Mommy loves you~!" />
|
||||
<script src="https://cdn.nhcarrigan.com/headers/index.js" async defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<head>
|
||||
<title>Mommy Bot</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="Mommy loves you~!" />
|
||||
<script src="https://cdn.nhcarrigan.com/headers/index.js" async defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Mommy Bot</h1>
|
||||
<img src="https://cdn.nhcarrigan.com/new-avatars/mommy-full.png" width="250" alt="Mommy" />
|
||||
<section>
|
||||
<p>Mommy loves you~!</p>
|
||||
<a href="https://mommy-slack.nhcarrigan.com/slack/install" style="display: inline-block; background-color: #ffffff; color: black; padding: 10px 20px; text-decoration: none; border-radius: 4px; margin: 5px;">
|
||||
<i class="fab fa-slack"></i> Add to Slack
|
||||
</a>
|
||||
<a href="https://discord.com/oauth2/authorize?client_id=1347642447643017289" class="social-button discord-button" style="display: inline-block; background-color: #5865F2; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; margin: 5px;">
|
||||
<i class="fab fa-discord"></i> Add to Discord
|
||||
</a>
|
||||
<a href="https://bsky.app/profile/mommy.naomi.party" class="social-button bluesky-button" style="display: inline-block; background-color: #0085FF; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; margin: 5px;">
|
||||
<i class="fab fa-bluesky"></i> Follow on Bluesky
|
||||
</a>
|
||||
<a href="https://mommy-slack.nhcarrigan.com/slack/install"><img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" /></a>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Links</h2>
|
||||
<p>
|
||||
<a href="https://git.nhcarrigan.com/nhcarrigan/mommy-bot">
|
||||
<i class="fa-solid fa-code"></i> Source Code
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://docs.nhcarrigan.com/">
|
||||
<i class="fa-solid fa-book"></i> Documentation
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://chat.nhcarrigan.com">
|
||||
<i class="fa-solid fa-circle-info"></i> Support
|
||||
</a>
|
||||
</p>
|
||||
<h2>Links</h2>
|
||||
<p>
|
||||
<a href="https://git.nhcarrigan.com/nhcarrigan/mommy-bot">
|
||||
<i class="fa-solid fa-code"></i> Source Code
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://docs.nhcarrigan.com/">
|
||||
<i class="fa-solid fa-book"></i> Documentation
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://chat.nhcarrigan.com">
|
||||
<i class="fa-solid fa-circle-info"></i> Support
|
||||
</a>
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user