Getting Started

Introduction

The Infomaxim API provides a comprehensive backend-as-a-service platform for building web and mobile applications. Our API offers:

  • RESTful architecture with JSON responses
  • JWT-based authentication and authorization
  • Flexible data management with secure querying
  • File storage and management
  • E-commerce capabilities with Stripe integration
  • Real-time analytics and reporting
  • Email and push notification services
Version: API V2 - Latest stable version with enhanced security and performance features.

Installation & Configuration

Prerequisites

  • Node.js 14.x or higher
  • Microsoft SQL Server
  • IIS (Internet Information Services) for production deployment

Environment Setup

Clone the repository and install dependencies:

git clone https://github.com/andy008/Infomaxim.git
cd Infomaxim/projects/api
npm install

Configuration File

Create a .env file in the API root directory with the following variables:

# Database Configuration
DB_NAME=infomaxim
DB_SERVER=your-server-name
DB_USER=your-username
DB_PASSWORD=your-password
DB_ENCRYPT=true

# JWT Secrets
JWT_ACCESS_SECRET=your-access-token-secret
JWT_REFRESH_SECRET=your-refresh-token-secret
JWT_ACCESS_TOKEN_LIFE=3600
JWT_REFRESH_TOKEN_LIFE=2592000

# API Configuration
API_PORT=3001
FRONTEND_DOMAIN=http://localhost:4200

# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100

# Encryption
ENCRYPTION_KEY=your-32-byte-encryption-key
ENCRYPTION_IV=your-16-byte-initialization-vector

Database Setup

The API connects to an existing Infomaxim database. Ensure your database is properly configured with:

  • User authentication tables
  • Application configuration tables
  • Dynamic data tables based on your schema

Starting the API Server

For development:

npm start

For production:

npm run start-prod

IIS Configuration

URL Rewrite Rule

Configure IIS to proxy requests to the Node.js API server. Add the following rule to your web.config:

<rewrite>
  <rules>
    <rule name="V2 Infomaxim API" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="infomaxim/api/v2/(.*)" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
      <action type="Rewrite" url="http://localhost:3001/{R:1}" />
      <serverVariables>
        <set name="HTTP_site-id" value="1" />
      </serverVariables>
    </rule>
  </rules>
</rewrite>
Important: The HTTP_site-id server variable must be set to the Infomaxim application ID for your site. This identifies which application database to query.

Server Variables Configuration

  1. Open IIS Manager
  2. Select your website
  3. Open "URL Rewrite"
  4. Click "View Server Variables" in the Actions panel
  5. Add HTTP_site-id to the allowed server variables list

Domain Configuration

The API uses the HTTP_site-id server variable to determine which Infomaxim application database to connect to. Each IIS website can have a different site-id, allowing multiple applications to run on the same API server.

Multiple Site Configuration

To host multiple Infomaxim applications on the same server:

  • Create separate IIS websites for each application
  • Configure each website with its own HTTP_site-id value
  • All websites can proxy to the same Node.js API server (port 3001)
  • The API will automatically query the correct application database based on the site-id

Base URL & Endpoints

API Base URLs

Environment Base URL
Development http://localhost:3001
Production https://yourdomain.com/infomaxim/api/v2

Standard Response Format

All API endpoints return JSON responses in the following format:

Success Response

{
  "status": "Success",
  "data": { 
    /* Response data */
  },
  "datetime": "2024-01-01T12:00:00Z"
}

Error Response

{
  "status": "Failed",
  "message": "Error description",
  "errors": [
    {
      "field": "fieldName",
      "message": "Field-specific error message"
    }
  ]
}

HTTP Status Codes

Status Code Description
200OK - Request successful
201Created - Resource created successfully
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing authentication token
403Forbidden - Insufficient permissions
404Not Found - Resource not found
409Conflict - Resource already exists
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Server error