{"id":15576744,"url":"https://github.com/icepick4/capitalympics-api","last_synced_at":"2025-04-09T18:08:41.958Z","repository":{"id":156588666,"uuid":"613023917","full_name":"icepick4/capitalympics-api","owner":"icepick4","description":"API for capitalympics","archived":false,"fork":false,"pushed_at":"2024-07-10T12:09:02.000Z","size":471,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T20:04:20.092Z","etag":null,"topics":["api","capital","capitals","data","database","docker","express","fast","flag","flags","manage","node","users"],"latest_commit_sha":null,"homepage":"https://capitalympics.com","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/icepick4.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":"2023-03-12T17:10:16.000Z","updated_at":"2024-07-10T12:09:04.000Z","dependencies_parsed_at":"2024-01-15T10:43:14.964Z","dependency_job_id":"4712252e-8798-46c0-8eae-efd7d74dd83d","html_url":"https://github.com/icepick4/capitalympics-api","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icepick4%2Fcapitalympics-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icepick4%2Fcapitalympics-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icepick4%2Fcapitalympics-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icepick4%2Fcapitalympics-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icepick4","download_url":"https://codeload.github.com/icepick4/capitalympics-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248084332,"owners_count":21045125,"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":["api","capital","capitals","data","database","docker","express","fast","flag","flags","manage","node","users"],"created_at":"2024-10-02T18:55:53.339Z","updated_at":"2025-04-09T18:08:41.935Z","avatar_url":"https://github.com/icepick4.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Capitalympis API\n\nThis is an API built with Node.js, Express, Prisma and MySQL to manage users and their scores for the [Capitalympics](https://github.com/icepick4/capitalympics) project.\n\n## Endpoints\n\n- `/api`: Authentication and user management routes. Here, we log the user, refresh their tokens, manage their accounts (delete and update).\n- `/api/continents`: Provides raw data for continents, which is then stored on the front-end.\n- `/api/regions`: Provides raw data for regions, which is then stored on the front-end.\n- `/api/countries`: Provides raw data for countries, which is then stored on the front-end.\n- `/api/questions`: Handles user responses, helps retrieve the best questions based on previous answers. This route involves significant backend calculations.\n- `/api/scores`: Retrieves calculated scores for a user, provides overall scores, and allows score resetting.\n- `/api/users`: Route for user registration only.\n\n## Dev\n\nThis project is not meant to be run locally but you can still do it, you need : \n\n- A file `.env` containing your database connection, such as : \n```\nPORT=XXXX\nDB_HOST=localhost\nDB_USER=username\nDB_PWD=password\nDB_NAME=database\nJWT_TOKEN=token\nDATABASE_URL=database url\n```\n(or see [example](.env.example))\n  \n- A mysql database with the correct tables :\n\n\u003cdetails\u003e\n\u003csummary\u003eUsers :\u003c/summary\u003e\n\n| Name          | Type         | Key |\n| ------------- | ------------ | --- |\n| id            | Int          | PK  |\n| name          | String       |     |\n| password      | String       |     |\n| created_at    | DateTime     |     |\n| updated_at    | DateTime     |     |\n| language      | Language     |     |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eContinent :\u003c/summary\u003e\n\n| Name          | Type         | Key |\n| ------------- | ------------ | --- |\n| id            | Int          | PK  |\n| name          | Json         |     |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCountry :\u003c/summary\u003e\n\n| Name            | Type         | Key |\n| --------------- | ------------ | --- |\n| id              | Int          | PK  |\n| code            | String       |     |\n| name            | Json         |     |\n| capital         | Json         |     |\n| official_name   | Json         |     |\n| region_id       | Int          |     |\n| population      | Int          |     |\n| google_maps_link| String        |     |\n| flag            | String        |     |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCountryCurrency :\u003c/summary\u003e\n\n| Name          | Type         | Key |\n| ------------- | ------------ | --- |\n| id            | Int          | PK  |\n| country_id    | Int          |     |\n| currency_id   | Int          |     |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCurrency :\u003c/summary\u003e\n\n| Name          | Type         | Key |\n| ------------- | ------------ | --- |\n| id            | Int          | PK  |\n| name          | String       |     |\n| symbol        | String       |     |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRegion :\u003c/summary\u003e\n\n| Name          | Type         | Key |\n| ------------- | ------------ | --- |\n| id            | Int          | PK  |\n| name          | Json         |     |\n| continent_id  | Int          |     |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eQuestionResult :\u003c/summary\u003e\n\n| Name          | Type         | Key |\n| ------------- | ------------ | --- |\n| id            | Int          | PK  |\n| user_id       | Int          |     |\n| country_id    | Int          |     |\n| learning_type | LearningType |     |\n| result        | Score        |     |\n| created_at    | DateTime     |     |\n\n\u003c/details\u003e\n\nWith these types :\n\n```javascript\nenum Language {\n  en\n  es\n  it\n  fr\n}\n\nenum LearningType {\n  capital\n  flag\n}\n\nenum Score {\n  succeeded\n  medium\n  failed\n}\n```\n\nUse prisma to initialize your database, migrations are available [here](/prisma/migrations).\n\nThen you can easily seed the database by running : `npm run seed`\nTo fill raw data tables : countries, regions and continents.\n  \n## Run the api\nEither : \n\n- Clone the repo\n- Run the classic : `npm i`\n- Do not forget to fill the `.env`\n- Run the following command : `npm run dev`\n- Then go to http://localhost:3001\n\nOr : \n\n- Build the Dockerfile with the following command : `docker build -t \u003cyourname\u003e/api-capitalympics -f Dockerfile .`\n- Run it : `sudo docker run --network=host -p 3001:3001 -e DB_HOST=\u003cYOUR_DB_HOST\u003e -e DB_USER=\u003cYOUR_DB_USER\u003e -e DB_PWD=\u003cYOUR_DB_PWD\u003e -e DB_NAME=\u003cYOUR_DB_NAME\u003e -e PORT=\u003cYOUR_PORT\u003e -e JWT_TOKEN=\u003cYOUR_JWT_TOKEN\u003e -e DATABASE_URL=\u003cYOUR_DATABASE_URL\u003e --name capitalympics \u003cyourname\u003e/api-capital`\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficepick4%2Fcapitalympics-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficepick4%2Fcapitalympics-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficepick4%2Fcapitalympics-api/lists"}