🎉 RamAPI v1.0 is now available! Read the Getting Started Guide
Documentation
Installation

Installation

This guide covers different ways to install and set up RamAPI in your project.

System Requirements

  • Node.js: 18.0.0 or later
  • npm: 9.0.0 or later (or equivalent package manager)
  • Operating System: Linux, macOS, or Windows

Package Manager Installation

npm

npm install ramapi

yarn

yarn add ramapi

pnpm

pnpm add ramapi

TypeScript Setup

RamAPI is built with TypeScript and provides full type definitions out of the box.

Install TypeScript

npm install --save-dev typescript @types/node

Create tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "lib": ["ES2020"],
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "moduleResolution": "node"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

Project Structure

Recommended project structure for a RamAPI application:

my-ramapi-app/
├── src/
│   ├── routes/
│   │   ├── users.ts
│   │   └── posts.ts
│   ├── middleware/
│   │   ├── auth.ts
│   │   └── logger.ts
│   ├── utils/
│   │   └── helpers.ts
│   └── server.ts
├── tests/
│   └── server.test.ts
├── package.json
├── tsconfig.json
└── .gitignore

Development Dependencies

For a complete development setup, consider installing these additional packages:

npm install --save-dev \
  @types/node \
  tsx \
  nodemon \
  eslint \
  prettier

Scripts Configuration

Add these scripts to your package.json:

{
  "scripts": {
    "dev": "nodemon --exec tsx src/server.ts",
    "build": "tsc",
    "start": "node dist/server.js",
    "test": "node --test",
    "lint": "eslint src/**/*.ts",
    "format": "prettier --write src/**/*.ts"
  }
}

Environment Variables

Create a .env file for environment configuration:

PORT=3000
NODE_ENV=development
LOG_LEVEL=debug

Load environment variables using dotenv:

npm install dotenv
import 'dotenv/config';
import { RamAPI } from 'ramapi';
 
const app = new RamAPI();
const PORT = process.env.PORT || 3000;
 
app.listen(PORT);

Verification

Verify your installation by running:

npm list ramapi

You should see output similar to:

my-app@1.0.0 /path/to/my-app
└── ramapi@1.0.0

Docker Setup (Optional)

Create a Dockerfile for containerized deployment:

FROM node:18-alpine
 
WORKDIR /app
 
COPY package*.json ./
RUN npm ci --only=production
 
COPY . .
 
EXPOSE 3000
 
CMD ["node", "dist/server.js"]

And a docker-compose.yml:

version: '3.8'
 
services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - PORT=3000
    restart: unless-stopped

Next Steps