{"id":13598971,"url":"https://github.com/guyromm/svelte-postgrest-template","last_synced_at":"2025-04-10T10:30:48.417Z","repository":{"id":47439962,"uuid":"257286494","full_name":"guyromm/svelte-postgrest-template","owner":"guyromm","description":"Svelte/SvelteKit + PostgREST + EveryLayout + social auth starter template","archived":false,"fork":false,"pushed_at":"2024-01-18T14:30:50.000Z","size":911,"stargazers_count":60,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-06T23:40:58.257Z","etag":null,"topics":["everylayout","facebook-login","google-authenticator","jwt","postgresql","postgrest","sapper","sapper-template","svelte","svelte-template"],"latest_commit_sha":null,"homepage":"","language":"Svelte","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guyromm.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-20T13:16:58.000Z","updated_at":"2024-11-05T17:30:22.000Z","dependencies_parsed_at":"2024-11-06T23:47:41.959Z","dependency_job_id":null,"html_url":"https://github.com/guyromm/svelte-postgrest-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyromm%2Fsvelte-postgrest-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyromm%2Fsvelte-postgrest-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyromm%2Fsvelte-postgrest-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guyromm%2Fsvelte-postgrest-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guyromm","download_url":"https://codeload.github.com/guyromm/svelte-postgrest-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199136,"owners_count":21063641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["everylayout","facebook-login","google-authenticator","jwt","postgresql","postgrest","sapper","sapper-template","svelte","svelte-template"],"created_at":"2024-08-01T17:00:58.616Z","updated_at":"2025-04-10T10:30:47.347Z","avatar_url":"https://github.com/guyromm.png","language":"Svelte","funding_links":[],"categories":["🏃 SvelteKit Starter Kits and Integrations"],"sub_categories":["The _How To's?_"],"readme":"* what \u0026 why?\n- [[https://svelte.dev/][svelte]] is the hot new FE dev stuff. do [[https://svelte.dev/tutorial/basics][the tutorial]] to get hooked. [[https://kit.svelte.dev/][SvelteKit]] - its equivalent of SSR\n  framework, not unlike next.js\n- [[http://postgrest.org/][postgrest]] is a really nice backend to quickly prototype apps by\n  definining data \u0026 permissions, without having to write backend.\n- [[https://every-layout.dev/][every layout]] is a fresh approach to plain css, with reusable components that make sense. borrowed from [[https://github.com/SilvanCodes/svelte-layout-components][SilvanCodes/svelte-layout-components]].\n- some social login love thrown in for good measure, uses [[https://github.com/beyonk-adventures/svelte-social-auth][beyonk-adventures/svelte-social-auth]]\n- tmux is used to run multiple processes and an editor, because nothing beats tmux and emacs (use [[http://web-mode.org/][web-mode]] to edit svelte!)\n* prequisites for dev env\n1. [[https://github.com/PostgREST/postgrest/releases/latest][postgrest]] - install according to [[http://postgrest.org/en/v6.0/tutorials/tut0.html][instructions]].\n   1. [[https://github.com/michelp/pgjwt][pgjwt]] - postgresql jwt extension for postgrest auth\n2. [[https://github.com/nvm-sh/nvm][nvm]] - to easily swap node/npm versions. tested with node v13.11.0.\n* cloning\n#+BEGIN_SRC bash\nnpx degit https://github.com/guyromm/svelte-postgrest-template svelte-postgrest-app\n#+END_SRC\n* package.json dependencies\n#+BEGIN_SRC bash\nnvm use ; ./npm-init.sh\n#+END_SRC\n\n* .env\n  use envs/local.tpl to create an envs/local .env shell file, and then\n  expand/eval it using ./setenv.sh\n#+BEGIN_SRC bash\n    function freeport() {\n\tFROM=$1\n\tTO=$2\n\tHOWMANY=$3\n\tcomm -23 \\\n\t     \u003c(seq \"$FROM\" \"$TO\" | sort) \\\n\t     \u003c(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) \\\n\t    | shuf | head -n \"$HOWMANY\"\n    }\n  export APPNAME=$(basename $(pwd))\n  export DBNAME=$APPNAME\n  export APPPORT=$(freeport 3000 4000 1)\n  export POSTGRESTPORT=$[APPPORT+1]\n  export SERVERPORT=$[APPPORT+2]\n  export JWTSECRET=$(head /dev/urandom | tr -dc A-F0-9 | head -c 64 ; echo '')\n\n  cp envs/local.tpl envs/local\n  sed -i -E \"s/APPPORTREPLACE/$APPPORT/g\" envs/local\n  sed -i -E \"s/SERVERPORTREPLACE/$SERVERPORT/g\" envs/local\n  sed -i -E \"s/POSTGRESTPORTREPLACE/$POSTGRESTPORT/g\" envs/local\n  sed -i -E \"s/DBNAMEREPLACE/$DBNAME/g\" envs/local\n  sed -i -E \"s/JWTSECRETREPLACE/$JWTSECRET/g\" envs/local\n  ./setenv.sh local\n#+END_SRC\n\n* deploying on aws\n** create a separate env\n#+BEGIN_SRC bash\ntest -f envs/aws || cp envs/local envs/aws\nsed -i -E \"s/^RDS=''$/RDS=1/g\" envs/aws\necho POSTGREST_PATH_AS_ARG=1 \u003e\u003e envs/aws\necho 'VITE_POSTGREST_PATH_AS_ARG=$POSTGREST_PATH_AS_ARG' \u003e\u003e envs/aws\nRDS_PASSWORD=$(tr -dc A-Za-z0-9 \u003c/dev/urandom | head -c 16 ; echo '')\naws rds describe-db-subnet-groups | tee /tmp/sng.json\negrep '^RDS_VPC_GROUP=(.+)$' envs/aws || echo 'RDS_VPC_GROUP='$(aws rds describe-db-subnet-groups | jq '.DBSubnetGroups[]|select(.DBSubnetGroupName | startswith(\"default-vpc-\")).DBSubnetGroupName' -r) \u003e\u003e envs/aws\negrep '^RDS_PASSWORD=(.+)$' envs/aws || echo \"RDS_PASSWORD=$RDS_PASSWORD\" \u003e\u003e envs/aws\n./setenv.sh aws\nlambda/postgrest-download.sh\n#+END_SRC\n\n** create the rds\n#+BEGIN_SRC bash\negrep '^RDS_HOSTNAME=(.+)$' envs/aws || (./lambda/rds-create.sh | egrep '^RDS_HOSTNAME=' | tee -a envs/aws\necho 'DBURIADMIN=\"postgres://postgres:$RDS_PASSWORD@$RDS_HOSTNAME/template1\"' | tee -a envs/aws\necho 'DBURI=\"postgres://postgres:$RDS_PASSWORD@$RDS_HOSTNAME/\"' | tee -a envs/aws\n)\n./setenv.sh aws\n#+END_SRC\n** create \u0026 deploy the lambda func\n#+BEGIN_SRC bash\nsource .env\negrep '^LAMBDA_ROLE=(.+)$' envs/aws || (\naws iam create-role --role-name $APPNAME --assume-role-policy-document file://lambda/trust-policy.tpl.json | tee envs/$ENV.role.json\naws iam attach-role-policy --role-name $APPNAME --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole\n)\negrep '^LAMBDA_ROLE=(.+)$' envs/aws \u0026\u0026 echo 'LAMBDA_ROLE_ALREADY_SET' || (test -f envs/$ENV.role.json \u0026\u0026 (echo LAMBDA_ROLE=$(jq .Role.Arn envs/$ENV.role.json -r) | tee -a envs/aws) || echo 'NO_ROLE_FILE')\n./setenv.sh aws\nsource .env\nlambda/pack.sh\naws lambda create-function --function-name $APPNAME-postgrest --runtime nodejs14.x --role \"$LAMBDA_ROLE\" --zip-file fileb://lambda/function.zip --handler index.handler --timeout 15 | tee envs/$ENV.lambda.json\negrep '^AWS_POSTGREST_LAMBDA_FUNC=(.+)$' envs/aws || echo 'AWS_POSTGREST_LAMBDA_FUNC='$(jq .FunctionName envs/$ENV.lambda.json -r) | tee -a envs/aws\naws lambda create-function-url-config --function-name $APPNAME-postgrest --auth-type NONE --cors 'AllowOrigins=*' | tee envs/$ENV.lambda.url.json\ntest -f envs/$ENV.lambda.url.json \u0026\u0026 sed -i -E 's/^POSTGREST_BASE_URI=(.*)$/POSTGREST_BASE_URI=\"'$(jq .FunctionUrl envs/$ENV.lambda.url.json -r | sed -E 's/\\//\\\\\\//g')'\"/g' envs/aws\n#+END_SRC\n* database initialization\n#+BEGIN_SRC bash\n  source .env\n  echo 'DBNAME:'$DBNAME\n  ./db_init.sh\n#+END_SRC\n* launch\n#+BEGIN_SRC bash\n./tmux.sh\n#+END_SRC\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguyromm%2Fsvelte-postgrest-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguyromm%2Fsvelte-postgrest-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguyromm%2Fsvelte-postgrest-template/lists"}