{"id":21237623,"url":"https://github.com/renie/mg-institute-api","last_synced_at":"2026-04-09T16:40:50.899Z","repository":{"id":45137881,"uuid":"296865912","full_name":"renie/mg-institute-api","owner":"renie","description":"Backend/Rest API of an online school.","archived":false,"fork":false,"pushed_at":"2024-12-08T06:21:32.000Z","size":1282,"stargazers_count":0,"open_issues_count":18,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T19:11:19.522Z","etag":null,"topics":["mongodb","nginx","nodejs"],"latest_commit_sha":null,"homepage":"","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/renie.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":"2020-09-19T12:38:09.000Z","updated_at":"2024-05-20T14:51:09.000Z","dependencies_parsed_at":"2024-02-08T01:24:02.065Z","dependency_job_id":"4f79ce3a-8f7f-45d0-87cb-0c7b8b1e06cb","html_url":"https://github.com/renie/mg-institute-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/renie%2Fmg-institute-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renie%2Fmg-institute-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renie%2Fmg-institute-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renie%2Fmg-institute-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renie","download_url":"https://codeload.github.com/renie/mg-institute-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243676783,"owners_count":20329434,"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":["mongodb","nginx","nodejs"],"created_at":"2024-11-21T00:19:48.166Z","updated_at":"2026-04-09T16:40:45.872Z","avatar_url":"https://github.com/renie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MG Institute API\n[![Build Status](https://travis-ci.com/renie/mg-institute-api.svg?branch=master)](https://travis-ci.com/renie/mg-institute-api)\n[![Maintainability](https://api.codeclimate.com/v1/badges/7dc85865d39cb4d344db/maintainability)](https://codeclimate.com/github/renie/mg-institute-api/maintainability)\n[![dependencies Status](https://david-dm.org/renie/mg-institute-api/status.svg)](https://david-dm.org/renie/mg-institute-api)\n[![devDependencies Status](https://david-dm.org/renie/mg-institute-api/dev-status.svg)](https://david-dm.org/renie/mg-institute-api?type=dev)\n[![Known Vulnerabilities](https://snyk.io/test/github/renie/mg-institute-api/badge.svg?targetFile=package.json)](https://snyk.io/test/github/renie/mg-institute-api?targetFile=package.json)\n\n## Dependencies\n\nThis project requires **NodeJS (version \u003e= 14.3)**, and **MongoDB (version \u003e= 4.2.9)**.\nIf you prefer to use a remote database, cloud MongoDB for instance, you just need to install NodeJS on your machine. Other deps will be download on next step.\n\n### Developers\nYou will need [codeclimate installed](https://github.com/codeclimate/codeclimate/blob/master/README.md) on your machine. In order to do that, you will have to [install docker](https://docs.docker.com/engine/install/ubuntu/) before.\n\nInstall engines (may take a while to finish and need sudo):\n```\ncodeclimate engines:install\n```\n\nYou can run it with (may need sudo):\n```\nnpm run codeclimate\n```\n\n## Setup\n\nInstall deps:\n\n```\nnpm i\n```\n\nCreate a `.env` file and set these variables:\n\n```\nAPPPORT=\u003cport where the API will run\u003e\nADDRESSDB=\u003caddress where your database is running\u003e\nUSERDB=\u003cdatabase user\u003e\nPASSDB=\u003cdatabase password\u003e\nNAMEDB=\u003cdatabase name\u003e\nPARAMSDB=\u003cdatabase extra params for connection string\u003e\nFRONTENDADDRESS=\u003caddress where front-end server is listening. ex:localhost:8080\u003e\nHTTPSKEYFILE=\u003cpath to your ssl key file (will be generated on next step)\u003e\nHTTPSCERTFILE=\u003cpath to your ssl cert file (will be generated on next step)\u003e\nJWTDEVTOKEN=\u003cany jwt token to bypass auth in dev env. THIS MUST NOT BE SET IN PROD\u003e\nSECRETKEYHMAC=\u003cany random string to be used as secret for HMAC on JWT\u003e\nSALTROUNDS=\u003cnumber of rounds to bcrypt\u003e\nVIMEO_CLIENTID=\u003cVimeo clientid\u003e\nVIMEO_CLIENTSECRET=\u003cVimeo client secret\u003e\nVIMEO_ACCESSTOKEN=\u003cVimeo access token\u003e\n```\n**After running seed, you should have a user with email `test@test.com` and password `123456`. This user can be used to test logged API accesses.**\n\nSeed dev database:\n\n```\nnpm run dev-seed\n```\n\nCreate a `.env-test` file and set the same variables you have at `.env`, but pointing to another database (this will be used just by automated tests).\n\nSeed test database:\n\n```\nnpm run dev-test\n```\n\n### SSL/TSL config (dev/staging)\nThis config is important to have an HTTPS environment for devs.\n\n#### Become a Certificate Authority\n\nGenerate private key\n```\nopenssl genrsa -des3 -out myCA.key 2048\n```\nGenerate root certificate\n```\nopenssl req -x509 -new -nodes -key myCA.key -sha256 -days 825 -out myCA.pem\n```\n\n#### Create CA-signed certs\n\nCreate a variable to ease next steps\n```\nNAME=localhost\n```\nGenerate a private key\n```\nopenssl genrsa -out $NAME.key 2048\n```\nCreate a certificate-signing request\n```\nopenssl req -new -key $NAME.key -out $NAME.csr\n```\nCreate a config file for extensions\n```\ntouch $NAME.ext\n```\nSet these variables in that recently created file\n```\nauthorityKeyIdentifier=keyid,issuer\nbasicConstraints=CA:FALSE\nkeyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment\nsubjectAltName = @alt_names\n[alt_names]\nDNS.1 = localhost\nIP.1 = 127.0.0.1\n```\nCreate(finally :roll_eyes:) the signed certificate\n```\nopenssl x509 -req -in $NAME.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial -out $NAME.crt -days 825 -sha256 -extfile $NAME.ext\n```\nCheck if everything went fine\n```\nopenssl verify -CAfile myCA.pem -verify_hostname $NAME $NAME.crt\n```\n\n#### Now import your CA file on your browser\nImport myCA.pem as an Authority in your Chrome settings *(Settings \u003e Manage certificates \u003e Authorities \u003e Import)*\n\n### Setup NGinX as reverse proxy\n\n===\n\n**This section is important JUST IF you want to have your dev environment mirroring production environment. Otherwise you can just run a separate server to frontend with `http-server`, for instance**\n\n===\n\n#### Ubuntu/Debian based distros\nJust set up run permissions on script and run it\n```\nsudo chmod +x ./nginx_install.sh\nsudo ./nginx_install.sh\n```\n\n#### Other environments\n\n- Install NGinX on last available version\n- Create a config file with following contents\n```\nserver {\n    server_name _;\n    listen \u003chost address\u003e:443 ssl;\n    ssl_certificate     \u003cpath to your SSL/TLS certificate file\u003e;\n    ssl_certificate_key \u003cpath to your SSL/TLS key file\u003e;\n    ssl_session_timeout 30m;\n    ssl_session_cache   shared:SSL:400k;\n    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n    server_tokens off;\n    charset utf-8;\n\n    gzip on;\n    gzip_min_length 0;\n    gzip_proxied any;\n    gzip_types text/html text/plain text/css text/javascript application/javascript application/x-javascript application/json image/svg+xml image/gif, image/png, image/jpeg image/webp;\n\n    location / {\n            proxy_pass https://\u003chost address\u003e:\u003chost port\u003e;\n            proxy_http_version 1.1;\n            proxy_set_header Upgrade \\$http_upgrade;\n            proxy_set_header Connection 'upgrade';\n            proxy_set_header Host \\$host;\n            proxy_cache_bypass \\$http_upgrade;\n    }\n\n    location ~* ^.+\\.(html|css|js|pdf|jpg|jpeg|png|svg) {\n        root \u003cpath to your frontend public dir\u003e;\n    }\n\n    location ~* ^\\/?$ {\n        root \u003cpath to your frontend public dir\u003e;\n        try_files /index.html =404;\n    }\n\n    location / {\n        root \u003cpath to your frontend public dir\u003e;\n        try_files $uri.html $uri $uri/index.html $uri/ =404;\n    }\n}\n```\n- Reload NGinX\n```\nsudo nginx -s reload\n```\n\n### Database seeding options\n\n#### Force seed\n\nBy default, if a collection has any documents, it won't be seeded. If you want to force it, use the following.\n\nFor dev environment\n\n```\nnpm run dev-seed -- --forceseed\n```\n\nFor test environment\n```\nnpm run test-seed -- --forceseed\n```\n\n#### Force drop\n\nIf you want to seed a database from scratch it is possible to drop collections before seeding.\n\nFor dev environment\n\n```\nnpm run dev-seed -- --forcedrop\n```\n\nFor test environment\n```\nnpm run test-seed -- --forcedrop\n```\n\n## Run API server\n\nDevelopment environment:\n\n```\nnpm run dev\n```\n\n## Run Tests\n\n```\nnpm test\n```\n\n## New seeds\n\nIf you are creating a new entity, it is very likely you want to seed a new collection.\nThe place for it is `models/db/seeds.js`.\n\n## Logs\nLogs are kept at `/logs`. You can check log rules at ./logger.js.\n\n**!! Logs are not rotated in dev env. Watch it !!**\n\n## Production Environment\nIf you need instructions to create a new production server, you might want to have a look [here](PRODSETUP.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenie%2Fmg-institute-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenie%2Fmg-institute-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenie%2Fmg-institute-api/lists"}