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 ramapiyarn
yarn add ramapipnpm
pnpm add ramapiTypeScript Setup
RamAPI is built with TypeScript and provides full type definitions out of the box.
Install TypeScript
npm install --save-dev typescript @types/nodeCreate 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
└── .gitignoreDevelopment Dependencies
For a complete development setup, consider installing these additional packages:
npm install --save-dev \
@types/node \
tsx \
nodemon \
eslint \
prettierScripts 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=debugLoad environment variables using dotenv:
npm install dotenvimport '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 ramapiYou should see output similar to:
my-app@1.0.0 /path/to/my-app
└── ramapi@1.0.0Docker 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-stoppedNext Steps
- Getting Started Guide - Build your first application
- Configuration - Configure your RamAPI instance
- Core Concepts - Learn the fundamentals