Now that you've created your first endpoint, let's start the development server and see your API in action.
Start the Development Server#
Revali provides a CLI tool to run your server. From your project root, run:
dart run revali dev
This command will:
- Analyze your routes and controllers
- Generate the necessary server code
- Start the development server
- Enable hot reload for instant development feedback
Server Configuration#
By default, Revali configures your server with these settings:
- Host:
localhost - Port:
8080 - API Prefix:
/api
Access Your API#
Once the server is running, you can access your API at:
http://localhost:8080/api
For your hello endpoint created in the previous guide:
GET http://localhost:8080/api/hello
Generated Files#
When Revali starts, it generates files in your project:
.
└── .revali/
└── server/
├── <generated-files>
└── server.dart
Hot Reload#
One of Revali's best features is hot reload support. When you make changes to your controllers:
- Save your file
- Revali automatically detects the changes
- Regenerates the necessary code
- Restarts the server
- Your changes are live instantly!
Testing Your API#
You can test your API using various tools:
Using curl#
curl http://localhost:8080/api/hello
Using a REST Client#
Tools like Postman, Insomnia, or Thunder Client work great for testing APIs.
Development Tips#
- Keep the terminal open: The development server shows logs and error messages
- Check the console: Revali provides helpful feedback about route generation
- Use hot reload: Make changes and see them instantly without restarting
Next Steps#
Troubleshooting#
Port Already in Use#
If port 8080 is already in use, you can change it in your AppConfig subclass:
import 'package:revali_router/revali_router.dart';
@App()
final class MainApp extends AppConfig {
const MainApp()
: super(
host: 'localhost',
port: 3000, // Use a different port
);
}
Server Crashes or Other Issues#
If you encounter other issues:
- Check the error messages in the terminal for clues
- Verify your code matches the examples in the documentation
- Try running
dart pub getto refresh dependencies -
If the problem persists, create an issue
with:
- A description of the problem
- Steps to reproduce
- Error messages/logs
- Your environment details (Dart version, OS, etc.)