Skip to content

Commit

Permalink
remove cookies for now
Browse files Browse the repository at this point in the history
build_runner is importing a private reference to Cookie dart:io_p which can't be used, until it's fixed
  • Loading branch information
codekeyz committed Dec 21, 2023
1 parent 6c294a6 commit 02f23ac
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 43 deletions.
21 changes: 4 additions & 17 deletions yaroo/lib/http/http.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import 'dart:async';
import 'dart:io';

import 'package:yaroo/src/_reflector/reflector.dart';
import 'package:yaroo/src/core.dart';

import 'http.dart';

export 'package:pharaoh/pharaoh.dart'
show
Request,
Response,
Session,
Middleware,
HTTPMethod,
CookieOpts,
session,
cookieParser,
useRequestHandler,
useShelfMiddleware;
show Request, Response, Session, Middleware, HTTPMethod, CookieOpts, session, cookieParser, useRequestHandler;

@inject
abstract class ApplicationController extends AppInstance {
abstract class HTTPController extends AppInstance {
late final Request request;

late final Response response;
Expand All @@ -33,10 +22,6 @@ abstract class ApplicationController extends AppInstance {

Session? get session => request.session;

List<Cookie> get cookies => request.cookies;

List<Cookie> get signedCookies => request.signedCookies;

get body => request.body;

Response badRequest([String? message]) {
Expand Down Expand Up @@ -65,4 +50,6 @@ abstract class ServiceProvider extends AppInstance {
static List<Type> get defaultProviders => [AppServiceProvider];

FutureOr<void> boot();

bool isAugmentation = false;
}
26 changes: 17 additions & 9 deletions yaroo/lib/src/_reflector/reflector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,29 @@ import '../../../http/http.dart';
import '../_container/container.dart';
import '../_router/definition.dart';
import '../_router/utils.dart';
import '../core.dart';

class Injectable extends r.Reflectable {
const Injectable()
: super(
r.invokingCapability,
r.metadataCapability,
r.newInstanceCapability,
r.declarationsCapability,
r.reflectedTypeCapability,
r.typeRelationsCapability,
const r.InstanceInvokeCapability('^[^_]'),
r.subtypeQuantifyCapability,
);
}

const unnamedConstructor = '';

const inject = Injectable();

List<X> filteredDeclarationsOf<X extends r.DeclarationMirror>(
r.ClassMirror cm,
predicate,
) {
List<X> filteredDeclarationsOf<X extends r.DeclarationMirror>(r.ClassMirror cm, predicate) {
var result = <X>[];
cm.declarations.forEach((k, v) {
if (predicate(v)) {
result.add(v as X);
}
if (predicate(v)) result.add(v as X);
});
return result;
}
Expand Down Expand Up @@ -64,7 +72,7 @@ ControllerMethod parseControllerMethod(ControllerMethodDefinition defn) {
final method = defn.$2;

final ctrlMirror = inject.reflectType(type) as r.ClassMirror;
if (ctrlMirror.superclass?.reflectedType != ApplicationController) {
if (ctrlMirror.superclass?.reflectedType != HTTPController) {
throw ArgumentError('$type must extend BaseController');
}

Expand Down
19 changes: 3 additions & 16 deletions yaroo/lib/src/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'dart:async';

import 'package:meta/meta.dart';
import 'package:pharaoh/pharaoh.dart';
import 'package:reflectable/reflectable.dart' as r;
import 'package:spookie/spookie.dart';
import 'package:yaroo/db/db.dart';

Expand All @@ -18,22 +17,10 @@ import 'config/config.dart';

part './core_impl.dart';

class Injectable extends r.Reflectable {
const Injectable()
: super(
r.invokingCapability,
r.metadataCapability,
r.newInstanceCapability,
r.declarationsCapability,
r.reflectedTypeCapability,
r.typeRelationsCapability,
r.instanceInvokeCapability,
r.subtypeQuantifyCapability,
);
}

typedef RoutesResolver = List<RouteDefinition> Function();

/// This should really be a mixin but due to a bug in reflectable.dart#324
/// TODO:(codekeyz) make this a mixin when reflectable.dart#324 is fixed
abstract class AppInstance {
Application get app => Application._instance;
}
Expand Down Expand Up @@ -130,7 +117,7 @@ abstract class ApplicationFactory {
static RequestHandler buildControllerMethod(ControllerMethod method) {
return (req, res) async {
final methodName = method.methodName;
final instance = createNewInstance<ApplicationController>(method.controller);
final instance = createNewInstance<HTTPController>(method.controller);
final mirror = inject.reflect(instance);

mirror
Expand Down
2 changes: 1 addition & 1 deletion yaroo/test/router_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:yaroo/yaroo.dart';

import './router_test.reflectable.dart';

class TestController extends ApplicationController {
class TestController extends HTTPController {
void create() {}

void index() {}
Expand Down

0 comments on commit 02f23ac

Please sign in to comment.