1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-03 13:46:38 -04:00

some error handling and cleanup

This commit is contained in:
2021-06-01 19:39:15 -04:00
parent 3fa058ee76
commit a4aab585ed
6 changed files with 59 additions and 27 deletions

View File

@ -21,7 +21,7 @@ Run `yarn install` ([Yarn must be installed](https://yarnpkg.com/en/docs/install
To ensure consistency and compatibility, the [`Dockerfile`](Dockerfile) in this repository will download the correct version of the Hugo Extended binary and its dependencies, and start a live testing server in a temporary container.
Using Docker doesn't require Node or Yarn, but you can also use `yarn start:docker` which is simply an alias for:
Using Docker doesn't require Node or Yarn, but you can also use `yarn docker` which is simply an alias for:
```bash
docker run --rm -v $(pwd):/src -p 1337:1337 $(docker build --no-cache -q .)

View File

@ -11,8 +11,25 @@ require("dotenv").config();
require("encoding");
exports.handler = async (event) => {
// some rudimentary error handling
const { slug } = event.queryStringParameters;
// some rudimentary error handling
if (!process.env.FAUNADB_SERVER_SECRET) {
return {
statusCode: 500,
body: JSON.stringify({
message: "Database credentials are missing.",
}),
};
}
if (event.httpMethod !== "GET") {
return {
statusCode: 400,
body: JSON.stringify({
message: `Method ${event.httpMethod} not allowed.`,
}),
};
}
if (!slug || slug === "/") {
return {
statusCode: 400,

View File

@ -8,9 +8,26 @@ const rssParser = require("rss-parser");
require("dotenv").config();
const baseUrl = "https://jarv.is/";
const feedUrl = "https://jarv.is/feed.xml";
exports.handler = async () => {
exports.handler = async (event) => {
// some rudimentary error handling
if (!process.env.FAUNADB_SERVER_SECRET) {
return {
statusCode: 500,
body: JSON.stringify({
message: "Fauna ",
}),
};
}
if (event.httpMethod !== "GET") {
return {
statusCode: 400,
body: JSON.stringify({
message: `Method ${event.httpMethod} not allowed.`,
}),
};
}
try {
const parser = new rssParser({
timeout: 3000,
@ -19,7 +36,7 @@ exports.handler = async () => {
secret: process.env.FAUNADB_SERVER_SECRET,
});
const feed = await parser.parseURL(feedUrl);
const feed = await parser.parseURL(baseUrl + "feed.xml");
const result = await client.query(
q.Map(
q.Paginate(q.Documents(q.Collection("hits"))),

View File

@ -170,6 +170,10 @@
from = "/jarvis.asc"
to = "/pubkey.asc"
status = 301
[[redirects]]
from = "/img/logo.svg"
to = "/img/favicon.svg"
status = 302
[[redirects]]
from = "/img/me_large.jpg"
to = "/img/me.jpg"
@ -182,6 +186,10 @@
from = "/me_large.jpg"
to = "/img/me.jpg"
status = 301
[[redirects]]
from = "/img/me_hu1c1a997e30e234e83718deb8b3f52283_130509_320x320_resize_q90_lanczos.jpg"
to = "/img/me.jpg"
status = 301
[[redirects]]
from = "/twemoji/svg/*"
to = "/vendor/emoji/svg/:splat"
@ -190,10 +198,6 @@
from = "/vendor/inter/*"
to = "/vendor/fonts/:splat"
status = 301
[[redirects]]
from = "/img/logo.svg"
to = "/img/favicon.svg"
status = 302
# Moved these random sites/projects elsewhere (mostly GitHub Pages) to keep
# this repo and domain squeaky clean:

View File

@ -15,14 +15,12 @@
},
"scripts": {
"clean": "rimraf public/ resources/ builds/ _vendor/ .netlify/{cache,functions}/ $TMPDIR/hugo_cache/ hugo_stats.json",
"build": "run-s build:** minify",
"build:hugo": "hugo --gc --cleanDestinationDir --verbose",
"build:functions": "netlify-lambda build functions",
"start": "run-p start:hugo start:functions",
"start": "run-p start:**",
"start:hugo": "hugo server --disableFastRender --buildDrafts --buildFuture --port=1337 --baseURL=/ --appendPort=false --bind=0.0.0.0 --verbose",
"start:functions": "netlify-lambda serve --port 9337 functions",
"start:docker": "docker run --rm -v $(pwd):/src:ro -p 1337:1337 $(docker build -q .)",
"minify": "run-s minify:**",
"build": "run-s build:** minify:**",
"build:hugo": "hugo --gc --cleanDestinationDir --verbose",
"build:functions": "netlify-lambda build functions",
"minify:html": "html-minifier --html5 --collapse-whitespace --collapse-boolean-attributes --preserve-line-breaks --minify-css --remove-comments --file-ext html --input-dir public --output-dir public **/*.html",
"minify:js": "terser --compress passes=3,negate_iife=false,keep_fargs=false,sequences=false,reduce_vars=false --mangle reserved=['sa','sa_event'] --output public/js/app.js -- public/js/app.js",
"minify:img": "glob-exec --parallel --foreach 'public/**/{img,images}/' -- imagemin '{{file.path}}*' --plugin=mozjpeg --plugin.mozjpeg.progressive --plugin.mozjpeg.quality=85 --plugin=pngquant --plugin.pngquant.quality={0.1,0.3} --plugin.pngquant.speed=1 --plugin.pngquant.strip --plugin=gifsicle --plugin=svgo --out-dir='{{file.path}}'",
@ -31,6 +29,7 @@
"lint:js": "eslint '**/*.js'",
"lint:md": "markdownlint 'content/**/*.md'",
"lint:prettier": "prettier --check .",
"docker": "docker run --rm -v $(pwd):/src:ro -p 1337:1337 $(docker build -q .)",
"percy": "npx percy snapshot"
},
"dependencies": {
@ -82,7 +81,7 @@
"stylelint-no-unsupported-browser-features": "~5.0.1",
"stylelint-prettier": "~1.2.0",
"stylelint-scss": "~3.19.0",
"terser": "^5.6.1"
"terser": "^5.7.0"
},
"optionalDependencies": {
"imagemin-gifsicle": "^7.0.0",

View File

@ -5584,22 +5584,17 @@ miller-rabin@^4.0.0:
bn.js "^4.0.0"
brorand "^1.0.1"
mime-db@1.47.0:
version "1.47.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.47.0.tgz#8cb313e59965d3c05cfbf898915a267af46a335c"
integrity sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==
mime-db@^1.28.0:
mime-db@1.48.0, mime-db@^1.28.0:
version "1.48.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.48.0.tgz#e35b31045dd7eada3aaad537ed88a33afbef2d1d"
integrity sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==
mime-types@~2.1.24:
version "2.1.30"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.30.tgz#6e7be8b4c479825f85ed6326695db73f9305d62d"
integrity sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==
version "2.1.31"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.31.tgz#a00d76b74317c61f9c2db2218b8e9f8e9c5c9e6b"
integrity sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==
dependencies:
mime-db "1.47.0"
mime-db "1.48.0"
mime@1.6.0:
version "1.6.0"
@ -8092,7 +8087,7 @@ terser@^4.1.2:
source-map "~0.6.1"
source-map-support "~0.5.12"
terser@^5.6.1:
terser@^5.7.0:
version "5.7.0"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.0.tgz#a761eeec206bc87b605ab13029876ead938ae693"
integrity sha512-HP5/9hp2UaZt5fYkuhNBR8YyRcT8juw8+uFbAme53iN9hblvKnLUTKkmwJG6ocWpIKf8UK4DoeWG4ty0J6S6/g==