dart-archive / rpc

RPC package for building server-side RESTful Dart APIs.
https://pub.dartlang.org/packages/rpc
BSD 3-Clause "New" or "Revised" License
117 stars 49 forks source link

rpc:generate does nothing? #94

Closed borysn closed 7 years ago

borysn commented 7 years ago

Hey guys!

New to dart here. Keep running into odd ball issues. I'm probably doing something wrong here.

I ran through the pirates-nest tutorial, and everything worked great. Got it going. Seems simple enough to understand and work with.

I'm now trying to generate my own client api, and the command pub global run rpc:generate client -i lib/server/apis/authapiart -o lib/client just hangs. no errors.

any advice here or clarifications would be appreciated. Please and thank you.

edit repo just'n'case

authapi.dart

// Copyright (c) 2016, borysn. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library server.api.authapi;

import 'package:rpc/rpc.dart';
import 'package:dev_appserver/common/auth/auth_token.dart';
import 'package:dev_appserver/common/auth/auth_token_verification.dart';
import 'package:dev_appserver/server/services/google_auth_verifier.dart';

@ApiClass(version: 'v1')
class AuthApi {
  GoogleAuthVerifier _glAuthVerifier;

  AuthApi() {
    this._glAuthVerifier = new GoogleAuthVerifier();
  }

  @ApiMethod(method: 'GET', path: 'google')
  AuthTokenVerification verifyGoogleAuth(AuthToken authToken) {
    return _glAuthVerifier.verify(authToken);
  }

}

pubspec.yaml

name: 'dev_appserver'
version: 0.0.1
description: A web server built using the shelf package.
author: borysn xborysn@gmail.com
#homepage: https://www.example.com

environment:
  sdk: '>=1.0.0 <2.0.0'

dependencies:
  args: '>=0.10.0 <0.14.0'
  shelf: '>=0.6.0 <0.7.0'
  rpc: '>=0.5.6+1'
  dart_jwt: '>=0.5.1'
borysn commented 7 years ago

still having a lot of trouble with generating a client api. I ran through the toyshop on examples, it all worked fine there, but I don't see any hints as too what I'm missing.

Here's what I'm trying now

// Copyright (c) 2016, borysn. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library authverifyapi;

import 'package:rpc/rpc.dart';

import 'package:dart_jwt/dart_jwt.dart';

class AuthVerifyRequest {
  @ApiProperty(required: true)
  String token;
}

class AuthVerifyResponse {
  bool isVerified;

  AuthVerifyResponse();
}

@ApiClass(version: 'v1')
class AuthVerifyApi {

  AuthVerifyApi();

  @ApiMethod(method: 'POST', path: 'google')
  AuthVerifyResponse verifyGoogleAuth(AuthVerifyRequest request) {
    AuthVerifyResponse response = new AuthVerifyResponse();

   /* JsonWebToken jwt = new JsonWebToken.decode(request.token);
    JwtValidationContext jvc = new JwtValidationContext.withSharedSecret("AIzaSyC1aHWikGh18FBBwuVbSGuUu1lQvWCOUnY");

    try {
      Set<ConstraintViolation> violations = jwt.validate(jvc);
      verification.isVerified = true;
      return verification;
    } catch (violation) {
      // claims may have been tampered with
      return verification;
    }*/

    return response;
  }

}
borysn commented 7 years ago

the question was already asked and answered in another issue. The answer that worked for me can be found here

use pub run instead of pub global run