Angel
1.x
1.x
  • Introduction
  • Example Projects
  • Awesome Angel
  • 1.1.0 Migration Guide
  • Social
    • Angel on Gitter
    • Angel on Medium
    • Angel on YouTube
  • The Basics
    • Installation & Setup
      • Without the Boilerplate
    • Requests & Responses
    • Dependency Injection
    • Basic Routing
    • Request Lifecycle
    • Middleware
    • Controllers
    • Handling File Uploads
    • Using Plug-ins
    • Rendering Views
    • REST Client
    • Testing
    • Error Handling
    • Pattern Matching and Parameter
    • Command Line
  • Flutter
    • Writing a Chat App
    • Flutter helper widgets
  • Services
    • Service Basics
    • TypedService
    • In-Memory
    • Custom Services
    • Hooks
      • Bundled Hooks
    • Database-Agnostic Relations
    • Database Adapters
      • MongoDB
      • RethinkDB
      • JSON File-based
  • Plug-ins
    • Authentication
    • Configuration
    • Diagnostics & Logging
    • Reverse Proxy
    • Service Seeder
    • Static Files
    • Validation
    • Websockets
    • Server-sent Events
    • Toggle-able Services
  • Middleware/Finalizers
    • CORS
    • Response Compression
    • Security
    • File Upload Security
    • shelf Integration
    • User Agents
    • Pagination
    • Range, If-Range, Accept-Ranges support
  • PostgreSQL ORM
    • Model Serialization
    • Query Builder + ORM
    • Migrations
  • Deployment
    • Running in Isolates
    • Configuring SSL
    • HTTP/2 Support
    • Ubuntu and nginx
    • AppEngine
    • Production Mode
  • Front-end
    • Mustache Templates
    • Jael template engine
      • Github
      • Basics
      • Custom Elements
      • Strict Resolution
      • Directive: declare
      • Directive: for-each
      • Directive: extend
      • Directive: if
      • Directive: include
      • Directive: switch
    • compiled_mustache-based engine
    • html_builder-based engine
    • Markdown template engine
    • Using Angel with Angular
  • Advanced
    • API Documentation
    • Contribute to Angel
    • Scaling & Load Balancing
    • Standalone Router
    • Writing a Plugin
    • Task Engine
    • Hot Reloading
    • Real-time polling
Powered by GitBook
On this page
  1. The Basics
  2. Installation & Setup

Without the Boilerplate

It's very easy to setup a bare-bones Angel server.

Any Dart project needs a project file, called pubspec.yaml. This file almost always contains a dependencies section, where you will install the Angel framework libraries.

dependencies:
    angel_framework: ^1.1.0

You might also want to install packages such as angel_static, angel_cache, angel_jael, and angel_cors.

Next, run pub get on the command line, or in your IDE if it has Dart support. This will install the framework and all of its dependencies.

Next, create a file, bin/server.dart. Put this code in it:

import 'dart:io';
import 'package:angel_framework/angel_framework.dart';

main() async {
  Angel app = new Angel();

  app.get("/", "Hello, world!");

  var server = await app.startServer();
  print("Angel server listening on port ${server.port}");
}

The specifics are not that important, but there are three important calls here:

  1. Angel app = new Angel() - The base Angel server is a simple class, and we need an instance of it to run our server. The name app is a convention adopted from Express. In general, call an Angel instance app. This has no effect on functionality, but it makes it easier for other developers to understand your code.

  2. await app.startServer(...) - This asynchronous call is what actually starts the server listening. Without it, your application won't be accessible over HTTP (as it won't ever listen for requests).

That's it! Your server is ready to serve requests. You can easily start it from the command line like this:

dart bin/server.dart
PreviousInstallation & SetupNextRequests & Responses

Last updated 6 years ago

app.get("/", "Hello, world!"); - This is a , and tells our server to respond to all GET requests at our server root with "Hello, world!". The response will automatically be encoded as JSON. Head over to the tutorial to learn about routes, and how they work.

route
Basic Routing