Coder Social home page Coder Social logo

convector-rest-api's People

Contributors

diestrin avatar jeffbicca avatar walmon avatar xcottos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

convector-rest-api's Issues

Errors trying to compile auto-generated REST api package

Steps to recreate:

  1. Created chaincode usschainx
  2. Tests OK
  3. Attempt to create REST api as follows:

npm install -g @worldsibu/convector-rest-api
conv-rest-api generate api -c usschainx -p usschain2

  1. REST api package created OK
    npx lerna run compile --scope usschainx-app

Tool Versions:
conv version 1.1.3
hurl version 1.0.5
convector-rest-api version 1.0.8

I am running this command: npx lerna run compile --scope usschainx-app
THE ERROR:
../../node_modules/fabric-shim/node_modules/winston/index.d.ts(4,23): error TS4090: Conflicting definitions for 'node' found at '/Users/mac/WORLD_SIBU/unemployment-services-chaincode-repo/usschain2/node_modules/fabric-shim/node_modules/@types/node/ts3.2/index.d.ts' and '/Users/mac/WORLD_SIBU/unemployment-services-chaincode-repo/usschain2/node_modules/@types/node/ts3.2/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
../../node_modules/fabric-shim/node_modules/winston/lib/winston/config/index.d.ts(4,23): error TS4090: Conflicting definitions for 'node' found at '/Users/mac/WORLD_SIBU/unemployment-services-chaincode-repo/usschain2/node_modules/fabric-shim/node_modules/@types/node/ts3.2/index.d.ts' and '/Users/mac/WORLD_SIBU/unemployment-services-chaincode-repo/usschain2/node_modules/@types/node/ts3.2/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
../../node_modules/fabric-shim/node_modules/winston/lib/winston/transports/index.d.ts(4,23): error TS4090: Conflicting definitions for 'node' found at '/Users/mac/WORLD_SIBU/unemployment-services-chaincode-repo/usschain2/node_modules/fabric-shim/node_modules/@types/node/ts3.2/index.d.ts' and '/Users/mac/WORLD_SIBU/unemployment-services-chaincode-repo/usschain2/node_modules/@types/node/ts3.2/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.

Issues running conv-rest-api

Hello,

I am trying to get a new Fabric 2.2 installation set up and going and we've run into some issues trying to run conv-rest-api.

We currently have a Fabric 1.0 ledger that we need to upgrade. We thought it would be easier to just set up 2.2 from scratch and then repopulate our ledger. So, we installed the latest version of Convector and I followed the tutorial for configuring our new project, "sr2". All went well until I got past step where I created the api.json to expose my smart contract methods. I went to create the API with conv-rest-api and I got errors.

The command I executed was: conv-rest-api generate api -c sr2 -p sr2 -f ./sr2.config.json

NOTE: I had to add a new parameter, "-p sr2", not listed in the tutorial but conv-rest-api threw an error when run without it.

I got the following errors:
[error log]
in generateApi in command.ts chaincode=sr2
in generateApi in command.ts chaincodeConfigFile=./sr2.config.json
generating stub..
removing previously generated app (packages/sr2-app)
generating stub folder
/usr/lib/node_modules/@worldsibu/convector-rest-api/templates_scripts/generate_api_template.bash: line 5: yo: command not found
Exiting packages folder...
/home/hyper2/sr2
Compiling new app...
lerna notice cli v3.13.4
lerna info filter [ 'sr2-app' ]
lerna ERR! EFILTER No packages remain after filtering [ 'sr2-app' ]
Adding dependencies...
lerna notice cli v3.13.4
lerna info filter [ 'sr2-app' ]
lerna ERR! EFILTER No packages remain after filtering [ 'sr2-app' ]
lerna notice cli v3.13.4
lerna info filter [ 'sr2-app' ]
lerna ERR! EFILTER No packages remain after filtering [ 'sr2-app' ]
lerna notice cli v3.13.4
lerna info filter [ 'sr2-app' ]
lerna ERR! EFILTER No packages remain after filtering [ 'sr2-app' ]
lerna notice cli v3.13.4
lerna info filter [ 'sr2-app' ]
lerna ERR! EFILTER No packages remain after filtering [ 'sr2-app' ]
lerna notice cli v3.13.4
lerna info filter [ 'sr2-app' ]
lerna ERR! EFILTER No packages remain after filtering [ 'sr2-app' ]
lerna notice cli v3.13.4
lerna info filter [ 'sr2-app' ]
lerna ERR! EFILTER No packages remain after filtering [ 'sr2-app' ]
Bootstrapping...
lerna notice cli v3.13.4
lerna info Bootstrapping 1 package
lerna info Installing external dependencies
lerna info hoist Installing hoisted dependencies into root
lerna info hoist Finished bootstrapping root
lerna info hoist Pruning hoisted dependencies
lerna info hoist Finished pruning hoisted dependencies
lerna info Symlinking packages and binaries
lerna info lifecycle [email protected]~prepare: [email protected]

[email protected] prepare /home/hyper2/sr2/packages/sr2-cc
npm run build

[email protected] build
npm run clean && tsc

[email protected] clean
rimraf dist client

lerna success Bootstrapped 1 package
Adding chaincode(s)...
lerna notice cli v3.13.4
lerna info filter [ 'sr2-app' ]
lerna ERR! EFILTER No packages remain after filtering [ 'sr2-app' ]
/usr/lib/node_modules/@worldsibu/convector-rest-api/dist/models/env.smart-model.js:51
for (var _i = 0, _a = apiConfig.environments; _i < _a.length; _i++) {
^

TypeError: Cannot read property 'length' of undefined
at EnvModel.get [as selectedApiConfig] (/usr/lib/node_modules/@worldsibu/convector-rest-api/dist/models/env.smart-model.js:51:67)
at EnvModel. (/usr/lib/node_modules/@worldsibu/convector-rest-api/dist/models/env.smart-model.js:25:50)
at step (/usr/lib/node_modules/@worldsibu/convector-rest-api/node_modules/tslib/tslib.js:141:27)
at Object.next (/usr/lib/node_modules/@worldsibu/convector-rest-api/node_modules/tslib/tslib.js:122:57)
at /usr/lib/node_modules/@worldsibu/convector-rest-api/node_modules/tslib/tslib.js:115:75
at new Promise ()
at Object.__awaiter (/usr/lib/node_modules/@worldsibu/convector-rest-api/node_modules/tslib/tslib.js:111:16)
at EnvModel.save (/usr/lib/node_modules/@worldsibu/convector-rest-api/dist/models/env.smart-model.js:21:24)
at ApiGenerator. (/usr/lib/node_modules/@worldsibu/convector-rest-api/dist/apiGenerator.js:57:49)
at step (/usr/lib/node_modules/@worldsibu/convector-rest-api/node_modules/tslib/tslib.js:141:27)
[end of error log]

First off, I assume that I may need to install Yeoman but figured that it probably should have installed automatically as a dependency so I ran "npm i" from my project root. This generated another set of error messages:
[error log]
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '^10.15.3 || ^12.15.0', npm: '^6.4.1' },
npm WARN EBADENGINE current: { node: 'v16.3.0', npm: '7.15.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '^10.15.3 || ^12.15.0', npm: ' ^6.4.1' },
npm WARN EBADENGINE current: { node: 'v16.3.0', npm: '7.15.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '^8.17.0', npm: '^6.13.4' },
npm WARN EBADENGINE current: { node: 'v16.3.0', npm: '7.15.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '^8.9.0', npm: '^5.5.1' },
npm WARN EBADENGINE current: { node: 'v16.3.0', npm: '7.15.1' }
npm WARN EBADENGINE }

[email protected] install
npm-run-all -s lerna:install

[email protected] lerna:install
lerna bootstrap

lerna notice cli v3.13.4
lerna info Bootstrapping 1 package
lerna info Installing external dependencies
lerna info hoist Installing hoisted dependencies into root
lerna info hoist Finished bootstrapping root
lerna info hoist Pruning hoisted dependencies
lerna info hoist Finished pruning hoisted dependencies
lerna info Symlinking packages and binaries
lerna info lifecycle [email protected]~prepare: [email protected]

[email protected] prepare /home/hyper2/sr2/packages/sr2-cc
npm run build

[email protected] build
npm run clean && tsc

[email protected] clean
rimraf dist client

lerna success Bootstrapped 1 package

removed 24 packages, and audited 1150 packages in 24s
[end of error log]

I currently have Node v16.3.0 and npm v7.15.1 installed.

Any ideas or suggestions? TIA

Controller doesn't compile chaincode model well (pascal case)

image

Property 'testchaincode' does not exist on type 'typeof Models'. Did you mean 'Testchaincode'

It's because it's using a lowercase but the rest of the project uses PascalCase.

Replicate

conv new tetproject -c testchaincode
cd tetproject
# Run convector-rest-api there

Errors trying to generate REST api

I just followed your supply chain project. I did everything starting from setting up docker containers that hold the network and starting and instantiating the chaincode on top of that.

Also I followed your auto-generate REST api tutorial. But I am getting many errors like below while generating the rest api:

lerna ERR! npm install --global-style exited 1 in 'supplychainchaincode-app'

lerna ERR! npm install --global-style stderr:

lerna ERR! npm install --global-style stdout:

  • Node --version: 8.15.1
  • npm --version : 6.4.1

`compile` task is not finding ByteBuffer

TestERR-app: node_modules/fabric-client/types/index.d.ts(592,12): error TS2304: Cannot find name 'ByteBuffer'.
TestERR-app: node_modules/fabric-client/types/index.d.ts(593,14): error TS2304: Cannot find name 'ByteBuffer'.
TestERR-app: node_modules/fabric-client/types/index.d.ts(597,19): error TS2304: Cannot find name 'ByteBuffer'.
TestERR-app: node_modules/fabric-client/types/index.d.ts(598,21): error TS2304: Cannot find name 'ByteBuffer'.
TestERR-app: node_modules/fabric-client/types/index.d.ts(674,18): error TS2304: Cannot find name 'Long'.

This is usually fixed by adding Byte Buffer typings which is already there. Check it out.

Compile task is needed because start just runs what's in /dist, it doesn't build the project.

Documentation of env.ts is missing

This generator creates in the path packages/server/src/env.ts a configuration file to tweak the REST API server but there is no documentation about the variables set in there.

They are not self explicatory for me and I think the documentation of those variables is important.

[Enhancement] Switch from identity

It would be very useful to be able to switch from identity for trying out REST endpoints from different authorizations. Currently, in env.ts, all values are defines as constants. But perhaps this could be done more dynamically, so that a single endpoint can be tested by a admin and a non-admin.

Cannot find ClassName in apiGeneratorClass

Hi,
When following the instructions for the Auto-generated REST API (link here), during the command conv-rest-api generate api -c car -f ./org1.car.config.json I get the error: "TypeError: Cannot read property 'getClassorThrow' of undefined". This is raised by reflectionUtils.js [152:41].

I am using a newer version of convector, where the file /org1.car.cconfig.json is now named as car.config.json, so I used that file.

I could notice that in class apiGenerator, the controllerName object was not retrieving the right data to variables plainName and controllersPattern. So I did a test and directly changed the file:

case 0:
  plainName = controllerName.replace('Controller', '').toLowerCase();
  controllersPattern = path_1.join(process.cwd(), ".") +
    ("/packages/**-cc/src/" + "car" + ".controller.ts");
    return [4, reflectionUtils_1.ReflectionUtils.getClassMethods(controllersPattern, 
       "CarController")];//controllerName)];

I have basically inserted the CarController name, and then it worked.

Do you have any idea on why the correct name for the class is not being used in the application?

Change the client path

Generating a new project will try to import files from example-cc/client, but the actual path is example-cc/dist/client for compiled javascript.

Controller and controler

Hello,

After following the steps for the Auto-generated API (link), I noticed that sometimes the system refers to Controllers (with double 't') as Controler (with single 't'). One example is the router.js file, as shown below:

import * as express from 'express';
import { 
    CarControler_create_post,
    CarControler_get_get } from './controllers'
export default express.Router()
.post('/carcontroler/create', CarControler_create_post)
.get('/carcontroler/get/:id', CarControler_get_get)

It seems to be an typo in some part of the code. Could you please take a look at it?

[]s

Error trying to generate the REST API with a camel case project name

Hi, I think I found a small error/feature in the REST API generator.

I was having a lot of problems with a Typescript error popping up during the REST API generation process.

conv-rest-api generate api -c projectName -f org1.projectName.config.json
[conv-rest-api] Removing previously generated app (packages/server)
[conv-rest-api] Generating stub folder 
[conv-rest-api] Exiting packages folder...
/Users/username/GitHub/projectName
[conv-rest-api] Compiling new app...
[conv-rest-api] Bootstrapping...
[conv-rest-api] Adding chaincode(s)...
(node:39035) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getClassOrThrow' of undefined
    at /Users/username/.nvm/versions/node/v8.15.1/lib/node_modules/@worldsibu/conv-rest-api/dist/utils/reflectionUtils.js:152:41
    at new Promise (<anonymous>)
    at Object.getClassMethods (/Users/username/.nvm/versions/node/v8.15.1/lib/node_modules/@worldsibu/conv-rest-api/dist/utils/reflectionUtils.js:146:16)
    at ApiGenerator.<anonymous> (/Users/username/.nvm/versions/node/v8.15.1/lib/node_modules/@worldsibu/conv-rest-api/dist/apiGenerator.js:152:70)
    at step (/Users/username/.nvm/versions/node/v8.15.1/lib/node_modules/@worldsibu/conv-rest-api/node_modules/tslib/tslib.js:136:27)
    at Object.next (/Users/username/.nvm/versions/node/v8.15.1/lib/node_modules/@worldsibu/conv-rest-api/node_modules/tslib/tslib.js:117:57)
    at /Users/username/.nvm/versions/node/v8.15.1/lib/node_modules/@worldsibu/conv-rest-api/node_modules/tslib/tslib.js:110:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/username/.nvm/versions/node/v8.15.1/lib/node_modules/@worldsibu/conv-rest-api/node_modules/tslib/tslib.js:106:16)
    at ApiGenerator.getParams (/Users/username/.nvm/versions/node/v8.15.1/lib/node_modules/@worldsibu/conv-rest-api/dist/apiGenerator.js:144:24)
(node:39035) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:39035) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I originally had generated the project with conv new projectName in camel case, then when I ran the api generator conv-rest-api generate api -c projectName -f org1.projectName.config.json I received the error above.

I thought the error was in my model files or the controller files, but it was something simpler.

When I regenerated the project name without camel case, the api generator worked.
That wasn't my first attempt ๐Ÿ˜ƒ

I was on a Macbook, and I should know better than to use camel case in file and directory names. You may want to force lowercase.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.