mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-07-27 12:56:03 -04:00
some error handling and cleanup
This commit is contained in:
@@ -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.
|
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
|
```bash
|
||||||
docker run --rm -v $(pwd):/src -p 1337:1337 $(docker build --no-cache -q .)
|
docker run --rm -v $(pwd):/src -p 1337:1337 $(docker build --no-cache -q .)
|
||||||
|
|||||||
+18
-1
@@ -11,8 +11,25 @@ require("dotenv").config();
|
|||||||
require("encoding");
|
require("encoding");
|
||||||
|
|
||||||
exports.handler = async (event) => {
|
exports.handler = async (event) => {
|
||||||
// some rudimentary error handling
|
|
||||||
const { slug } = event.queryStringParameters;
|
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 === "/") {
|
if (!slug || slug === "/") {
|
||||||
return {
|
return {
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
|
|||||||
+20
-3
@@ -8,9 +8,26 @@ const rssParser = require("rss-parser");
|
|||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
|
|
||||||
const baseUrl = "https://jarv.is/";
|
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 {
|
try {
|
||||||
const parser = new rssParser({
|
const parser = new rssParser({
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
@@ -19,7 +36,7 @@ exports.handler = async () => {
|
|||||||
secret: process.env.FAUNADB_SERVER_SECRET,
|
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(
|
const result = await client.query(
|
||||||
q.Map(
|
q.Map(
|
||||||
q.Paginate(q.Documents(q.Collection("hits"))),
|
q.Paginate(q.Documents(q.Collection("hits"))),
|
||||||
|
|||||||
+8
-4
@@ -170,6 +170,10 @@
|
|||||||
from = "/jarvis.asc"
|
from = "/jarvis.asc"
|
||||||
to = "/pubkey.asc"
|
to = "/pubkey.asc"
|
||||||
status = 301
|
status = 301
|
||||||
|
[[redirects]]
|
||||||
|
from = "/img/logo.svg"
|
||||||
|
to = "/img/favicon.svg"
|
||||||
|
status = 302
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/img/me_large.jpg"
|
from = "/img/me_large.jpg"
|
||||||
to = "/img/me.jpg"
|
to = "/img/me.jpg"
|
||||||
@@ -182,6 +186,10 @@
|
|||||||
from = "/me_large.jpg"
|
from = "/me_large.jpg"
|
||||||
to = "/img/me.jpg"
|
to = "/img/me.jpg"
|
||||||
status = 301
|
status = 301
|
||||||
|
[[redirects]]
|
||||||
|
from = "/img/me_hu1c1a997e30e234e83718deb8b3f52283_130509_320x320_resize_q90_lanczos.jpg"
|
||||||
|
to = "/img/me.jpg"
|
||||||
|
status = 301
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/twemoji/svg/*"
|
from = "/twemoji/svg/*"
|
||||||
to = "/vendor/emoji/svg/:splat"
|
to = "/vendor/emoji/svg/:splat"
|
||||||
@@ -190,10 +198,6 @@
|
|||||||
from = "/vendor/inter/*"
|
from = "/vendor/inter/*"
|
||||||
to = "/vendor/fonts/:splat"
|
to = "/vendor/fonts/:splat"
|
||||||
status = 301
|
status = 301
|
||||||
[[redirects]]
|
|
||||||
from = "/img/logo.svg"
|
|
||||||
to = "/img/favicon.svg"
|
|
||||||
status = 302
|
|
||||||
|
|
||||||
# Moved these random sites/projects elsewhere (mostly GitHub Pages) to keep
|
# Moved these random sites/projects elsewhere (mostly GitHub Pages) to keep
|
||||||
# this repo and domain squeaky clean:
|
# this repo and domain squeaky clean:
|
||||||
|
|||||||
+6
-7
@@ -15,14 +15,12 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf public/ resources/ builds/ _vendor/ .netlify/{cache,functions}/ $TMPDIR/hugo_cache/ hugo_stats.json",
|
"clean": "rimraf public/ resources/ builds/ _vendor/ .netlify/{cache,functions}/ $TMPDIR/hugo_cache/ hugo_stats.json",
|
||||||
"build": "run-s build:** minify",
|
"start": "run-p start:**",
|
||||||
"build:hugo": "hugo --gc --cleanDestinationDir --verbose",
|
|
||||||
"build:functions": "netlify-lambda build functions",
|
|
||||||
"start": "run-p start:hugo start:functions",
|
|
||||||
"start:hugo": "hugo server --disableFastRender --buildDrafts --buildFuture --port=1337 --baseURL=/ --appendPort=false --bind=0.0.0.0 --verbose",
|
"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:functions": "netlify-lambda serve --port 9337 functions",
|
||||||
"start:docker": "docker run --rm -v $(pwd):/src:ro -p 1337:1337 $(docker build -q .)",
|
"build": "run-s build:** minify:**",
|
||||||
"minify": "run-s 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: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: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}}'",
|
"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:js": "eslint '**/*.js'",
|
||||||
"lint:md": "markdownlint 'content/**/*.md'",
|
"lint:md": "markdownlint 'content/**/*.md'",
|
||||||
"lint:prettier": "prettier --check .",
|
"lint:prettier": "prettier --check .",
|
||||||
|
"docker": "docker run --rm -v $(pwd):/src:ro -p 1337:1337 $(docker build -q .)",
|
||||||
"percy": "npx percy snapshot"
|
"percy": "npx percy snapshot"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -82,7 +81,7 @@
|
|||||||
"stylelint-no-unsupported-browser-features": "~5.0.1",
|
"stylelint-no-unsupported-browser-features": "~5.0.1",
|
||||||
"stylelint-prettier": "~1.2.0",
|
"stylelint-prettier": "~1.2.0",
|
||||||
"stylelint-scss": "~3.19.0",
|
"stylelint-scss": "~3.19.0",
|
||||||
"terser": "^5.6.1"
|
"terser": "^5.7.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"imagemin-gifsicle": "^7.0.0",
|
"imagemin-gifsicle": "^7.0.0",
|
||||||
|
|||||||
@@ -5584,22 +5584,17 @@ miller-rabin@^4.0.0:
|
|||||||
bn.js "^4.0.0"
|
bn.js "^4.0.0"
|
||||||
brorand "^1.0.1"
|
brorand "^1.0.1"
|
||||||
|
|
||||||
mime-db@1.47.0:
|
mime-db@1.48.0, mime-db@^1.28.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:
|
|
||||||
version "1.48.0"
|
version "1.48.0"
|
||||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.48.0.tgz#e35b31045dd7eada3aaad537ed88a33afbef2d1d"
|
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.48.0.tgz#e35b31045dd7eada3aaad537ed88a33afbef2d1d"
|
||||||
integrity sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==
|
integrity sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==
|
||||||
|
|
||||||
mime-types@~2.1.24:
|
mime-types@~2.1.24:
|
||||||
version "2.1.30"
|
version "2.1.31"
|
||||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.30.tgz#6e7be8b4c479825f85ed6326695db73f9305d62d"
|
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.31.tgz#a00d76b74317c61f9c2db2218b8e9f8e9c5c9e6b"
|
||||||
integrity sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==
|
integrity sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==
|
||||||
dependencies:
|
dependencies:
|
||||||
mime-db "1.47.0"
|
mime-db "1.48.0"
|
||||||
|
|
||||||
mime@1.6.0:
|
mime@1.6.0:
|
||||||
version "1.6.0"
|
version "1.6.0"
|
||||||
@@ -8092,7 +8087,7 @@ terser@^4.1.2:
|
|||||||
source-map "~0.6.1"
|
source-map "~0.6.1"
|
||||||
source-map-support "~0.5.12"
|
source-map-support "~0.5.12"
|
||||||
|
|
||||||
terser@^5.6.1:
|
terser@^5.7.0:
|
||||||
version "5.7.0"
|
version "5.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.0.tgz#a761eeec206bc87b605ab13029876ead938ae693"
|
resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.0.tgz#a761eeec206bc87b605ab13029876ead938ae693"
|
||||||
integrity sha512-HP5/9hp2UaZt5fYkuhNBR8YyRcT8juw8+uFbAme53iN9hblvKnLUTKkmwJG6ocWpIKf8UK4DoeWG4ty0J6S6/g==
|
integrity sha512-HP5/9hp2UaZt5fYkuhNBR8YyRcT8juw8+uFbAme53iN9hblvKnLUTKkmwJG6ocWpIKf8UK4DoeWG4ty0J6S6/g==
|
||||||
|
|||||||
Reference in New Issue
Block a user