Angel3 Developer Guide
  • README
  • Foreword
  • Tutorial
    • Getting Started
    • Minimal Setup
  • Command Line Interface
    • Setup
  • Templates and Views
    • Server Side Rendered Views
    • JAEL3
      • About
      • Basics
      • Custom Elements
      • Strict Resolution
      • Directive: declare
      • Directive: for-each
      • Directive: extend
      • Directive: if
      • Directive: include
      • Directive: switch
  • Authentication
    • About
    • Strategies
    • Local
  • Databases
    • Object Relational Mapping (ORM)
      • About
      • Basic Functionality
      • Relations
      • Migrations
      • PostgreSQL
    • NoSQL
  • Extensions and Plugins
    • Using Plug-ins
    • Writing a Plugin
  • Under the hood
    • Basic Routing
    • Requests & Responses
    • Request Lifecycle
    • Dependency Injection
    • Middleware
    • Controllers
    • Parsing Request Bodies
    • Serialization
    • Service Basics
    • Testing
    • Error Handling
    • Pattern Matching and Parameter
  • Angel Framework Migration
    • Angel 2.x.x to Angel3
      • Rationale - Why a new Version?
      • Framework Changelog
      • 3.0.0 Migration Guide
    • Angel 1.x.x to 2.x.x
      • Framework Changelog
      • 2.0.0 Migration Guide
  • Packages
    • Authentication
    • CORS
    • Database-Agnostic Relations
    • Configuration
    • Databases
      • ORM
      • MongoDB
      • JSON File-based
      • RethinkDB
    • Templates and Views
      • Jael template engine
      • Mustache Templates
      • compiled_mustache-based engine
      • html_builder-based engine
      • Markdown template engine
      • Using Angel with Angular
    • Hot Reloading
    • Pagination
    • Polling
    • Production Utilities
    • REST Client
    • Reverse Proxy
    • Router
    • Serialization
    • Service Seeder
    • Static Files
    • Security
    • Server-sent Events
    • shelf Integration
    • Task Engine
    • User Agents
    • Validation
    • Websockets
  • Resources
    • Dependency Injection Patterns
    • Example Projects
    • YouTube Tutorials
    • Ecosystem
Powered by GitBook
On this page

Was this helpful?

  1. Tutorial

Minimal Setup

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

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

dependencies:
    angel3_framework: ^6.0.0

You might also want to install packages such as angel3_static, angel3_cache, angel3_jael, and angel3_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/main.dart. Put this code in it:

import 'dart:io';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';

void main() async {
  var app = Angel();
  var http = AngelHttp(app);

  app.get("/", (req, res) => "Hello, world!");

  var server = await http.startServer();
  print("Angel server listening at ${http.uri}");
}

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

  • var app = Angel() - The base Angel3 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 Angel3 instance app. This has no effect on functionality, but it makes it easier for other developers to understand your code.

  • await http.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/main.dart
PreviousGetting StartedNextCommand Line Interface

Last updated 2 years ago

Was this helpful?

app.get("/", (req, res) => "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