{"id":26491802,"url":"https://github.com/danielc92/bikeshare-api","last_synced_at":"2025-03-20T08:50:46.241Z","repository":{"id":39601632,"uuid":"274396937","full_name":"danielc92/bikeshare-api","owner":"danielc92","description":"A bike share REST-API, designed with Node.js, Typescript, TypeORM, Postgres \u0026 Docker","archived":false,"fork":false,"pushed_at":"2023-01-24T03:27:39.000Z","size":985,"stargazers_count":16,"open_issues_count":14,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T23:02:02.140Z","etag":null,"topics":["docker","postgresql","rest-api","side-project","typeorm","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/danielc92.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}},"created_at":"2020-06-23T12:14:30.000Z","updated_at":"2024-02-16T21:03:09.000Z","dependencies_parsed_at":"2023-02-13T15:31:29.323Z","dependency_job_id":null,"html_url":"https://github.com/danielc92/bikeshare-api","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/danielc92%2Fbikeshare-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielc92%2Fbikeshare-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielc92%2Fbikeshare-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielc92%2Fbikeshare-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielc92","download_url":"https://codeload.github.com/danielc92/bikeshare-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244583173,"owners_count":20476233,"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":["docker","postgresql","rest-api","side-project","typeorm","typescript"],"created_at":"2025-03-20T08:50:45.788Z","updated_at":"2025-03-20T08:50:46.235Z","avatar_url":"https://github.com/danielc92.png","language":"TypeScript","readme":"# Bikeshare API\n\nA bike share REST-API, designed with Node.js, Typescript, TypeORM, Postgres \u0026 Docker\n\n### Stack\n\n- Typescript\n- Node.js\n- TypeORM\n- Docker\n- Postgres\n\n### Getting started\n\nPrerequisites:\n- Install NVM node package manager\n- Install docker for desktop\n#### Node \n```\n# Using node package manager install version 12\nnvm install 12.0.0\n\nnvm use 12.0.0\n\n# You may check what version is currently being used with\nnvm list\n\n# you will need nodemon\nnpm i -g nodemon\n\n# install rest of dependencies\nnpm i\n```\n#### Running development server\n```\n# Start the docker postgres db\nnpm run db-start\n# Run the development api server\nnpm run dev\n```\n#### Testing the controllers\n```\n# Start the docker postgres db (if you haven't done so already)\nnpm run db-start\n# Running all tests\nnpm run test\n```\n\n#### Testing in postman\n- Import the collection from postman folder\n- Set `{{host}}` global variable to http://localhost:3050 (or whatever it is set to in `src/index.ts`)\n- Set `{{token}}` global variable if youre using authentication. This token is obtainable, each time a successful request to `{{host}}/auth/login` is made\n### Available Routes\n\n- /auth/login (allows Riders to authenticate and retrieve jwt token)\n- /rider (allows for create, delete, update, retrieval of Rider data)\n- /route (allows for create, delete, update, retrieval of Route data)\n- /pack (allows for create, delete, update, retrieval of Pack data)\n- /bike (allows for create, delete, update, retrieval of Bike data)\n- /contact (allows for create, delete, update, retrieval of Contact data)\n- /my-routes (allows for create, delete, retrieval of Rider-Route associations)\n- /my-packs (allows for create, delete, retrieval of Rider-Pack associations)\n\n### Configuration\n\nTypeORM configuration can be modified in `ormconfig.json` in root of project. Currently the project uses a docker/postgres setup for local development.\n\n### Examples\n\nLoading many to many\n\n```\nconst data = await connection\n    .getRepository(Rider)\n    .createQueryBuilder(\"rider\")\n    .leftJoinAndSelect(\"rider.routes\", \"route\")\n    .getMany();\n```\n\nSaving many to many\n\n```\nlet z = connection.getRepository(Route);\nlet results = await z.find();\nlet x = connection.getRepository(Rider);\nlet rider = await x.findOne();\nconsole.log(rider);\nrider.routes = results;\nawait connection.manager.save(rider);\n\n```\n\nDeleting many to many\n\n```\n  let aRider = await connection\n      .getRepository(Rider)\n      .findOne({ where: { id: 3 }, relations: [\"packs\"] });\n\n    aRider.packs = aRider.packs.filter((p) =\u003e p.id !== 3);\n    await connection.manager.save(aRider);\n```\n\n```sql\nINSERT INTO permission\n(\"apiRoute\", \"requestMethod\")\nVALUES\n('/bike', 'get'),('/bike', 'post'),('/bike', 'patch'),('/bike', 'delete'),\n('/bike/detail','get'),\n('/route', 'get'),('/route', 'post'),('/route', 'patch'),('/route', 'delete'),\n('/route/detail','get'),\n('/rider', 'get'),('/rider', 'post'),('/rider', 'patch'),('/rider', 'delete'),\n('/rider/detail','get'),\n('/brand', 'get'),('/brand', 'post'),('/brand', 'patch'),('/brand', 'delete'),\n('/brand/detail','get'),\n('/contact', 'get'),('/contact', 'post'),('/contact', 'patch'),('/contact', 'delete'),\n('/contact/detail','get'),\n('/pack', 'get'),('/pack', 'post'),('/pack', 'patch'),('/pack', 'delete'),\n('/pack/detail','get'),\n('/my-packs', 'get'),('/my-packs', 'patch'),('/my-packs', 'delete'),\n('/my-routes', 'get'),('/my-routes', 'patch'),('/my-routes', 'delete'),\n('/auth/login','post')\n;\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielc92%2Fbikeshare-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielc92%2Fbikeshare-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielc92%2Fbikeshare-api/lists"}