Documentation Index
Fetch the complete documentation index at: https://mintlify.com/juanjh1/asimilation/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before installing Asimilation, ensure you have the following:
Node.js
Node.js 16.x or higher (ES Modules support required)
Package Manager
npm, yarn, or pnpm
Asimilation requires Node.js with ES Modules support. Make sure your Node.js version is 16.0.0 or later.
Verify Node.js Version
Check your Node.js version:
If you need to upgrade, visit nodejs.org or use a version manager like nvm.
Installation
Install the Package
Install @asimilation/core using your preferred package manager:
npm install @asimilation/core
Package Details
TypeScript Configuration
Asimilation is built with TypeScript and works best in TypeScript projects. Follow these steps to configure TypeScript:
Install TypeScript
If you haven’t already, install TypeScript:npm install -D typescript
Create tsconfig.json
Create a tsconfig.json file in your project root:{
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"lib": ["ES2020"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
The "module": "ES2020" setting is required because Asimilation uses ES Modules. Do not use "commonjs".
Configure package.json
Add "type": "module" to your package.json:{
"name": "my-asimilation-app",
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "tsc",
"start": "node dist/server.js",
"dev": "tsx watch src/server.ts"
},
"dependencies": {
"@asimilation/core": "^0.0.2"
},
"devDependencies": {
"typescript": "^5.0.0",
"tsx": "^4.0.0"
}
}
Install tsx for a better development experience with hot reloading:Then run: npx tsx watch src/server.ts
Project Structure
Here’s a recommended project structure for Asimilation applications:
my-asimilation-app/
├── src/
│ ├── server.ts # Main server file
│ ├── routes/
│ │ ├── users.ts # User routes
│ │ ├── posts.ts # Post routes
│ │ └── index.ts # Route registration
│ ├── middleware/
│ │ ├── auth.ts # Authentication middleware
│ │ └── logger.ts # Logging middleware
│ ├── controllers/
│ │ ├── users.ts # User controllers
│ │ └── posts.ts # Post controllers
│ └── types/
│ └── index.ts # Type definitions
├── dist/ # Compiled JavaScript (generated)
├── node_modules/
├── package.json
├── tsconfig.json
└── .env
Minimal Structure
For simple projects, you can start with just:
my-app/
├── src/
│ └── server.ts
├── package.json
└── tsconfig.json
Verify Installation
Create a simple test file to verify your installation:
Create test server
Create src/server.ts:import { asi, url } from '@asimilation/core';
asi.setup(3000, import.meta.url);
url.addPath("/", (req, res) => {
res.sendJson({ message: "Installation successful!" }, 200);
});
asi.run();
console.log("Server running on http://localhost:3000");
Build and run
Build and start your server:Or for development with tsx: Test the endpoint
In a new terminal, test your server:curl http://localhost:3000/
You should see:{"message": "Installation successful!"}
If you see the success message, Asimilation is correctly installed and configured!
Using JavaScript (Without TypeScript)
While TypeScript is recommended, you can use Asimilation with plain JavaScript:
Configure package.json
Add "type": "module" to enable ES Modules:{
"name": "my-app",
"version": "1.0.0",
"type": "module",
"dependencies": {
"@asimilation/core": "^0.0.2"
}
}
Create JavaScript server
Create server.js:import { asi, url } from '@asimilation/core';
asi.setup(3000, import.meta.url);
url.addPath("/", (req, res) => {
res.sendJson({ message: "Hello from JavaScript!" }, 200);
});
asi.run();
Using JavaScript means you’ll lose type safety and IDE autocomplete. TypeScript is strongly recommended for better developer experience.
Troubleshooting
Error: “Cannot use import statement outside a module”
Solution: Add "type": "module" to your package.json.
Error: “Cannot find module ‘@asimilation/core’”
Solution: Ensure the package is installed:
npm install @asimilation/core
TypeScript compilation errors
Solution: Verify your tsconfig.json has "module": "ES2020" and "moduleResolution": "node".
Port already in use
Solution: Change the port in asi.setup() or kill the process using the port:
# Find process using port 3000
lsof -i :3000
# Kill the process (replace PID with actual process ID)
kill -9 PID
Next Steps
Quickstart
Build your first server in 5 minutes
Core Concepts
Learn the fundamental concepts
API Reference
Explore the complete API documentation
Guides
View guides and tutorials