Skip to content

Commit 49879ce

Browse files
committed
Cleaning up project docs, folder structure, and adding service landing page.
1 parent 43616f1 commit 49879ce

30 files changed

+4826
-13
lines changed

README.md

Lines changed: 93 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,97 @@
1-
# WebPipe Block Demos
1+
# WebPipe Examples
22

3-
In this repo we're demonstrating simple but complete example blocks. Using
4-
`now.sh`, Node, and the node-webpipe server module.
3+
> Welcome to the world's finest private collection of meticulously handcrafted
4+
> WebPipes.
55
6-
## Examples
6+
> This project is a single web service (available at
7+
> [webpip.es](https://webpip.es)) built on top of the
8+
> [ZEIT Now](https://github.com/zeit/now-examples) cloud platform.
79
8-
Try running a few client requests locally.
10+
\*Note: As of 6/8/2019, only NodeJS examples exist the moment. However,we should
11+
be able to include any Now-supported runtime.
12+
13+
## Public Convenience API
14+
15+
As a convenience, each example is publically available at via
16+
[webpip.es](https://webpip.es). You can check `now.json` for each example's HTTP
17+
pathname, but basically, the folder each lives in is also the HTTP pathname.
18+
Accordingly, you can find the `./api/parse-url` example is available via
19+
`https://webpip.es/parse-url`:
20+
21+
```bash
22+
curl -v -X OPTIONS https://webpip.es/parse-url
23+
```
24+
25+
<details>
26+
<summary>Response body is the input & output block definitions.</summary>
27+
28+
```json
29+
{
30+
"name": "Parse URL",
31+
"description": "Parse URL using WHATWG URL Standard.",
32+
"inputs": [
33+
{
34+
"name": "url",
35+
"type": "string",
36+
"description": "A url to parse."
37+
}
38+
],
39+
"outputs": [
40+
{
41+
"name": "parts",
42+
"type": "objects",
43+
"description": "Returns the parsed URL parts."
44+
}
45+
]
46+
}
47+
```
48+
49+
</details>
50+
51+
> _Nice things are nice._ Please be mindful and keep your _use_ & _usage_
52+
> responsible. It's intended to serve primarily as a hands-on demonstration for
53+
> newcomers.
54+
55+
## Full Example
56+
57+
Try running a few client requests locally. Just run `node index.js` inside the
58+
example folder, or `now dev` if you prefer.
59+
60+
It may be a bit easier starting with the very minimal `calculate-square-root`
61+
WebPipe. That said, the examples aren't structured in any particular order or
62+
and don't have any sort of difficulty levels, so feel free to explore in
63+
whatever way feels most comfortable.
64+
65+
```bash
66+
curl -v -X OPTIONS \
67+
https://webpip.es/inspect-hostname-dns
68+
```
69+
70+
<details>
71+
<summary>Response body is the input & output block definitions.</summary>
72+
73+
```json
74+
{
75+
"name": "DNS Lookup",
76+
"description": "Determine whether or not a hostname exists.",
77+
"inputs": [
78+
{
79+
"name": "hostname",
80+
"type": "string",
81+
"description": "A hostname to lookup."
82+
}
83+
],
84+
"outputs": [
85+
{
86+
"name": "ok",
87+
"type": "bool",
88+
"description": "Returns true of false if lookup succeeds."
89+
}
90+
]
91+
}
92+
```
93+
94+
</details>
995

1096
### DNS Lookup Block
1197

@@ -15,7 +101,7 @@ to do is provide. a hostname then the block does its work to find us answer.
15101

16102
## Example Usage
17103

18-
```sh
104+
```bash
19105
curl -v -X OPTIONS \
20106
https://webpip.es/inspect-hostname-dns
21107
```
@@ -46,7 +132,7 @@ curl -v -X OPTIONS \
46132

47133
</details>
48134

49-
```sh
135+
```bash
50136
curl -i -X POST \
51137
-H "Content-Type: application/json" \
52138
-d '{"inputs":[{"domain":"google.com"}]}' \
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

blocks/upload-url-to-s3/s3-uploader.js renamed to api/upload-url-to-s3/s3-uploader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const stream = require('stream')
22
const axios = require('axios')
33
const AWS = require('aws-sdk')
4-
const url = require('url') // built-in utility
4+
const url = require('url')
55

66
class S3RemoteUploader {
77
constructor (remoteAddr) {

now.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"name": "block-demos",
2+
"name": "webpipe-examples",
33
"version": 2,
44
"builds": [
5-
{ "src": "blocks/calculate-square-root/*.js", "use": "@now/node" },
5+
{ "src": "www/package.json", "use": "@now/next" },
6+
{ "src": "api/calculate-square-root/*.js", "use": "@now/node" },
67
{ "src": "blocks/parse-url/*.js", "use": "@now/node" },
78
{ "src": "blocks/parse-rss/*.js", "use": "@now/node" },
89
{ "src": "blocks/convert-markdown-to-html/*.js", "use": "@now/node" },
@@ -15,6 +16,11 @@
1516
{
1617
"src": "/(.*)",
1718
"dest": "blocks/$1"
19+
},
20+
{
21+
"src": "/(.*)",
22+
"methods": ["GET"],
23+
"dest": "www/$1"
1824
}
1925
],
2026
"regions": ["gru1", "hnd1", "iad1", "sfo1"],

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
2-
"name": "block-demos",
2+
"name": "webpipe-examples",
33
"version": "1.0.0",
4-
"description": "A fine collection of hand-crafted webpipes.",
4+
"description": "A fine collection of hand-crafted example webpipes.",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"
77
},
88
"author": "Matthew Hudson",
99
"license": "MIT",
1010
"dependencies": {
11-
"@google-cloud/vision": "^1.1.3",
1211
"node-webpipe": "0.0.3"
1312
}
1413
}

www/favicon.ico

100 KB
Binary file not shown.

www/favicon.png

826 Bytes
Loading

www/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
target: 'serverless'
3+
}

www/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "webpipe-examples",
3+
"license": "MIT",
4+
"private": true,
5+
"dependencies": {
6+
"next": "^8.0.0-canary.2",
7+
"react": "^16.7.0",
8+
"react-dom": "^16.7.0"
9+
},
10+
"scripts": {
11+
"now-build": "next build"
12+
}
13+
}

www/pages/index.js

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
const Page = () => (
2+
<div className='container'>
3+
<div className='logo'>
4+
<svg
5+
xmlns='http://www.w3.org/2000/svg'
6+
xmlSpace='preserve'
7+
width={200}
8+
height={200}
9+
fill='#0036ff'
10+
version='1.1'
11+
viewBox='-21.125 -5 100 100'>
12+
<path d='m60.053 3v18.439c0 1.657-1.293 3-2.89 3h-4.738v62.265c0 1.82-1.411 3.296-3.153 3.296h-38.605c-1.742 0-3.154-1.476-3.154-3.296v-62.265h-4.624c-1.596 0-2.889-1.343-2.889-3v-18.439c0-1.657 1.293-3 2.889-3h54.274c1.597 0 2.89 1.343 2.89 3zm-39.544 23.268c0-1.063-0.816-1.926-1.823-1.926h-3.931c-1.006 0-1.823 0.863-1.823 1.926v57.551c0 1.063 0.816 1.927 1.823 1.927h3.931c1.006 0 1.823-0.863 1.823-1.927v-57.551zm-10.583-22.896h-3.932c-1.006 0-1.822 0.784-1.822 1.75v13.221c0 0.967 0.816 1.751 1.822 1.751h3.932c1.006 0 1.822-0.784 1.822-1.751v-13.22c0-0.967-0.816-1.751-1.822-1.751z' />
13+
</svg>
14+
</div>
15+
16+
<div className='intro'>
17+
<h1>
18+
Uh oh! If you're here you're probably a little lost, need a little help?
19+
</h1>
20+
<h3>Warning Notice</h3>
21+
<p>
22+
Webpip.es do not accept HTTP <code>GET</code> requests.
23+
</p>
24+
<p>
25+
Please remember to use the appropriate HTTP Method, either{' '}
26+
<code>OPTIONS</code>
27+
or <code>POST</code>.
28+
</p>
29+
30+
<hr />
31+
<h3>Helpful Resources</h3>
32+
<p>
33+
You might find this{' '}
34+
<a href='https://codepen.io/matthewhudson/full/GVEmBo' target='_blank'>
35+
Codepen
36+
</a>{' '}
37+
helpful, it's an example of the JavaScript client invoking a simple
38+
WebPipe that converts GitHub-flavored Markdown.
39+
</p>
40+
<p>
41+
You can also visit the{' '}
42+
<a
43+
href='https://webpipes.org'
44+
title='WebPipes Official Site'
45+
target='_blank'>
46+
WebPipes.org
47+
</a>{' '}
48+
Official Site for a Slack invite, and access to other community
49+
resources &amp; gathering spots.
50+
</p>
51+
52+
<hr />
53+
54+
<p>
55+
View this project on{' '}
56+
<a
57+
href='https://github.com/webpipes/webpipe-examples'
58+
title='GitHub for this project'
59+
target='_blank'>
60+
GitHub
61+
</a>
62+
.
63+
</p>
64+
</div>
65+
<style jsx global>{`
66+
* {
67+
box-sizing: border-box;
68+
}
69+
html,
70+
body {
71+
height: 100%;
72+
}
73+
body {
74+
margin: 0;
75+
color: white;
76+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
77+
'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans',
78+
'Helvetica Neue', sans-serif;
79+
text-rendering: optimizeLegibility;
80+
-webkit-font-smoothing: antialiased;
81+
-moz-osx-font-smoothing: grayscale;
82+
background: radial-gradient(circle, #333, #333 1px, #000 1px, #000);
83+
background-size: 28px 28px;
84+
background-position: center;
85+
font-size: 18px;
86+
line-height: 1.6;
87+
font-weight: 400;
88+
}
89+
a {
90+
text-decoration: none;
91+
color: white;
92+
}
93+
strong {
94+
color: white;
95+
font-weight: 600;
96+
}
97+
code {
98+
font-family: Menlo, Monaco, Lucida Console, Liberation Mono,
99+
DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace,
100+
serif;
101+
font-size: 0.9em;
102+
}
103+
code::before,
104+
code::after {
105+
content: '\`';
106+
}
107+
::selection {
108+
background: #f81ce5;
109+
color: white;
110+
}
111+
::-moz-selection {
112+
background: #f81ce5;
113+
color: white;
114+
}
115+
.container {
116+
display: flex;
117+
flex-direction: column;
118+
align-items: center;
119+
justify-content: center;
120+
max-width: 100%;
121+
width: 1080px;
122+
min-height: 100vh;
123+
margin: auto;
124+
padding: 30px 20px;
125+
}
126+
.logo {
127+
margin: 30px 0 20px;
128+
}
129+
.intro {
130+
text-align: left;
131+
max-width: 640px;
132+
}
133+
.intro a {
134+
margin-right: 0.15em;
135+
border-bottom: 1px solid;
136+
}
137+
h2 {
138+
font-size: 30px;
139+
}
140+
hr {
141+
display: none;
142+
border: none;
143+
border-bottom: 1px solid #666;
144+
width: 100px;
145+
margin: 30px 0;
146+
}
147+
.clocks {
148+
display: flex;
149+
flex-wrap: wrap;
150+
flex: 1;
151+
align-items: center;
152+
justify-content: center;
153+
width: 100%;
154+
margin: 0 -10px;
155+
padding: 40px 0;
156+
max-height: 500px;
157+
}
158+
.clocks a {
159+
position: relative;
160+
flex: 1 0 25%;
161+
text-align: center;
162+
padding: 10px;
163+
margin: 20px 0;
164+
font-size: 17px;
165+
transition: all 0.1s ease;
166+
}
167+
.clocks a:hover {
168+
box-shadow: 0 0 0 1px #666;
169+
}
170+
.clock span {
171+
font-weight: 700;
172+
}
173+
.clock time {
174+
display: block;
175+
height: 3.2em;
176+
font-weight: 700;
177+
color: #fff;
178+
animation: pulse 1s forwards;
179+
}
180+
@keyframes pulse {
181+
from {
182+
color: #fff;
183+
}
184+
to {
185+
color: #bbb;
186+
}
187+
}
188+
@media screen and (max-width: 960px) {
189+
.clocks a {
190+
flex: 1 0 50%;
191+
font-size: 20px;
192+
}
193+
}
194+
@media screen and (max-width: 480px) {
195+
.clocks a {
196+
flex: 1 0 100%;
197+
}
198+
.clocks {
199+
max-height: unset;
200+
}
201+
hr {
202+
display: block;
203+
}
204+
}
205+
`}</style>
206+
</div>
207+
)
208+
209+
export default Page

0 commit comments

Comments
 (0)