{"id":25228113,"url":"https://github.com/david0z/express-api","last_synced_at":"2026-04-09T23:03:09.849Z","repository":{"id":274210352,"uuid":"921839350","full_name":"David0z/express-api","owner":"David0z","description":"Express, PostgreSQL, Typescript, JWT example Rest API","archived":false,"fork":false,"pushed_at":"2025-01-31T11:47:20.000Z","size":265,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T09:53:46.466Z","etag":null,"topics":["example-project","express","jwt","node","nodejs","postgresql","rest-api","sql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/David0z.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":"2025-01-24T18:01:03.000Z","updated_at":"2025-01-31T11:49:25.000Z","dependencies_parsed_at":"2025-01-31T12:43:01.888Z","dependency_job_id":null,"html_url":"https://github.com/David0z/express-api","commit_stats":null,"previous_names":["david0z/mysterious-express-api","david0z/express-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David0z%2Fexpress-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David0z%2Fexpress-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David0z%2Fexpress-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David0z%2Fexpress-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/David0z","download_url":"https://codeload.github.com/David0z/express-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345309,"owners_count":20924097,"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":["example-project","express","jwt","node","nodejs","postgresql","rest-api","sql","typescript"],"created_at":"2025-02-11T09:51:20.607Z","updated_at":"2026-04-09T23:03:09.792Z","avatar_url":"https://github.com/David0z.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express Api\n\nExpress, PostgreSQL, Typescript, JWT example Rest API\n\n## Installation\n\n### Easiest way:\n\n1. Install Docker:\n\nhttps://docs.docker.com/engine/install/\n\n2. In directory of cloned project folder run:\n\n```\n  docker-compose up\n```\n\nAnd wait for installation to finish.\n\nYou can check by visiting\n\n`localhost:8080/`\n\n## Usage\n\nTo be able to access user endpoints, you first need to generate a user token.\n\nYou do that by sending a POST request to the following endpoint:\n\n```\nlocalhost:8080/api/auth/register\n```\n\nAnd a required payload like the one below:\n\n```\n{\n    \"email\": \"test@example.com\",\n    \"password\": \"123456789\"\n}\n```\n\nYou'll receive an answer object like this:\n\n```\n{\n    \"message\": \"User registered successfully\",\n    \"token\": \"eyJhbGciOiJIUzI1NiIsInR...\"\n}\n```\n\n![App Screenshot](https://raw.githubusercontent.com/David0z/mysterious-express-api/refs/heads/main/screenshots/1.png)\n\nCopy the token value as it will be required in requests to user endpoints.\n\nNow you can try to create a new user with POST request to the route:\n\n```\nlocalhost:8080/api/user\n```\n\nWith this payload:\n\n```\n{\n    \"firstName\": \"Dawid\",\n    \"lastName\": \"Czesak\",\n    \"role\": \"admin\",\n    \"email\": \"test@test.com\"\n}\n```\n\n![App Screenshot](https://raw.githubusercontent.com/David0z/mysterious-express-api/refs/heads/main/screenshots/3.png)\n\nAnd with Bearer token in the \"Authorization\" header:\n\n```\nBearer eyJhbGciOiJIUzI1N...\n```\n\n![App Screenshot](https://raw.githubusercontent.com/David0z/mysterious-express-api/refs/heads/main/screenshots/2.png)\n\n### Tests\n\nTo run tests I run:\n\n- docker-compose -f docker-compose.test.yml up\n  (to set up seperate database)\n- npm install\n- [optional] npm start\n- npm run test (in seperate terminal)\n\n## API Reference\n\n### Auth API\n\n#### - Register User\n\n```http\n  POST /api/auth/register\n```\n\nJSON payload:\n\n```\n{\n    \"email\": string,  **required**\n    \"password\": string **required, at least 6 letters**\n}\n```\n\nExample JSON Response:\n\n```\n{\n    \"message\": \"User registered successfully\",\n    \"token\": \"eyJhbGciOiJIUzI1NiIs...\"\n}\n```\n\nSuccess response code: **201**\n\n#### - Login User\n\n```http\n  POST /api/auth/login\n```\n\nJSON payload:\n\n```\n{\n    \"email\": string,  **required**\n    \"password\": string **required**\n}\n```\n\nExample JSON Response:\n\n```\n{\n    \"token\": \"eyJhbGciOiJIUzI1NiIs...\"\n}\n```\n\nSuccess response code: **200**\n\n### User API\n\nEach of the following endpoints require a Bearer Token from **Auth** endpoint.\n\n#### - Create User\n\n```http\n  POST /api/user\n```\n\nJSON payload:\n\n```\n{\n    \"firstName\": string,\n    \"lastName\": string,\n    \"role\": string: \"admin\" | \"user\", **required**\n    \"email\": string  **required**\n}\n```\n\nSuccess response code: **201**\n\n#### - Get users\n\n```http\n  GET /api/users\n```\n\nExample JSON Response:\n\n```\n[\n  {\n    \"id\": 1,\n    \"firstName\": \"John\",\n    \"lastName\": \"Smith\",\n    \"email\": \"jsmith@gmail.com\",\n    \"role\": \"user\"\n  },\n  {\n    \"id\": 2,\n    \"firstName\": \"Jan\",\n    \"lastName\": \"Kowalski\",\n    \"email\": \"jkowalski@gmail.com\",\n    \"role\": \"admin\"\n  }\n]\n```\n\nSuccess response code: **200**\n\n#### - Get user\n\n```http\n  GET /api/user/${id}\n```\n\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `id`      | `string` | **Required**. Id of user to fetch |\n\nExample JSON Response:\n\n```\n{\n    \"id\": 3,\n    \"firstName\": \"\",\n    \"lastName\": \"\",\n    \"email\": \"example@gmail.com\",\n    \"role\": \"user\"\n  }\n```\n\nSuccess response code: **200**\n\n#### - Update User\n\n```http\n  PATCH /api/user/${id}\n```\n\n| Parameter | Type     | Description                        |\n| :-------- | :------- | :--------------------------------- |\n| `id`      | `string` | **Required**. Id of user to update |\n\nJSON payload:\n\n```\n{\n    \"firstName\": string,\n    \"lastName\": string,\n    \"role\": string: \"admin\" | \"user\"\n}\n```\n\nSuccess response code: **200**\n\n#### - Delete User\n\n```http\n  DELETE /api/user/${id}\n```\n\n| Parameter | Type     | Description                        |\n| :-------- | :------- | :--------------------------------- |\n| `id`      | `string` | **Required**. Id of user to delete |\n\nSuccess response code: **200**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid0z%2Fexpress-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavid0z%2Fexpress-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid0z%2Fexpress-api/lists"}