Alpha ready :)

This commit is contained in:
thosakwe 2016-12-21 14:06:09 -05:00
parent acbe7d3738
commit 373a3a30c6
7 changed files with 101 additions and 33 deletions

8
.gitignore vendored
View file

@ -7,6 +7,7 @@
.packages
.project
.pub/
.scripts-bin/
build/
**/packages/
@ -73,4 +74,11 @@ crashlytics.properties
crashlytics-build.properties
fabric.properties
### VSCode template
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
logs/**/*.txt

15
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Start Server",
"type": "dart-cli",
"request": "launch",
"cwd": "${workspaceRoot}",
"debugSettings": "${command.debugSettings}",
"program": "${workspaceRoot}/bin/server.dart",
"args": [],
"preLaunchTask": "pub:serve"
}
]
}

25
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,25 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "pub",
"isShellCommand": true,
"echoCommand": true,
"showOutput": "always",
"tasks": [
{
"taskName": "pub:build",
"suppressTaskName": true,
"args": [
"build"
]
},
{
"taskName": "pub:serve",
"suppressTaskName": true,
"args": [
"serve"
]
}
]
}

View file

View file

@ -2,6 +2,7 @@
library angel.routes;
import 'package:angel_cors/angel_cors.dart';
import 'package:angel_errors/angel_errors.dart';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_proxy/angel_proxy.dart';
import 'package:angel_static/angel_static.dart';
@ -19,14 +20,32 @@ configureRoutes(Angel app) async {
}
configureAfter(Angel app) async {
// 404 handler
app.after.add((req, ResponseContext res) async {
throw new AngelHttpException.NotFound();
// Set our application up to handle different errors.
var errors = new ErrorHandler(handlers: {
404: (req, res) async =>
res.render('error', {'message': 'No file exists at ${req.path}.'}),
500: (req, res) async => res.render('error', {'message': req.error.message})
});
// Default error handler
app.onError(
(e, req, res) async => res.render('error', {'message': e.message}));
errors.fatalErrorHandler = (AngelFatalError e) async {
e.request.response
..statusCode = 500
..writeln('500 Internal Server Error: ${e.error}')
..writeln(e.stack);
await e.request.response.close();
};
// Throw a 404 if no route matched the request
app.after.add(errors.throwError());
// Handle errors when they occur, based on outgoing status code.
// By default, requests will go through the 500 handler, unless
// they have an outgoing 200, or their status code has a handler
// registered.
app.after.add(errors.middleware());
// Pass AngelHttpExceptions through handler as well
await app.configure(errors);
}
configureServer(Angel app) async {

View file

@ -1,26 +1,27 @@
name: angel
description: An easily-extensible web server framework in Dart.
version: 1.0.0-dev
author: Tobe O
homepage: https://github.com/angel-dart/angel
publish_to: none
dependencies:
angel_auth: ^1.0.0-dev
angel_configuration: ^1.0.0-dev
angel_cors: ^1.0.0-dev
angel_diagnostics: ^1.0.0-dev
angel_errors: ^1.0.0-dev
angel_framework: ^1.0.0-dev
angel_mongo: ^1.0.0-dev
angel_mustache: ^1.0.0-dev
angel_proxy: ^1.0.0-dev
angel_static: ^1.1.0-dev
angel_test: ^1.0.0-dev
mailer: ^1.1.0+4
validate: ^1.5.2
dev_dependencies:
http: ^0.11.3
grinder: ^0.8.0+2
test: ^0.12.13
transformers:
- angel_configuration
author: "Tobe O"
description: "An easily-extensible web server framework in Dart."
homepage: "https://github.com/angel-dart/angel"
name: "angel"
publish_to: "none"
version: "1.0.0-dev"
dependencies:
angel_auth: "^1.0.0-dev"
angel_compress: "^1.0.0"
angel_configuration: "^1.0.0-dev"
angel_cors: "^1.0.0-dev"
angel_diagnostics: "^1.0.0-dev"
angel_errors: "^1.0.0-dev"
angel_framework: "^1.0.0-dev"
angel_mongo: "^1.0.0-dev"
angel_mustache: "^1.0.0-dev"
angel_proxy: "^1.0.0-dev"
angel_static: "^1.1.0-dev"
angel_test: "^1.0.0-dev"
mailer: "^1.1.0+4"
validate: "^1.5.2"
dev_dependencies:
grinder: "^0.8.0+2"
http: "^0.11.3"
test: "^0.12.13"
transformers:
- "angel_configuration"

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>{{message}}</title>
<title>Error</title>
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">