Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Manage your Mongo Databases in RHMAP with Mongo Express

December 15, 2016
Emilio Rodriguez
Related topics:
DatabasesOpen source
Related products:
Red Hat build of Node.js

    Red Hat Mobile Application Platform (RHMAP) supports an agile approach to developing, integrating, and deploying enterprise mobile applications. Most likely, your mobile apps will include one or more cloud apps which will require persistence support such as a Mongo Database. But managing databases is not always easy, as command line support for this databases is complex and not always available.

    To ease this pain, Mongo Express can be used as an database GUI. For the mongo databases in your cloud apps, it is a powerful and intuitive tool which can be used in conjunction or as substitute for the default database browser. The main benefits from using "Mongo Express" instead of "Data Browser" are:

    • Can run complex queries
    • In-depth stats for every view
    • Supports BSON types as TimeStamp() or DBRef()

    IMPORTANT: there are some implications when using Mongo Express as a database manager:

    • Mongo Express can only manage the databases in one Cloud App and environment at a time
    • There is no authentication by default when using Mongo Express as explained in this article so take into account all the security issues that this may arise [1]
    • Users running the platform on the RHMAP should upgrade their databases if it was not upgraded before

    [1] Check the Annex ‘how to add authentication’ to overcome this issue

    Integrate Mongo Express as a Cloud App

    Mongo Express can be installed as a cloud app and, by using the right configuration, talk to other app’s database. Here you can find out how to install and configure Mongo Express to manage your Cloud App’s Mongo database.

    1. Identify our cloud app’s MongoDB url

    Once we have our cloud app properly set up within our project we need to identify what is its mongo connection URL so the service can connect to it. We can get this URL from the App Studio in Environment Variables > System Environment variables (inside our cloud app).

    The url should be stored in an environment variable called FH_MONGODB_CONN_URL [2]

    1

    We need to save the value of this variable so we can use it later when configuring our Mongo Express service.

    2. Import Mongo Express as a Cloud App in the studio

    In the ‘Apps, Cloud Apps & Services’ section of your project click on the ‘+’ sign to add a new Cloud App.

    screen-shot-2016-11-25-at-12-30-16

    Then follow the wizard to ‘Import an Existing App’ using our Mongo Express Service repository url as the public git repository url to import the app from: https://github.com/emilioicai/mongo-express-service.git

    screen-shot-2016-11-25-at-12-33-20

     

    3. Configure the Mongo Express to talk to your Cloud App’s database

    To do so, we will add an environment variable named MONGO_CONN_URL_APP setting the value as the Mongo connection url value we saved in step 1

    screen-shot-2016-11-25-at-12-45-51

     

    4. Deploy Mongo Express

    Once the Mongo Express is configured, it is time to deploy. It’s important to select Node.js 4.4.3 as runtime since the it doesn’t work with earlier versions of Node.

    screen-shot-2016-11-25-at-12-47-25

    That’s it! Mongo Express should be up and ready to manage your Cloud App’s MongoDB

    Alternatively, you can install Mongo Express directly as part of your cloud app. To do so you follow the next guide.

     

    [2] Users running the platform on Feedhenry MBaaS should upgrade their databases before having this environment var available


    Integrate Mongo Express as part of an existing Cloud App

    1. Add mongo-express as a dependency in your app

    Mongo express is distributed as a npm package. To define it as a dependency in your cloud app add "mongo-express": "0.32.0" to your Cloud App’s package.json .

    2. Create a mongo-express config file in your app

    Mongo express requires some configuration to run safely. A sample configuration file working with RHMAP can be found here. Save this file in your Cloud App’s file directory structure.

    3. Mount Mongo Express as middleware in your app

    var mongo_express = require('mongo-express/lib/middleware')
    var mongo_express_config = require('')
    
    app.use('/mongo_express', mongo_express(mongo_express_config))
    

    4. Commit, push and deploy you app

    At this point your app should be ready to be deployed. You only need to commit the changes you made, push them and deploy the app. Mongo Express will be available at: https://<your_app’s_url>/mongo_express


    Annex: how to add authentication

    A basic authentication mechanism can be set up in place easily. In this guide we used two npm packages to achieve this:

    • basic-auth (to benefit from the HTTP basic authentication mechanism)
    • rhmap-auth (to use RHMAP’s authentication check)

    The easiest way of achieving authentication is by creating a middleware function which asks for the credentials and checks their validity with RHMAP’s authentication method:

    var auth = require('basic-auth');
    var rhmapAuth = require('rhmap-auth');
    
    
    function isAuthenticated(req, res, next) {
        var user = auth(req);
        rhmapAuth(user.name,user.pass,function(err, isValid){
            if (!err && isValid){
                return next();
            }else{
                res.statusCode = 401;
                res.setHeader('WWW-Authenticate', 'Basic realm="example"');
                res.end('Access denied');
            }
        });
    }
    

    Now we can use add this middleware function in our route for Mongo Express. For example, we could replace

    app.use('/', mongo_express(mongo_express_config));

    With

    app.use('/', isAuthenticated, mongo_express(mongo_express_config));

    And automatically all accesses to our Mongo Express app will be validated with RHMAP’s authentication mechanism.

    Last updated: November 9, 2023

    Recent Posts

    • Confidential virtual machine storage attack scenarios

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    • Best Practice Configuration and Tuning for Linux and Windows VMs

    • Red Hat UBI 8 builders have been promoted to the Paketo Buildpacks organization

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility