{"id":15994280,"url":"https://github.com/pixelhandler/blog-api","last_synced_at":"2025-04-05T00:16:02.882Z","repository":{"id":31394440,"uuid":"34957612","full_name":"pixelhandler/blog-api","owner":"pixelhandler","description":"JSON API following jsonapi.org spec for a blog application with auth for creating and editing post resources","archived":false,"fork":false,"pushed_at":"2023-07-22T01:30:02.000Z","size":654,"stargazers_count":6,"open_issues_count":6,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T08:31:24.876Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pixelhandler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2015-05-02T17:53:47.000Z","updated_at":"2023-07-20T07:25:11.000Z","dependencies_parsed_at":"2024-12-18T04:41:31.812Z","dependency_job_id":"1595555d-c833-4d49-b6fa-329c4efbd555","html_url":"https://github.com/pixelhandler/blog-api","commit_stats":{"total_commits":48,"total_committers":3,"mean_commits":16.0,"dds":"0.39583333333333337","last_synced_commit":"59f001ef7ab3b4b033d20288de9bb2d1dce7d145"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelhandler%2Fblog-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelhandler%2Fblog-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelhandler%2Fblog-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelhandler%2Fblog-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixelhandler","download_url":"https://codeload.github.com/pixelhandler/blog-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266568,"owners_count":20910837,"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":[],"created_at":"2024-10-08T07:08:05.721Z","updated_at":"2025-04-05T00:16:02.865Z","avatar_url":"https://github.com/pixelhandler.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blog API\n\nJSON API following [jsonapi.org] spec for a blog application with auth for creating and editing post resources\n\n* .ruby-version is setup for 3.0.6\n* Serialization of models (to JSON) is done with the [jsonapi-resources] gem\n  * Use ActiveRecord and the `pg` gem for [PostgreSQL]\n\n## Setup\n\n* `bundle` to install the gems\n* `mkdir -p shared/log \u0026\u0026 mkdir -p shared/pids \u0026\u0026 mkdir -p shared/sockets`\n\n### Config\n\nCopy the config/database.example.yml config/secrets.example.yml files to:\nconfig/database.yml config/secrets.yml\n\nIn the database.example.yml file the password is set to and environemnt variables:\nBLOG_API_DB_USR and BLOG_API_DB_PWORD. set your environment variables, or replace them\nwith your db credentials\n\n    export BLOG_API_DB_USR='blog_api'\n    export BLOG_API_DB_PWORD='XXXX'\n\n* DB role 'blog_api'\n\nSetup a Postgress role: 'blog_api'\n\n    createuser -P -s -e blog_api\n    createdb blog_api_development -O blog_api\n\nOr,\n\n    PGUSER=$BLOG_API_DB_USR PGPASSWORD=$BLOG_API_DB_PWORD psql -h localhost -p 5432 blog_api_development\n\n    CREATE ROLE blog_api WITH SUPERUSER LOGIN PASSWORD 'X';\n    CREATE DATABASE blog_api_development OWNER blog_api;\n    CREATE DATABASE blog_api_test OWNER blog_api;\n\n\n* `bundle exec rake db:setup`\n* See the seeds file to create resources for a post, author, and user\n\n### Seeds\n\nCopy the db/seeds.example.rb and add records for an user, author and posts\n\n## Restore DB from production\n\n1) Use tunnel\n\n    ssh -fNg -L 54321:127.0.0.1:5432 pixelhandler.com\n    lsof -i tcp | grep ^ssh\n\n2) Dump database (use pword from prod)\n\n    current_time=$(date \"+%Y.%m.%d-%H.%M.%S\"); pg_dump -U $BLOG_API_DB_PROD_USR -h localhost -p 54321 $BLOG_API_DB_PROD \u003e $BLOG_API_DB_PROD\".\"$current_time\".sql\"\n\n3) Drop and create\n\n    bin/rails db:drop\n    bin/rails db:create\n\n4) Import\n\n    PGUSER=$BLOG_API_DB_USR PGPASSWORD=$BLOG_API_DB_PWORD psql -h localhost -p $BLOG_API_DB_PORT blog_api_development \u003c blog_api_production.sql\n\n## Docker For PostgreSQL\n\n- https://docs.docker.com/engine/examples/postgresql_service/#installing-postgresql-on-docker\n\n    docker build -t eg_postgresql .\n    docker run --rm -P --name pg_test eg_postgresql\n    docker ps\n    psql -h localhost -p 32768 -d docker -U docker --password\n\n`docker` is the pword.\n\n## Notes / Reference\n\n* Slugs: \u003chttp://code-worrier.com/blog/custom-slugs-in-rails/\u003e\n* Token Auth:\n  * \u003chttp://adamalbrecht.com/2014/12/04/add-json-web-token-authentication-to-your-angular-rails-app/\u003e\n  * \u003chttp://robert-reiz.com/2014/04/12/has_secure_password-with-rails-4-1/\u003e\n\n[jsonapi.org]: http://jsonapi.org\n[PostgreSQL]: http://www.postgresql.org\n[jsonapi-resources]: https://github.com/cerebris/jsonapi-resources\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelhandler%2Fblog-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixelhandler%2Fblog-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelhandler%2Fblog-api/lists"}