acode / cli Goto Github PK
View Code? Open in Web Editor NEWAutocode CLI and standard library tooling
Home Page: https://autocode.com/
License: MIT License
Autocode CLI and standard library tooling
Home Page: https://autocode.com/
License: MIT License
When invoking a service using f
(example: f thisdavej/test
) from a different directory than my microservice directory, a warning message appears indicating that "no env.json detected".
I recognize the intent of this message; however, I think the most common use case for f
will be users invoking f
from the command line to utilize various microservices—and this error message will not be meaningful to them, and will be a distraction.
I'm thinking the error message only makes sense when invoking microservices on the local machine using f .
and thus the message should not appear otherwise. If there are other contexts where it is useful, perhaps you could include a --verbose
flag that could be used by developers for troubleshooting purposes to help guide and notify them that the env.json file could not be found.
I got this error. Looks probably because of node.js version, but how do I do for this?
$ lib init
/Users/izumisy/.nvm/versions/node/v4.5.0/lib/node_modules/lib/cli/error_log.js:8
let details = err.details[k];
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/izumisy/.nvm/versions/node/v4.5.0/lib/node_modules/lib/cli/commands/login.js:6:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
$ node --version
v4.5.0
Under the "Your Functions" tab, the "New Function" button brings up a window, but nothing I do can create a new directory and/or function.
Hello team!
Just curious, are you using AWS Lambda underneath? If so, I saw that you were supporting Node 6, do you use a shim like in Apex to make Lambda support it?
I would like to serve f in my localhost 8080 environment without using stdlib gateway eg. offline.
Do I need to setup nodejs hosting/gateway/bridge myself and call f functions or there is something already done ?
After using lib release
to push a new version of the readme file for my stdlib project, I see a 414 Nginx error when viewing the service at https://stdlib.com/services/brozeph/chess.
The contents of my readme are as follows (it is quite verbose...):
This service exists to validate and track board movements and provide a valid set of moves (in Algebraic Notation) for the consumer. The underlying functionality is provided by the open source NPM module, chess
.
stateCode
- this is the identifer for the board at the current state (this value is returned as stateCode
after each move)notation
- the notation for the next move to apply to the boardWhen an initial request is made to the API with no keyword arguments specified (stateCode
or notation
), a new game will be created and a response is returned highlighting available moves for the white
side to make. The stateCode
returned in the response represents that board at that state (for a new game, this value of stateCode
is cWFtVUExd0hFUFBhd2RDSzFMMUtZQT09
).
In order to make a subsequent move, the stateCode
of the game along with the appropriate notation
value must be supplied to the service. This will return a response with a new stateCode
that must be used in conjunction with the next move to continue to move pieces on the game's board.
All requests to the service will result in either the creation of a new game board or continuation of an existing game board. Each response will contain the following top-level properties (in a JSON payload):
stateCode
- the identifier required to resume the game at the current state (this value changes after each move)notations
a4
, Nf3
, etc.)
src
file
- the file where the piece that can be moved currently sits (a
, b
, c
, d
, e
, f
or g
)rank
- the rank where the piece that can be moved currently sites (1
, 2
, 3
, 4
, 5
, 6
, 7
or 8
)piece
moveCount
- a number representing the number of times the piece has been movedside
name
- a string indicating the color of the piece: white
or black
type
- a string indicating the type of the piece: pawn
, bishop
, knight
, rook
, queen
or king
dest
file
- the file where the piece that can be moved would move to (a
, b
, c
, d
, e
, f
or g
)rank
- the rank where the piece that can be moved would move to (1
, 2
, 3
, 4
, 5
, 6
, 7
or 8
)piece
moveCount
- a number representing the number of times the piece has been movedside
name
- a string indicating the color of the piece: white
or black
type
- a string indicating the type of the piece: pawn
, bishop
, knight
, rook
, queen
or king
history
- an array of objects with the following properties:
capturedPiece
- if a piece was captured, it would be noted herehashCode
- the identifier of the board piece position after this movealgebraic
- the algebraic notation of the movepromotion
- true
or false
depending on whether the move resulted in a promotion of a piecepiece
moveCount
- a number representing the number of times the piece has been movedside
name
- a string indicating the color of the piece: white
or black
type
- a string indicating the type of the piece: pawn
, bishop
, knight
, rook
, queen
or king
prevFile
- the previous file where the piece once lived prior to the moveprevRank
- the previous rank where the piece once lived prior to the movepostFile
- the file where the piece lives after the movepostRank
- the rank where the piece lives after the movesquares
- an array of objects with the following properties
file
- a lower case letter value that notes the column
of the chess board: a
, b
, c
, d
, e
, f
or g
, h
rank
- a number that notes the row
of chess board: 1
, 2
, 3
, 4
, 5
, 6
, 7
or 8
piece
- an object that represents the piece
moveCount
- a number representing the number of times the piece has been movedside
name
- a string indicating the color of the piece: white
or black
type
- a string indicating the type of the piece: pawn
, bishop
, knight
, rook
, queen
or king
state
check
- true
or false
indicating whether or not a King on the board is in checkmate
- true
or false
indicating whether or not a King on the board is in check materepetition
- true
or false
indicating whether a 3 fold repetition has occurred on the boardstalemate
- true
or false
indicating whether or not the board is in stalemateEach call returns a JSON payload that provides insight into available moves (notations
), the history of moves to this point (history
), each square on the board (squares
), the current state of the game (state
) and an identifier necessary for making the next move (stateCode
).
f brozeph/chess/game --stateCode "anBwRVB3RkdxVXR0L00wN3JFTmV2UT09OmIz" --notation a5
The above command returns the following:
{
"stateCode": "dlNRWDhtalVSaUpiVnFWVnQzVDNndz09OmIzOmE1",
"notations": {
"Na3": {
"src": {
"file": "b",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "knight",
"notation": "N"
}
},
"dest": {
"file": "a",
"rank": 3,
"piece": null
}
},
"Nc3": {
"src": {
"file": "b",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "knight",
"notation": "N"
}
},
"dest": {
"file": "c",
"rank": 3,
"piece": null
}
},
"Bb2": {
"src": {
"file": "c",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "bishop",
"notation": "B"
}
},
"dest": {
"file": "b",
"rank": 2,
"piece": null
}
},
"Ba3": {
"src": {
"file": "c",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "bishop",
"notation": "B"
}
},
"dest": {
"file": "a",
"rank": 3,
"piece": null
}
},
"Nf3": {
"src": {
"file": "g",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "knight",
"notation": "N"
}
},
"dest": {
"file": "f",
"rank": 3,
"piece": null
}
},
"Nh3": {
"src": {
"file": "g",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "knight",
"notation": "N"
}
},
"dest": {
"file": "h",
"rank": 3,
"piece": null
}
},
"a3": {
"src": {
"file": "a",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "a",
"rank": 3,
"piece": null
}
},
"a4": {
"src": {
"file": "a",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "a",
"rank": 4,
"piece": null
}
},
"c3": {
"src": {
"file": "c",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "c",
"rank": 3,
"piece": null
}
},
"c4": {
"src": {
"file": "c",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "c",
"rank": 4,
"piece": null
}
},
"d3": {
"src": {
"file": "d",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "d",
"rank": 3,
"piece": null
}
},
"d4": {
"src": {
"file": "d",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "d",
"rank": 4,
"piece": null
}
},
"e3": {
"src": {
"file": "e",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "e",
"rank": 3,
"piece": null
}
},
"e4": {
"src": {
"file": "e",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "e",
"rank": 4,
"piece": null
}
},
"f3": {
"src": {
"file": "f",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "f",
"rank": 3,
"piece": null
}
},
"f4": {
"src": {
"file": "f",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "f",
"rank": 4,
"piece": null
}
},
"g3": {
"src": {
"file": "g",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "g",
"rank": 3,
"piece": null
}
},
"g4": {
"src": {
"file": "g",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "g",
"rank": 4,
"piece": null
}
},
"h3": {
"src": {
"file": "h",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "h",
"rank": 3,
"piece": null
}
},
"h4": {
"src": {
"file": "h",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "h",
"rank": 4,
"piece": null
}
},
"b4": {
"src": {
"file": "b",
"rank": 3,
"piece": {
"moveCount": 1,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
"dest": {
"file": "b",
"rank": 4,
"piece": null
}
}
},
"history": [
{
"capturedPiece": null,
"hashCode": "jppEPwFGqUtt/M07rENevQ==",
"algebraic": "b3",
"promotion": false,
"piece": {
"moveCount": 1,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
},
"prevFile": "b",
"prevRank": 2,
"postFile": "b",
"postRank": 3
},
{
"capturedPiece": null,
"hashCode": "vSQX8mjURiJbVqVVt3T3gw==",
"algebraic": "a5",
"promotion": false,
"piece": {
"moveCount": 1,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
},
"prevFile": "a",
"prevRank": 7,
"postFile": "a",
"postRank": 5
}
],
"squares": [
{
"file": "a",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "rook",
"notation": "R"
}
},
{
"file": "b",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "knight",
"notation": "N"
}
},
{
"file": "c",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "bishop",
"notation": "B"
}
},
{
"file": "d",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "queen",
"notation": "Q"
}
},
{
"file": "e",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "king",
"notation": "K"
}
},
{
"file": "f",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "bishop",
"notation": "B"
}
},
{
"file": "g",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "knight",
"notation": "N"
}
},
{
"file": "h",
"rank": 1,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "rook",
"notation": "R"
}
},
{
"file": "a",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "b",
"rank": 2,
"piece": null
},
{
"file": "c",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "d",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "e",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "f",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "g",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "h",
"rank": 2,
"piece": {
"moveCount": 0,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "a",
"rank": 3,
"piece": null
},
{
"file": "b",
"rank": 3,
"piece": {
"moveCount": 1,
"side": {
"name": "white"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "c",
"rank": 3,
"piece": null
},
{
"file": "d",
"rank": 3,
"piece": null
},
{
"file": "e",
"rank": 3,
"piece": null
},
{
"file": "f",
"rank": 3,
"piece": null
},
{
"file": "g",
"rank": 3,
"piece": null
},
{
"file": "h",
"rank": 3,
"piece": null
},
{
"file": "a",
"rank": 4,
"piece": null
},
{
"file": "b",
"rank": 4,
"piece": null
},
{
"file": "c",
"rank": 4,
"piece": null
},
{
"file": "d",
"rank": 4,
"piece": null
},
{
"file": "e",
"rank": 4,
"piece": null
},
{
"file": "f",
"rank": 4,
"piece": null
},
{
"file": "g",
"rank": 4,
"piece": null
},
{
"file": "h",
"rank": 4,
"piece": null
},
{
"file": "a",
"rank": 5,
"piece": {
"moveCount": 1,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "b",
"rank": 5,
"piece": null
},
{
"file": "c",
"rank": 5,
"piece": null
},
{
"file": "d",
"rank": 5,
"piece": null
},
{
"file": "e",
"rank": 5,
"piece": null
},
{
"file": "f",
"rank": 5,
"piece": null
},
{
"file": "g",
"rank": 5,
"piece": null
},
{
"file": "h",
"rank": 5,
"piece": null
},
{
"file": "a",
"rank": 6,
"piece": null
},
{
"file": "b",
"rank": 6,
"piece": null
},
{
"file": "c",
"rank": 6,
"piece": null
},
{
"file": "d",
"rank": 6,
"piece": null
},
{
"file": "e",
"rank": 6,
"piece": null
},
{
"file": "f",
"rank": 6,
"piece": null
},
{
"file": "g",
"rank": 6,
"piece": null
},
{
"file": "h",
"rank": 6,
"piece": null
},
{
"file": "a",
"rank": 7,
"piece": null
},
{
"file": "b",
"rank": 7,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "c",
"rank": 7,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "d",
"rank": 7,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "e",
"rank": 7,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "f",
"rank": 7,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "g",
"rank": 7,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "h",
"rank": 7,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "pawn",
"notation": ""
}
},
{
"file": "a",
"rank": 8,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "rook",
"notation": "R"
}
},
{
"file": "b",
"rank": 8,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "knight",
"notation": "N"
}
},
{
"file": "c",
"rank": 8,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "bishop",
"notation": "B"
}
},
{
"file": "d",
"rank": 8,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "queen",
"notation": "Q"
}
},
{
"file": "e",
"rank": 8,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "king",
"notation": "K"
}
},
{
"file": "f",
"rank": 8,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "bishop",
"notation": "B"
}
},
{
"file": "g",
"rank": 8,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "knight",
"notation": "N"
}
},
{
"file": "h",
"rank": 8,
"piece": {
"moveCount": 0,
"side": {
"name": "black"
},
"type": "rook",
"notation": "R"
}
}
],
"state": {
"check": false,
"mate": false,
"repetition": false,
"stalemate": false
}
}
To create a new game:
curl https://f.stdlib.com/brozeph/chess/game
To make a move:
curl https://f.stdlib.com/brozeph/chess/game?stateCode=anBwRVB3RkdxVXR0L00wN3JFTmV2UT09OmIz¬ation=a5
Utilizing the f
NPM module (npm install f --save
):
const f = require('f');
f('brozeph/chess/game')({
stateCode : 'anBwRVB3RkdxVXR0L00wN3JFTmV2UT09OmIz',
notation : 'a5'
}, (err, response) => {
// handle error or response...
});
Hi,
I'm trying to understand from the documentation what is the proper way to handle setup/initialization of a new function. For example: It needs to connect to an underlying service, which takes time and I want it to be done just once on init.
Maybe I missed it, but I can't find reference for that.
Is it possible?
Thanks,
DD.
asgard:~/stdlib-workspace$ lib create foo
? Default Function Name foo
Error: Bad Request
I'm not seeing my template dependencies getting merged in with the main app template's. Are there any known issues? Can you point me to the code that should be doing this?
I've had a hard time tracking it down but I'm going to take another wack at it this evening.
Will it be possible to call my function via GET? Some apps, like podcasts agregators and rss readers, can only make get requests.
Amazon is no longer approving skills without request validation so it should be added to the template.
Where are the templates held? Possibly I could add support to it but I don't see anything related to Alexa in the lib cli.
Is there any way to debug? I suppose timeout. I'm getting this response:
Error: Unexpected server response:
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style type="text/css"> html, body, iframe { margin: 0; padding: 0; height: 100%; } iframe { display: block; width: 100%; border: none; } </style> <title>Application Error</title> </head> <body> <iframe src="//s3.amazonaws.com/heroku_pages/error.html"> <p>Application Error</p> </iframe> </body> </html>
I want to deploy my code to <stdlib>
through TravisCI (or any CI service).
I would need to set the environment variables to do this because I have to set my user. I can do this using a build.sh
script for example which can receive $USER and $PASSWD from outside, but it's insecure.
Is there any method to use an $ACCESS_TOKEN
to Deploy?
Hi, it might be a simple issue, but including dependencies in package.json just doesn't work for me. How can I do it? Thanks.
I'm interested in building and using services with f. But I can't find anywhere a list of already available examples. I would imagine there's a list of services that people have build or that you've built. Where is that list?
Users should be able to set up two factor authentication to protect their accounts.
I think it makes sense to be able to update env.json and env. variables in general without having to edit the package version.
It would be really useful to have hot reloading on the lib http
local development server, so we don't have to kill and relaunch it.
I use webtask.io that's part of auth0 and they use bearer token thats passed in the header.
What are your plans securing a call to endpoint?
use case:
person logs in with twitter , needs to process something specific to him/her , web app makes a call on his behalf.
I am hoping it won't be too complicated with enough developer control.
cheers
I can't seem to find any documentation on how logging and monitoring works with lib. Can someone point me in the right direction there?
Is there any way to dynamically set response headers? E.g. generating ETag based on response body for cache control.
lib create -t slack
worked as expected.slack-app
directory, runninglib .commands --command /hello --text hey there --channel general
Error: No parser found for extension ".json"
.The current limit is way too low.
413 Request Entity Too Large
macOS 10.12.1
node v5.1.1 (latest with Homebrew)
$ lib init
/usr/local/lib/node_modules/lib/cli/error_log.js:8
let details = err.details[k];
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Looks like ES6 issue, but I'm not sure where to declare use strict.
should probably publish a new version to npm as it currently shows:
npm install stdlib --save
whereas it is correct in the repo README as per 84c46c9
function runs fine locally but when I publish dev
or release
, I get an error.
f .
=> incubated cross-platform applications
f . 2
=> mesh 24/7 programming, liberating orchestrated collaborative touchpoints
lib up dev
...
Functions available:
antic/buzz@dev/buzz
Function
[0] iterations
f antic/buzz@dev/buzz
Error: Error: Cannot read property 'filename' of undefined
at IncomingMessage.<anonymous> (/Users/antic/.nvm/versions/node/v6.9.1/lib/node_modules/lib/node_modules/f/lib/f.js:100:27)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
https://f.stdlib.com/antic/buzz
Error: Cannot read property 'filename' of undefined
Hey there! I'm already diggin' this tool:
f james/twitter/hello sausage bacon eggs
When I saw package.json I thought I might be able to install packages from there by putting them in package.json, but that doesn't appear to be the case. If not, what should I be using package.json for?
Guys, i would like to use your service, but it makes no sense to me why these are the restrictions on the password. Can it be changed?
The cli or other website documentation should describe how to set such account information as full_name
and twitter_id
$ lib init
/home/ubuntu/.nvm/versions/node/v4.7.3/lib/node_modules/lib.cli/cli/commands/nomethod.js:96
lib({token: token, host: host, port: port})[params.name](...args, kwargs, cb);
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at /home/ubuntu/.nvm/versions/node/v4.7.3/lib/node_modules/lib.cli/node_modules/cmnd/lib/command_line_interface.js:97:20
at Array.forEach (native)
at CommandLineInterface.load (/home/ubuntu/.nvm/versions/node/v4.7.3/lib/node_modules/lib.cli/node_modules/cmnd/lib/command_line_interface.js:80:44)
When a service function returns an error, the stdlib
servers return that response as a code 400 in text/plain
without adding proper CORS headers. This causes browser libraries to fail to correctly receive any error responses. The issue seems to be entirely server-side.
Consider the following function that returns an error in some situations:
(Code is running at http://pras.stdlib.com/happy@dev/)
function.json
{
"name": "happy",
"description": "Returns the string 'happy'.",
"kwargs": { "happy": "Set this to true." }
}
index.js
module.exports = (params, callback) => {
// Return an error if happy is not true.
if (!params.kwargs.happy) {
return callback(new Error('Happy must be set to "true".'));
}
callback(null, 'happy');
};
Let's call this function from browser using the f
library:
// Load f.js in the HTML HEAD.
f('pras/happy@dev')({
happy: false // intentionally cause an error
}, (err, result) => {
console.log(err);
console.log(result);
});
What we see is that when happy
is set to true
, the stdlib servers return a response that includes an Access-Control-Allow-Origin
clause, which makes the response interpretable by the browser.
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Access-Control-Allow-Origin
Connection:keep-alive
Content-Length:54
Content-Type:application/json
Date:Tue, 18 Apr 2017 05:14:45 GMT
X-Stdlib-Environment:dev
X-Stdlib-Time:100
When happy
is set to false, however, the server responds without these headers when it returns the error:
Connection:keep-alive
Content-Length:28
Content-Type:text/plain
Date:Tue, 18 Apr 2017 05:15:12 GMT
X-Stdlib-Environment:dev
X-Stdlib-Time:100
Without the header, the browser rejects the response entirely as a security violation:
XMLHttpRequest cannot load http://f.stdlib.com/pras/happy@dev. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 400.
which means that f
loses the server's error message and returns a generic one instead:
Error: Could not run function.
I expected:
What happened:
This was on Mac Chrome
You should clean the library, or delete /dev/hello functions after a limited time avec their creation.
There are 32 pages of /dev/hello functions :(
> stdlib up dev
Invalid namespace: "maer007"
Namespace must follow these guidelines:
- Three (3) characters or more
- Begin with a letter
- Contain only alphanumeric (or -) characters
- End with a letter or number
When attempting to create a service based on the alexa template, I'm getting an error message.
Error:
lib create -t alexa --write-over
Awesome! Let's create a stdlib service!
We'll use the template alexa to proceed.
? Service Name alexa
Fetching template alexa...
Error: Could not install template alexa
fixme ;)
Would be nice to have a command like f:list
to list all the functions under a namespace. I'm not sure if it should only list under your own namespaces, for privacy.
$ stdlib f:list txgruppi/dev
txgruppi/dev/hello
txgruppi/dev/anotherfunction
My envs:
node -v
: v5.5.0Error log:
$ stdlib f:new
/usr/local/lib/node_modules/stdlib.com/index.js:4
let host = 'f.stdlib.com';
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/usr/local/lib/node_modules/stdlib.com/cli/commands/f.js:6:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
It would be nice if lib user --set password
prompted for a password if one is not supplied on the command line. This would prevent the password from appearing in my shell history.
I created a simple adder
function:
module.exports = (params, callback) => {
const x1 = Number(params.kwargs.x1);
const x2 = Number(params.kwargs.x2);
console.log(`x2 = ${x2}`);
callback(null, x1 + x2);
};
I can't figure out how to pass negative numbers in as parameter values. Here's what I'm trying:
c:\> lib . --x1 3 --x2 -2
The resulting output is:
x2 = 0
3
lib
appears to be interpreting -2
as another parameter rather than as a parameter value for x2
. Do I need to escape the -2
value somehow?
How to change the HTTP code in node function?
Example:
var requiredField = {
statusCode: 422,
body: 'CPF parameter is required'
};
callback(requiredField, null);
######
var redirectToSite = {
statusCode: 302,
body: 'www.uol.com.br'
};
callback(null, redirectToSite);
Can i help me?
something like
stdlib f:compile sub_folder
Hi,
i just fresh install the cli yarn global add lib.cli
, log in & try to create a project, then get error:
/tmp/stdlib-workspace $ lib create t
Awesome! Let's create a stdlib service!
Error: Bad Request
where can i get detail error info, or enable the verbose mode?
When installing using npm i -g lib.cli
on mac I got the following error:
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "lib.cli" "-g"
npm ERR! node v6.3.1
npm ERR! npm v3.10.3
npm ERR! path ../lib/node_modules/lib.cli/cli/bin.js
npm ERR! code EEXIST
npm ERR! errno -17
npm ERR! syscall symlink
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/lib.cli/cli/bin.js' -> '/usr/local/bin/lib'
npm ERR! File exists: ../lib/node_modules/lib.cli/cli/bin.js
npm ERR! Move it away, and try again.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/david/projects/npm-debug.log
I think that the name lib
is to generic and this can happen on other machines as well
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.