mirror of https://github.com/Seich/Beau.git
Update example (#163)
* Moving from inquirer to prompts. It has a smaller dependency graph and we don't need the fancy features inquirer has. * Added a single better example to keep updated as I finalize the schema.
This commit is contained in:
parent
987c1df81e
commit
849b823311
|
|
@ -0,0 +1,23 @@
|
||||||
|
endpoint: https://pokeapi.co/api/v2
|
||||||
|
|
||||||
|
# Try replacing this pokemon using params:
|
||||||
|
# beau request get-pokemon -P "pokemon=dragapult"
|
||||||
|
environment:
|
||||||
|
_:
|
||||||
|
pokemon: ditto
|
||||||
|
|
||||||
|
GET /pokemon/$env._.pokemon: get-pokemon
|
||||||
|
GET $get-pokemon.body.location_area_encounters: get-encounters
|
||||||
|
|
||||||
|
---
|
||||||
|
host: httpbin
|
||||||
|
endpoint: https://httpbin.org
|
||||||
|
|
||||||
|
POST /anything:
|
||||||
|
- alias: post-first-area
|
||||||
|
payload:
|
||||||
|
area: $get-encounters.body.0.location_area.name
|
||||||
|
|
||||||
|
- alias: post-pokemon-type
|
||||||
|
payload:
|
||||||
|
type: $get-pokemon.body.types.0.type.name
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
VERSION: 1
|
|
||||||
ENDPOINT: https://api.github.com
|
|
||||||
|
|
||||||
auth: &auth
|
|
||||||
HEADERS:
|
|
||||||
Authorization: token asfdasf123423sd1fgnh7d83n478
|
|
||||||
User-Agent: Beau
|
|
||||||
|
|
||||||
GET /user:
|
|
||||||
ALIAS: $user
|
|
||||||
<<: *auth
|
|
||||||
|
|
||||||
GET /user/repos:
|
|
||||||
ALIAS: $repos
|
|
||||||
<<: *auth
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
version: 1
|
|
||||||
endpoint: http://httpbin.org
|
|
||||||
|
|
||||||
environment:
|
|
||||||
the:
|
|
||||||
post: 2
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
headers:
|
|
||||||
hello: 'Hello2'
|
|
||||||
|
|
||||||
POST /anything:
|
|
||||||
alias: anything
|
|
||||||
payload:
|
|
||||||
title: $jpa:get-post.body.title
|
|
||||||
|
|
||||||
---
|
|
||||||
host: jpa
|
|
||||||
endpoint: http://jsonplaceholder.typicode.com
|
|
||||||
|
|
||||||
GET /posts/$env.the.post: get-post
|
|
||||||
GET /users/$jpa:get-post.body.userId: hello
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
version: 1
|
|
||||||
endpoint: https://httpbin.org/
|
|
||||||
|
|
||||||
cookiejar: true
|
|
||||||
environment:
|
|
||||||
params:
|
|
||||||
name: David
|
|
||||||
|
|
||||||
GET /anything:
|
|
||||||
- alias: anything
|
|
||||||
payload:
|
|
||||||
name: $env.params.name
|
|
||||||
- alias: anything2
|
|
||||||
|
|
||||||
GET /cookies/set:
|
|
||||||
alias: set-cookies
|
|
||||||
params:
|
|
||||||
hello: World
|
|
||||||
|
|
||||||
GET /status/418:
|
|
||||||
alias: teapot
|
|
||||||
|
|
||||||
POST /post:
|
|
||||||
alias: post
|
|
||||||
formdata:
|
|
||||||
id: $[uuid()]
|
|
||||||
file: $[createReadStream('./github.yml')]
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
version: 1
|
|
||||||
endpoint: 'http://jsonplaceholder.typicode.com'
|
|
||||||
|
|
||||||
environment:
|
|
||||||
the:
|
|
||||||
post: 1
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
headers:
|
|
||||||
hello: $posts.body.0.userId
|
|
||||||
|
|
||||||
GET /posts/$env.the.post: get-post
|
|
||||||
|
|
||||||
GET /posts/:
|
|
||||||
alias: posts
|
|
||||||
headers:
|
|
||||||
hello: false
|
|
||||||
|
|
||||||
POST /posts/:
|
|
||||||
alias: new-post
|
|
||||||
documentation:
|
|
||||||
title: New Post
|
|
||||||
|
|
||||||
GET /users/$posts.body.0.userId:
|
|
||||||
alias: post-user
|
|
||||||
documentation:
|
|
||||||
description: Fetches the user for a give post.
|
|
||||||
params:
|
|
||||||
hello: 'world'
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
endpoint: http://localhost:10080
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
- jwt:
|
|
||||||
data:
|
|
||||||
userId: 12
|
|
||||||
name: Sergio
|
|
||||||
secret: 'asdfasdf+asdfasdf/asdfasdfasdfasdf=='
|
|
||||||
|
|
||||||
GET /test:
|
|
||||||
alias: test
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
VERSION: '1'
|
|
||||||
ENDPOINT: https://slack.com/api
|
|
||||||
|
|
||||||
auth: &auth
|
|
||||||
token: xoxp-139455775026-139455775090-147751461120-f224ed6ffee029869a0f138d0859e7d6
|
|
||||||
|
|
||||||
GET /users.getPresence:
|
|
||||||
ALIAS: presence
|
|
||||||
PARAMS:
|
|
||||||
<<: *auth
|
|
||||||
|
|
||||||
GET /channels.list:
|
|
||||||
ALIAS: channel-list
|
|
||||||
PARAMS:
|
|
||||||
<<: *auth
|
|
||||||
exclude_archived: true
|
|
||||||
|
|
||||||
GET /channels.info:
|
|
||||||
ALIAS: channel-info
|
|
||||||
PARAMS:
|
|
||||||
<<: *auth
|
|
||||||
channel: $channel-list.response.body.channels.0.id
|
|
||||||
|
|
||||||
POST /chat.postMessage:
|
|
||||||
ALIAS: new-message
|
|
||||||
PARAMS:
|
|
||||||
<<: *auth
|
|
||||||
channel: $channel-info.response.body.channel.id
|
|
||||||
text: 'Hey Seich!'
|
|
||||||
parse: full
|
|
||||||
link_names: true
|
|
||||||
username: Beau
|
|
||||||
|
|
||||||
GET /users.list:
|
|
||||||
ALIAS: user-list
|
|
||||||
PARAMS:
|
|
||||||
<<: *auth
|
|
||||||
15
schema.json
15
schema.json
|
|
@ -71,6 +71,9 @@
|
||||||
"cookiejar": {
|
"cookiejar": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"host": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"$ref": "#/definitions/requestObject"
|
"$ref": "#/definitions/requestObject"
|
||||||
},
|
},
|
||||||
|
|
@ -83,7 +86,17 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"environment": {}
|
"environment": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": true,
|
||||||
|
"properties": {
|
||||||
|
"_": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Environment variables brought in by cli params or dotenv.",
|
||||||
|
"additionalProperties": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"patternProperties": {
|
"patternProperties": {
|
||||||
"(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH)\\s.*": {
|
"(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH)\\s.*": {
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,8 @@ class Request {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(cache = new RequestCache()) {
|
async exec(cache = new RequestCache()) {
|
||||||
const isPathFullUrl = isUrl(this.PATH)
|
|
||||||
|
|
||||||
let settings = cache.parse({
|
let settings = cache.parse({
|
||||||
baseUrl: isPathFullUrl ? '' : this.ENDPOINT,
|
baseUrl: '',
|
||||||
uri: this.PATH,
|
uri: this.PATH,
|
||||||
method: this.VERB,
|
method: this.VERB,
|
||||||
jar: this.COOKIEJAR,
|
jar: this.COOKIEJAR,
|
||||||
|
|
@ -83,6 +81,9 @@ class Request {
|
||||||
resolveWithFullResponse: true
|
resolveWithFullResponse: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isPathFullUrl = isUrl(settings.uri)
|
||||||
|
settings.baseUrl = isPathFullUrl ? '' : this.ENDPOINT
|
||||||
|
|
||||||
settings = removeOptionalKeys(settings, [
|
settings = removeOptionalKeys(settings, [
|
||||||
'headers',
|
'headers',
|
||||||
'qs',
|
'qs',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue