Boilerplate updates
This commit is contained in:
parent
ac36ba8318
commit
4324d80acc
8 changed files with 49 additions and 51 deletions
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
@ -3,14 +3,14 @@
|
|||
"configurations": [
|
||||
{
|
||||
"name": "Development Server",
|
||||
"type": "dart-cli",
|
||||
"type": "dart",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/bin/dev.dart",
|
||||
"checkedMode": true
|
||||
},
|
||||
{
|
||||
"name": "Production Server",
|
||||
"type": "dart-cli",
|
||||
"type": "dart",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/bin/prod.dart",
|
||||
"checkedMode": true
|
||||
|
|
14
Dockerfile
14
Dockerfile
|
@ -1,14 +1,20 @@
|
|||
FROM ubuntu:14.04
|
||||
FROM ubuntu:16.04
|
||||
MAINTAINER Tobe O <thosakwe@gmail.com>
|
||||
|
||||
# Install Dart SDK 1.24.2
|
||||
# Install Dart SDK.
|
||||
RUN sudo apt-get update
|
||||
RUN sudo apt-get install -y apt-transport-https
|
||||
RUN sudo apt-get install -y curl
|
||||
RUN sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
|
||||
RUN sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
|
||||
|
||||
# Uncomment this for Dart 1.24.x
|
||||
# RUN sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
|
||||
|
||||
# Comment this out if not installing Dart 2.x
|
||||
RUN sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_unstable.list > /etc/apt/sources.list.d/dart_unstable.list'
|
||||
|
||||
RUN sudo apt-get update
|
||||
RUN sudo apt-get install -y dart=1.24.2-1
|
||||
RUN sudo apt-get install -y dart
|
||||
RUN export PATH="/usr/lib/dart/bin:$PATH"
|
||||
|
||||
# Copy necessary files
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/angel_dart/discussion)
|
||||
[![Pub](https://img.shields.io/pub/v/angel_framework.svg)](https://pub.dartlang.org/packages/angel_framework)
|
||||
[![Build status](https://travis-ci.org/angel-dart/framework.svg?branch=master)](https://travis-ci.org/angel-dart/framework)
|
||||
![License](https://img.shields.io/github/license/angel-dart/framework.svg)
|
||||
|
||||
**Fill out the [v1.0.0 survey](https://docs.google.com/forms/d/e/1FAIpQLSfEgBNsOoi_nYZMmg2IAGyMv1nNaa6B3kUk3QdNJU5987ucVA/viewform?usp=sf_link) now!!!**
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import 'dart:io';
|
||||
import 'dart:io' hide FileMode;
|
||||
import 'dart:isolate';
|
||||
import 'package:angel/angel.dart';
|
||||
import 'package:angel_framework/angel_framework.dart';
|
||||
import 'package:dart2_constant/io.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
const String hostname = '127.0.0.1';
|
||||
|
@ -25,8 +26,11 @@ void isolateMain(int id) {
|
|||
app.logger = new Logger('angel')
|
||||
..onRecord.listen((rec) {
|
||||
if (rec.error != null) {
|
||||
var sink =
|
||||
new File('server_log.txt').openWrite(mode: FileMode.APPEND);
|
||||
var err = rec.error;
|
||||
if (err is AngelHttpException && err.statusCode != 500) return;
|
||||
var now = new DateTime.now().toUtc();
|
||||
var filename = 'server_log_' + now.toString() + '.txt';
|
||||
var sink = new File(filename).openWrite(mode: FileMode.append);
|
||||
sink
|
||||
..writeln(rec.error)
|
||||
..writeln(rec.stackTrace)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:angel_http_exception/angel_http_exception.dart';
|
||||
import 'package:console/console.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
|
@ -5,12 +6,16 @@ import 'package:logging/logging.dart';
|
|||
void prettyLog(LogRecord record) {
|
||||
var pen = new TextPen();
|
||||
chooseLogColor(pen.reset(), record.level);
|
||||
pen(record.toString());
|
||||
|
||||
if (record.error != null)
|
||||
pen(record.error.toString());
|
||||
if (record.stackTrace != null)
|
||||
pen(record.stackTrace.toString());
|
||||
if (record.error == null) pen(record.toString());
|
||||
|
||||
if (record.error != null) {
|
||||
var err = record.error;
|
||||
if (err is AngelHttpException && err.statusCode != 500) return;
|
||||
pen(record.toString() + '\n');
|
||||
pen(err.toString());
|
||||
if (record.stackTrace != null) pen(record.stackTrace.toString());
|
||||
}
|
||||
|
||||
pen();
|
||||
}
|
||||
|
@ -27,6 +32,5 @@ void chooseLogColor(TextPen pen, Level level) {
|
|||
pen.magenta();
|
||||
else if (level == Level.FINER)
|
||||
pen.blue();
|
||||
else if (level == Level.FINEST)
|
||||
pen.darkBlue();
|
||||
else if (level == Level.FINEST) pen.darkBlue();
|
||||
}
|
||||
|
|
|
@ -43,13 +43,19 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
|
|||
//
|
||||
// Read the following for documentation:
|
||||
// * https://github.com/angel-dart/angel/wiki/Error-Handling
|
||||
app.errorHandler = (e, req, res) async {
|
||||
if (e.statusCode == 404) {
|
||||
return await res
|
||||
.render('error', {'message': 'No file exists at ${req.path}.'});
|
||||
}
|
||||
|
||||
return await res.render('error', {'message': e.message});
|
||||
var oldErrorHandler = app.errorHandler;
|
||||
app.errorHandler = (e, req, res) async {
|
||||
if (!req.accepts('text/html'))
|
||||
return await oldErrorHandler(e, req, res);
|
||||
else {
|
||||
if (e.statusCode == 404) {
|
||||
return await res
|
||||
.render('error', {'message': 'No file exists at ${req.path}.'});
|
||||
}
|
||||
|
||||
return await res.render('error', {'message': e.message});
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ name: angel
|
|||
description: An easily-extensible web server framework in Dart.
|
||||
publish_to: none # Ensure we don't accidentally publish our private code! ;)
|
||||
environment:
|
||||
sdk: '>=2.0.0-dev <2.0.0'
|
||||
sdk: '>=2.0.0-dev <3.0.0'
|
||||
homepage: https://github.com/angel-dart/angel
|
||||
dependencies:
|
||||
angel_auth: ^1.1.0 # Supports stateless authentication via JWT
|
||||
|
@ -10,14 +10,11 @@ dependencies:
|
|||
angel_cors: ^1.0.0 # CORS support
|
||||
angel_framework: ^1.1.0 # The core server library.
|
||||
angel_jael: ^1.0.0 # Server-side templating engine
|
||||
angel_serialize: ^2.0.0 # Model definition metadata.
|
||||
angel_static: ^1.3.0 # Static file server
|
||||
angel_validate: ^1.0.0 # Allows for validation of input data
|
||||
dart2_constant: ^1.0.0 # For backwards compatibility.
|
||||
dev_dependencies:
|
||||
angel_hot: ^1.1.0-alpha # Hot-reloading support. :)
|
||||
angel_serialize_generator: ^2.0.0 # Generates serialization code for models.
|
||||
angel_hot: ^1.1.0 # Hot-reloading support. :)
|
||||
angel_test: ^1.1.0 # Utilities for testing Angel servers.
|
||||
build_runner: ^0.7.0
|
||||
console: ^2.2.4
|
||||
grinder: ^0.8.0
|
||||
test: ^0.12.13
|
|
@ -1,21 +0,0 @@
|
|||
// Grinder is not part of Angel, but you may consider using it
|
||||
// to run tasks, a la Gulp.
|
||||
//
|
||||
// See its documentation here:
|
||||
// https://github.com/google/grinder.dart
|
||||
|
||||
import 'package:grinder/grinder.dart';
|
||||
|
||||
main(args) => grind(args);
|
||||
|
||||
@Task()
|
||||
test() => new TestRunner().testAsync();
|
||||
|
||||
@DefaultTask()
|
||||
@Depends(test)
|
||||
build() {
|
||||
Pub.build();
|
||||
}
|
||||
|
||||
@Task()
|
||||
clean() => defaultClean();
|
Loading…
Reference in a new issue