{"id":21338364,"url":"https://github.com/dukex/ely","last_synced_at":"2026-03-04T02:32:02.409Z","repository":{"id":40341956,"uuid":"505247607","full_name":"dukex/ely","owner":"dukex","description":"Run a api service inside the database","archived":false,"fork":false,"pushed_at":"2022-07-05T15:04:15.000Z","size":8086,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T20:08:21.621Z","etag":null,"topics":["api","api-rest","database","postgresql","serverless"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"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/dukex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["dukex"]}},"created_at":"2022-06-20T00:16:57.000Z","updated_at":"2022-07-01T07:29:58.000Z","dependencies_parsed_at":"2022-08-18T18:30:19.391Z","dependency_job_id":null,"html_url":"https://github.com/dukex/ely","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/dukex/ely","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dukex%2Fely","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dukex%2Fely/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dukex%2Fely/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dukex%2Fely/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dukex","download_url":"https://codeload.github.com/dukex/ely/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dukex%2Fely/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30070084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T01:03:42.280Z","status":"online","status_checked_at":"2026-03-04T02:00:07.464Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","api-rest","database","postgresql","serverless"],"created_at":"2024-11-22T00:14:38.680Z","updated_at":"2026-03-04T02:32:02.369Z","avatar_url":"https://github.com/dukex.png","language":"Go","funding_links":["https://github.com/sponsors/dukex"],"categories":[],"sub_categories":[],"readme":"# ELY\n\nELY is a toy project, please does not use it in production yer, the main idea is run a api service inside the database, a generic golang server is up but the functions to handle the endpoint is running in the any language supported by postgresql\n\n## Installation\n\nInstall ELY command package\n\n```\n$ go install github.com/dukex/ely/cmd/ely@latest\n```\n\nNow you can use `ely` command\n\n```\n$ ely\nELY is a tool for create a API service using database functions\n\nUsage:\n  ely [command]\n\nAvailable Commands:\n  completion  Generate the autocompletion script for the specified shell\n  db          Manage ELY database\n  deploy      Deploy functions to database\n  help        Help about any command\n  server      Run the ELY server\n\nFlags:\n  -h, --help   help for ely\n\nUse \"ely [command] --help\" for more information about a command.\n```\n\n## Usage\n\nThe ELY requires a up and running postgresql database, all commands depends of `DATABASE_URL` env proper configured.  \n\n```\nexport DATABASE_URL=postgresql://localhost:5433/ely?sslmode=disable\n```\n\n### Create the workdir\n\nLet's to create your project directory\n\n```\n$ mkdir -p awesome-db-api/functions\n```\n\n### Setup database\n\nNow we need setup the database, we will create the ELY types\n\n```\n$ ely db setup\n```\n\n### Create functions\n\nLet's to create the first and simpler function, the healthy status endpoint\n\n```\n$ touch functions/healthy.sql\n```\n\nOpen the `functions/healthy.sql` file and put the follow content:\n\n```\nCREATE OR REPLACE FUNCTION healthy()\n  RETURNS http_response\nAS $$\n    ely = GD['ely']\n    render_json = ely['render_json']\n\n    return render_json({ \"healthy\": True });\n$$ LANGUAGE plpython3u;\n```\n\nThis functions basically will responds the HTTP Status 200, with a JSON `{ \"healthy\": true }`.\n\nNow let's to deploy the function to the database:\n\n```\n$ ely deploy\n```\n\nDone! Your functions is ready to be used.\n\n### Setup an endpoint\n\nLet's to create a YAML to configure your API\n\n```\n$ touch ely.yml\n```\n\nThis will map the endpoints with the database functions, given we created the `healthy` previously let's to map this function to a endpoint. Edit the `ely.yml` as:\n\n```yaml\nendpoint:\n  - path: \"/health_status\"\n    function: 'healthy'\n```\n\n### Up and running server\n\nTo finish, we should up the server\n\n```\n$ ely server\nServer starring at 9001\n```\n\nNow you can access [localhost:9001/health_status](http://localhost:9001/health_status)\n\n## Complex examples\n\n**You can see more examples in the [examples](examples/) directory.**\n\nLet's to create a users index endpoint\n\n```\n$ touch functions/userindex.sql\n```\n\nOpen the `functions/userindex.sql` file and put the follow content:\n\n```\nCREATE OR REPLACE FUNCTION usersindex()\n  RETURNS http_response\nAS $$\n    ely = GD['ely']\n    render_json = ely['render_json']\n    params = ely['params']\n\n    enabled = params(\"enabled\")\n\n    plan = plpy.prepare(\"SELECT * FROM users WHERE enabled = $1\", [ \"boolean\" ])\n\n    users = plpy.execute(plan, [ enabled != 'false' ])\n\n    return render_json([dict(user) for user in users]) \n$$ LANGUAGE plpython3u;\n```\n\nAnd in the `ely.yml` file:\n\n```\nendpoint:\n  - path: \"/users\"\n    function: 'usersindex'\n````\n\nRun server:\n\n```\n$ ely server\n```\n\nAccess the endpoint [localhost:9001/users](http://localhost:9001/users). You can send the enabled query string params to see different results [localhost:9001/users?enabled=false](http://localhost:9001/users?enabled=false)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdukex%2Fely","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdukex%2Fely","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdukex%2Fely/lists"}