Skip to main content

First Application

This section will guide you through creating your first application using OSI. We'll create a simple file manager that demonstrates the basic usage of OSI's core features.

Project Setup

  1. Create a new directory and initialize the project:
mkdir osi-test
cd osi-test
npm init -y
  1. Install required dependencies:
npm install osi.onpremises typescript
npm install --save-dev @types/node

Implementation

Main Application (index.ts)

import { fs, os } from 'osi.onpremises';

async function main() {
try {
// List files in current directory
const files = await fs.ls('.');
console.log('Files in current directory:');
files.forEach(file => {
console.log(`${file.name} (${file.size} bytes)`);
});

// Get system information
const cpuInfo = await os.cpu();
console.log('\nSystem Information:');
console.log(`Architecture: ${cpuInfo.architecture}`);
console.log(`Processor: ${cpuInfo.processor}`);
} catch (error) {
console.error('Error:', error);
}
}

main();

Running the Application

  1. Add the following script to your package.json:
{
"scripts": {
"start": "ts-node src/index.ts"
}
}
  1. Start the application:
npm start

What We've Learned

This example demonstrates:

  • Setting up an application with OSI
  • Using the FileSystem module to list files
  • Using the OS module to get system information
  • Proper error handling
  • IPC communication (Electron only)

Next Steps

Now that you have a basic understanding of OSI, you can:

  1. Explore the Core Components documentation
  2. Learn about the API Reference
  3. Check out Best Practices for more advanced usage