{"id":19408755,"url":"https://github.com/4lessandrodev/mflix-mongo","last_synced_at":"2025-07-16T19:33:56.064Z","repository":{"id":105006912,"uuid":"342053834","full_name":"4lessandrodev/mflix-mongo","owner":"4lessandrodev","description":"estudos mongo","archived":false,"fork":false,"pushed_at":"2021-02-24T22:59:25.000Z","size":31955,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T02:17:47.033Z","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/4lessandrodev.png","metadata":{"files":{"readme":"README.rst","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":"2021-02-24T22:31:25.000Z","updated_at":"2021-02-24T22:59:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"39231bd3-90ae-442a-8649-70b137bfb042","html_url":"https://github.com/4lessandrodev/mflix-mongo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/4lessandrodev/mflix-mongo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fmflix-mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fmflix-mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fmflix-mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fmflix-mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4lessandrodev","download_url":"https://codeload.github.com/4lessandrodev/mflix-mongo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lessandrodev%2Fmflix-mongo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265534739,"owners_count":23783881,"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":[],"created_at":"2024-11-10T12:07:47.819Z","updated_at":"2025-07-16T19:33:56.043Z","avatar_url":"https://github.com/4lessandrodev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"=====\nMflix\n=====\n\nThis is a short guide on setting up the system and environment dependencies\nrequired for the MFlix application to run.\n\n\nProject Structure\n-----------------\n\nDownloading the **mflix-js.zip** handout may take a few minutes. Unzipping the\nfile should create a new directory called **mflix-js**.\n\nMost of your work will be implementing methods in the **dao** directory, which\ncontains all database interfacing methods. The API will make calls to Data\nAccess Objects (DAOs) that interact directly with MongoDB.\n\nThe unit tests in **test** will test these database access methods directly,\nwithout going through the API. The UI will run these methods in integration\ntests, and therefore requires the full application to be running.\n\nThe lesson handouts can be found in the **test/lessons** directory. These files\nwill look like **\u003clesson-name\u003e.spec.js**, and can be run with ``npm test -t\n\u003clesson-name\u003e``.\n\nThe API layer is fully implemented, as is the UI. The application is programmed\nto  run on port **5000** by default - if you need to run on a port other than\n5000, you can edit the **index.html** file in the build directory to modify the\nvalue of **window.host**.\n\nPlease do not modify the API layer in any way, under the **mflix-js/src/api**\ndirectory. This may result in the front-end application failing to validate some\nof the labs.\n\n\nNode Library Dependencies\n-------------------------\n\nThe dependencies for the MFlix application should be downloaded using the\n``npm`` command-line tool. You can get this tool by `downloading Node.js\n\u003chttps://nodejs.org/en/download/\u003e`_. Make sure to choose the correct option for\nyour operating system.\n\nOnce the installation is complete, you may need to restart your computer before\nusing the command line tools. You can test that it's installed by running the\nfollowing command:\n\n.. code-block:: sh\n\n  node -v\n\nThis should print out the version of ``node`` you currently have - we recommend\nusing version 10 or later, so this command should print something like\n``v10.x``.\n\nOnce ``npm`` is installed, you can install the MFlix dependencies by running the\nfollowing command from the **mflix-js** directory:\n\n.. code-block:: sh\n\n  npm install\n\nYou must run this from the top level of the project, so ``npm`` has access to\nthe **package.json** file where the dependencies are.\n\nYou may see warnings depending on your operating system from **fsevents** or\nHusky warning about **git** missing. These are informational only and do not\nimpact the functionality of the application. You can safely ignore them.\n\n\nMongoDB Installation\n--------------------\n\nIt is recommended to connect MFlix with MongoDB Atlas, so you do not need to\nhave a MongoDB server running on your host machine. The lectures and labs in\nthis course will assume that you are using an Atlas cluster instead of a local\ninstance.\n\nThat said, you are still required to have the MongoDB server installed, in order\nto be able to use two server tool dependencies:\n\n- ``mongorestore``\n\n  - A utility for importing binary data into MongoDB.\n\n- ``mongo``\n\n  - The MongoDB shell\n\nTo download these command line tools, please visit the\n`MongoDB download center \u003chttps://www.mongodb.com/download-center#enterprise\u003e`_\nand choose the appropriate platform.\n\nAll of these tools are free to use. MongoDB Enterprise is also free to use for\ntesting and evaluation purposes.\n\n\nMongoDB Atlas Cluster\n---------------------\n\nMFlix uses MongoDB to persist all of its data.\n\nOne of the easiest ways to get up and running with MongoDB is to use MongoDB\nAtlas, a hosted and fully-managed database solution.\n\nIf you have taken other MongoDB University courses like M001 or M121, you may\nalready have an account - feel free to reuse that cluster for this course.\n\n*Note: Be advised that some of the UI aspects of Atlas may have changed since\nthe inception of this README, therefore some of the screenshots in this file may\nbe different from the actual Atlas UI interface.*\n\n\nUsing an existing MongoDB Atlas Account:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you already have a previous Atlas account created, perhaps because you've\ntaken one of our other MongoDB university courses, you can repurpose it for\nthis course.\n\nLog-in to your Atlas account and create a new project named **M220** by clicking\non the **Context** dropdown menu:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_create_project.png\n\nAfter creating a new project, you need to create an **mflix** free tier cluster.\n\n\nCreating a new MongoDB Atlas Account:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you do not have an existing Atlas account, go ahead and `create an Atlas\nAccount \u003chttps://cloud.mongodb.com/links/registerForAtlas\u003e`_ by filling in the\nrequired fields:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/atlas_registration.png\n\n\nCreating a free tier cluster called \"mflix\":\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n*Note: You will need to do this step even if you are reusing an Atlas account.*\n\n1. After creating a new project, you will be prompted to create the first\n   cluster in that project:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_create.png\n\n\n2. Choose AWS as the cloud provider, in a Region that has the label\n   **Free Tier Available**:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_provider.png\n\n\n3. Select **Cluster Tier** M0:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_tier.png\n\n\n4. Set **Cluster Name** to **mflix** and click **Create Cluster**. It may take\n   7-10 minutes to successfully create your Atlas cluster:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_name.png\n\n\n5. Once you press **Create Cluster**, you will be redirected to the account\n   dashboard. In this dashboard, make sure you set your project name to\n   **M220**. Go to **Settings** menu item and change the project name from the\n   default **Project 0** to **M220**:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_project.png\n\n\n6. Next, configure the security settings of this cluster, by enabling the **IP\n   Whitelist** and **MongoDB Users**:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_ipwhitelisting.png\n\nUpdate your IP Whitelist so that your app can talk to the cluster. Click the\n**Security** tab from the **Clusters** page. Then click **IP Whitelist**\nfollowed by **Add IP Address**. Finally, click **Allow Access from Anywhere**\nand click **Confirm**.\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_allowall.png\n\n\n7. Then create the application MongoDB database user required for this course:\n\n  - username: **m220student**\n  - password: **m220password**\n\nYou can create new users through **Security** -\u003e **Add New User**.\n\nAllow this user the privilege to **Read and write to any database**:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_application_user.png\n\n\n8. When the user is created, and the cluster deployed, you can test the setup by\n   connecting via the Mongo shell. You can find instructions to connect in the\n   **Connect Your Application** section of the cluster dashboard:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_connect_application.png\n\nGo to your cluster **Overview** -\u003e **Connect** -\u003e **Connect Your Application**.\nSelect the option corresponding to your local MongoDB version and copy the\n``mongo`` connection command.\n\nThe below example connects to Atlas as the user you created before, with\nusername **m220student** and password **m220password**. You can run this command\nfrom your command line:\n\n.. code-block:: sh\n\n  mongo \"mongodb+srv://m220student:m220password@\u003cYOUR_CLUSTER_URI\u003e\"\n\nBy connecting to the server from your host machine, you have validated that the\ncluster is configured and reachable from your local workstation.\n\nYou may see the following message when you connect::\n\n  Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]\n\nThis is a log message, **not** an error - feel free to ignore it.\n\n\nImporting Data\n--------------\n\nThe ``mongorestore`` command necessary to import the data is located below. Copy\nthe command and use an Atlas SRV string to import the data (including username\nand password credentials).\n\nReplace the SRV string below with your own:\n\n.. code-block:: sh\n\n  # navigate to mflix-js directory\n  cd mflix-js\n\n  # import data into Atlas\n  mongorestore --drop --gzip --uri \\\n    \"mongodb+srv://m220student:m220password@\u003cYOUR_CLUSTER_URI\u003e\" data\n\nThe entire dataset contains almost 200,000 documents, so importing this data may\ntake 5-10 minutes.\n\n\nRunning the Application\n-----------------------\n\nIn order for the application to use Atlas, you will need a file called **.env**\nto contain the connection information. In the **mflix-js** directory you can\nfind two files, **dotenv_unix** (for Unix users) and **dotenv_win** (for Windows\nusers).\n\nOpen the file for your chosen operating system and enter your Atlas SRV\nconnection string as directed in the comment. This is the information the driver\nwill use to connect. Make sure **not** to wrap your Atlas SRV connection between\nquotes::\n\n  MFLIX_DB_URI = mongodb+srv://...\n\nIt's highly suggested you also change the **SECRET_KEY** to some very long, very\nrandom string. While this application is only meant for local use during this\ncourse, software has a strange habit of living a long time.\n\nWhen you've edited the file, rename it to **.env** with the following command:\n\n.. code-block:: sh\n\n  mv dotenv_unix .env  # on Unix\n  ren dotenv_win .env  # on Windows\n\n*Note:* Once you rename this file to **.env**, it will no longer be visible in\nFinder or File Explorer. However, it will be visible from Command Prompt or\nTerminal, so if you need to edit it again, you can open it from there:\n\n.. code-block:: sh\n\n vi .env       # on Unix\n notepad .env  # on Windows\n\nIn the **mflix-js** directory, run the following commands:\n\n.. code-block:: sh\n\n  # install MFlix dependencies\n  npm install\n\n  # start the MFlix application\n  npm start\n\nThis will start the application. You can then access the MFlix application at\n`http://localhost:5000/ \u003chttp://localhost:5000/\u003e`_.\n\n\nRunning the Unit Tests\n----------------------\n\nTo run the unit tests for this course, you will use `Jest\n\u003chttps://jestjs.io/docs/en/getting-started\u003e`_. Jest has been included in this\nproject's dependencies, so ``npm install`` should install everything you need.\n\nEach course lab contains a module of unit tests that you can call individually\nwith ``npm test``. For example, to run the test **connection-pooling.test.js**,\nrun the command:\n\n.. code-block:: sh\n\n  npm test -t connection-pooling\n\nEach ticket will contain the exact command to run that ticket's specific unit\ntests. You can run these commands from anywhere in the **mflix-js** project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4lessandrodev%2Fmflix-mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4lessandrodev%2Fmflix-mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4lessandrodev%2Fmflix-mongo/lists"}