Skip to content

Basics Tutorial

This tutorial will guide you through the basic features, perfect for beginners.

After completing this tutorial, you will be able to:

  • Create and configure application instances
  • Understand the basic lifecycle
  • Handle common use cases

First, let’s create a basic application:

import { createApp } from 'your-package-name';
const app = createApp({
name: 'Tutorial App',
debug: true
});

You can customize various options:

const app = createApp({
name: 'Tutorial App',
version: '1.0.0',
debug: true,
timeout: 10000
});
  • name - Application name for logging and identification
  • version - Version number, optional
  • debug - Enable debug output
  • timeout - Operation timeout in milliseconds

Starting the application is simple:

await app.run();
console.log('Application started!');

When you need to stop:

await app.stop();
console.log('Application stopped');

Putting it all together:

import { createApp } from 'your-package-name';
async function main() {
const app = createApp({
name: 'Tutorial App',
debug: true
});
try {
await app.run();
console.log('Application running...');
// Do some work
await new Promise(resolve => setTimeout(resolve, 5000));
await app.stop();
console.log('Application stopped');
} catch (error) {
console.error('Error:', error);
}
}
main();

Try these exercises to reinforce your learning:

  1. Create an app with a 30-second timeout
  2. Enable debug mode and observe the output
  3. Add error handling logic