Installation
There are two ways to install the Data API:
- Generate a standalone Data API with the CLI (recommended to get started): the CLI reads your database schema and generates a ready-to-run Express app with all your models.
- Add Adminmate to your existing Express app: install one npm package and add a few lines of code. Useful when your backend already runs on Express with Sequelize or Mongoose models.
Requirements
Section titled “Requirements”- Node.js 16 or later
- A MySQL, PostgreSQL, SQLite or MongoDB database
- An Adminmate account: sign up for free
1. Create a project
Section titled “1. Create a project”Log in and create a new project. Choose a name (you can change it later) and your database type.
You then get a Project ID and a Secret Key. Keep them secret: they link your Data API to your Adminmate project.
2a. Generate a Data API with the CLI
Section titled “2a. Generate a Data API with the CLI”Install the Adminmate CLI:
npm i adminmate-cli -gThen run the command displayed in the Dashboard. It contains your project credentials and looks like this:
adminmate --name "My project" --id <project-id> --sk <secret-key> --db <database-type> --hash <token>The CLI asks for:
- your database connection details (host, port, user, password, database name, and the schema for PostgreSQL);
- the master password you want to use to open your back-office.
The Dashboard follows the installation live. Once done, the CLI has generated a new folder:
my-project/ .env credentials and database URL package.json server.js the Express app database.js the database connection config/ adminmate.js the Adminmate configuration models/ one file per table / collection controllers/ empty, for your own code middlewares/ empty, for your own codeInstall the dependencies and start the Data API:
cd my-projectnpm installnpm startThe Data API listens on port 3020 by default (set the PORT environment variable to change it). Go back to the Dashboard: your back-office opens at https://app.adminmate.io/<your-project-slug>.
2b. Add Adminmate to an existing Express app
Section titled “2b. Add Adminmate to an existing Express app”Install the package matching your database:
# MySQL, PostgreSQL or SQLite (Sequelize)npm install adminmate-express-sequelize
# MongoDB (Mongoose)npm install adminmate-express-mongooseAdd Adminmate right after the creation of your Express app, before your own routes and authentication middlewares:
const express = require('express');const Adminmate = require('adminmate-express-mongoose'); // or 'adminmate-express-sequelize'const User = require('./models/user'); // your models
const app = express();
app.use(Adminmate.init({ projectId: process.env.AM_PROJECT_ID, secretKey: process.env.AM_SECRET_KEY, authKey: process.env.AM_AUTH_KEY, masterPassword: process.env.AM_MASTER_PWD, models: [ { slug: 'users', model: User }, // one line per model you want to manage in Adminmate ]}));
// ...your own middlewares and routesAM_PROJECT_IDandAM_SECRET_KEYare given by the Dashboard.AM_AUTH_KEYmust be a long random string, for example generated withopenssl rand -hex 32.AM_MASTER_PWDis the password you will type to open your back-office. Choose a strong one.
Restart your server. Adminmate only adds routes under /adminmate/api, so it does not interfere with the rest of your app.
3. Connect the Dashboard
Section titled “3. Connect the Dashboard”In the Dashboard, enter the URL where your Data API is reachable (for example http://localhost:3020) and your master password. Adminmate checks the connection and opens your back-office.
You can add other environments later (staging, production…) from Settings › Environments.
Et voilà! Next step: configure your back-office.