REST API Backend

The REST API Backend is the representation of the server-side system for the RESTful services to be created by the user. The name of the backend will be included in the URL of the RESTful API for the app. Once a backend is created. It can be accessed through the browser with http://localhost:7000/{backendname}. Metamug does not provide backend versioning instead, versioning is provided at the resource level.

The Backend screen on the Metamug Console lists the App Backends created by the user and shows details. The information about the selected backend is displayed in the panel. This information includes the following

  1. Backend endpoint to be accessed by app developers to access the API.
  2. Documentation Page for developer's reference to understand the API calls to be made. The details about the method, parameters and other pre-conditions.

Metamug Backend Screen

Backend Creation

The New Backend button can be used to create a new backend. The backend creation form requires the name, description and database type for the backend. Backend Creation Form

  1. Name
    • Only lower case alphabets are allowed as names. The backend name is used to form the url when making API requests.
    • Names "console" and "root" are reserved and cannot be used as backend names.
    • A backend name has to be unique - there cannot be more than one backends with same name.
  2. Description
    • Description is used for displaying in the backend documentation.
  3. Database Type
    • The database type for a backend can be internal - embedded within the Metamug server itself OR external - connection to user's own database. This is explained in detailed in the later sections.

Backend Database

Each backend creates a database schema along with it. The default database provided is HSQLDB, which is Internal (uses the same hardware as the API server itself). This database will be used for all the created backends if they do not specify an external database connection. We do not recommend using HSQLDB unless you are building a small proof-of-concept, due to its limitations.

Connecting to External Database

External database connection can be established to the backend by selecting the External database option. Backend Creation - ExtDB

Currently the external DB connection feature supports only MySQL and PostgreSQL. You will need to provide the following connection details.

Granting Permissions

Make sure that your database has permissions granted to the username and password which you enter.

For example for MySQL you can use the following

GRANT ALL ON testdb.* to 'username'@'' IDENTIFED BY 'password';

Accessing Backend

The current backend is visible on top navigation bar as a dropdown. Backend contains resource files, code execution and SQL editor to access information about database schema. The tables created within a backend cannot be accessed by another backend. The user can switch between backends created on the Backends page. The corresponding code and resource file will be displayed after switching.

Deleting the backend

Exporting backend for production

A backend can be exported by clicking on the export icon.

Backend Creation - ExtDB

On exporting a backend, a WAR archive gets downloaded by the browser. The WAR file can be unzipped to produce a Java web application folder. The exported WAR is currently only tested to run on Tomcat. We will be supporting other Servlet containers later.

The Database connection details can be found in /META-INF/context.xml inside the webapp folder.