{"id":20365607,"url":"https://github.com/hackyourfuture/project-api","last_synced_at":"2025-09-01T20:09:32.032Z","repository":{"id":74102005,"uuid":"89814318","full_name":"HackYourFuture/project-api","owner":"HackYourFuture","description":null,"archived":false,"fork":false,"pushed_at":"2017-04-30T19:02:11.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-16T06:06:56.826Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/HackYourFuture.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,"zenodo":null}},"created_at":"2017-04-29T21:37:29.000Z","updated_at":"2017-04-29T21:37:43.000Z","dependencies_parsed_at":"2023-04-09T18:46:47.103Z","dependency_job_id":null,"html_url":"https://github.com/HackYourFuture/project-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HackYourFuture/project-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackYourFuture%2Fproject-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackYourFuture%2Fproject-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackYourFuture%2Fproject-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackYourFuture%2Fproject-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HackYourFuture","download_url":"https://codeload.github.com/HackYourFuture/project-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackYourFuture%2Fproject-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273183228,"owners_count":25059812,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"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":[],"created_at":"2024-11-15T00:19:03.121Z","updated_at":"2025-09-01T20:09:32.007Z","avatar_url":"https://github.com/HackYourFuture.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HackYourFuture Project-api\n\nThis is a HYF Project boilerplate for building a REST API. Let's refresh our minds on this. [READ THIS SO POST](http://stackoverflow.com/questions/671118/what-exactly-is-restful-programming)\n\n## Getting started\nBefore getting started with this repo, read and repeat the \"Getting started\" part of the [Angular WebApp Repo](https://github.com/HackYourFuture/project-webapp-angular), and get ready to collaborate in your team\n\n## Step 1: Requirements\nMake sure you have these 4 installed\n- [Node.js version 7.3.0 or higher](https://nodejs.org/en/) (easily manage Node version with [NVM](https://github.com/creationix/nvm/blob/master/README.md))\n- [Docker](https://www.docker.com/community-edition#/download)\n- (Windows users only) [Bash](https://www.howtogeek.com/261591/how-to-create-and-run-bash-shell-scripts-on-windows-10/)\n\n## Step 2: Install\nClone your copy of this repo as explained [Angular WebApp Repo](https://github.com/HackYourFuture/project-webapp-angular). Then:\n```\n// find where you cloned the repo\ncd project-api/\nnpm install // Install NPM dependencies\nsh database/create_database.sh // Install database\n```\n\n## Step 3: Start the api\n```\nnpm start\n```\n\n## Step 4: Read essential docs of these software packages\n- [node-db-migrate](https://db-migrate.readthedocs.io/en/latest/) for managing the database structure using migrations\n- [expressjs](http://expressjs.com/) for routing\n- [mysql2](https://github.com/sidorares/node-mysql2) for talking to MySQL with promise support\n- [dotenv](https://github.com/motdotla/dotenv) for saving passwords etc safely.\n\nNice to read but not required to work:\n- [Docker](https://www.docker.com/what-docker)\n\n\n## Step 5: Try it out (1): Create a MySQL schema\nTry to make a new entity (e.g. \"products\") and its MySQL table\n- Go to `package.json` and checkout the `scripts` section. It contains a couple of commands that can execute `node-db-migrate` commands. The most essential ones are: `node run migrate-up` `node run migrate-down` `node run create-migration {{migration-name}}`\n- Check if the database is running. Try to connect to the database by running `sh database/connect_database.sh` If it doesn't work, rerun the `sh database/create_database.sh` script to start the db. To see if the mysql docker container is running you can type `docker ps`\n- To create a new table we run `npm run create-migration products`\n- Go to `./database/migrations/sqls/#####-products-up.sql`\n- Write `CREATE TABLE products` command with some fields\n- DO NOT FORGET EVER, write the DOWN command by opening the `./database/migrations/sqls/#####-products-down.sql` and writing `DROP TABLE products`. The down migration is always the command that undos the up command`\n- Save both migrations\n- Run `npm run migrate-up`\n- Unless you get errors, your table should be created!\n## Step 6: Try it out (2):  Write a route\nTry to make a new entity (e.g. \"products\") and its corresponding route\n- Create a file under `./lib/routers` and call it `products.js`\n- Take a look at `students.js` or `teachers.js`. What the file does is: start a new `express.Router()` object, add some routes to it (e.g. `router.get` or `router.post` and then export that router). Do the same for `products.js`.\n- Add the file to the main express application in `./lib/app.js` by requiring it and giving it a path. Under routers, we define the base path to which our products router will be added. Express will \"merge\" paths from the main router with the child `products` router.\n- Try it out! go to your new path in your browser or using `curl -XGET 'localhost:3000/api/v1/products'`\n\n\n## (Optional) Connect to MySQL DB from the CLI\n```\n// Shell:\nsh database/connect_database.sh\n\n// Once connected\nUSE hyf_db;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackyourfuture%2Fproject-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackyourfuture%2Fproject-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackyourfuture%2Fproject-api/lists"}