Skip to content

Commit ee67b1e

Browse files
committed
Resolve conflicts
2 parents 17928f2 + 106bc67 commit ee67b1e

25 files changed

+1339
-2350
lines changed

.eslintrc.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ module.exports = {
1313
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
1414
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
1515
'@nuxtjs',
16-
'plugin:prettier/recommended'
16+
'prettier',
17+
'prettier/vue',
18+
'plugin:prettier/recommended',
19+
'plugin:nuxt/recommended'
1720
],
1821
// required to lint *.vue files
1922
plugins: ['prettier'],
@@ -35,7 +38,8 @@ module.exports = {
3538
'error',
3639
{
3740
singleQuote: true,
38-
semi: false
41+
semi: false,
42+
endOfLine:"auto"
3943
}
4044
],
4145
}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11.6.0
1+
lts/dubnium

.yarnclean

Lines changed: 0 additions & 45 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,26 @@
1010
Live demo can be found [here](https://nuxt-netlify-functions-example.netlify.com/).
1111

1212

13-
## Info
14-
For the requests on the client side we use the [Axios Module](https://github.com/nuxt-community/axios-module). To proxy locally you have to set up the [Proxy Module](https://github.com/nuxt-community/proxy-module) in `nuxt.config.js`:
15-
16-
```js
17-
proxy: {
18-
'/.netlify': {
19-
target: 'http://localhost:9000',
20-
pathRewrite: { '^/.netlify/functions': '' }
21-
}
22-
}
23-
```
13+
## Testing functions locally
14+
Thanks to the [Netlify Dev](https://www.netlify.com/products/dev/) command in the Netlify CLI (`yarn global add nelitfy-cli`), you can test your functions locally with no build step involved!
15+
16+
After building the app and running `netlify dev` or `ntl dev`, you can test the functions locally by hitting the endpoint http://localhost:8888/.netlify/functions/<function-name>
17+
2418

2519
## Build Setup
2620

2721
``` bash
28-
# Use nvm
22+
# Use Node version specified in nvmrc
2923
$ nvm use
3024

3125
# Install dependencies
3226
$ yarn
3327

34-
# Build lambda functions locally
35-
$ yarn netlify-lambda build netlify-lambda-src
36-
37-
# Serve lambda functions locally
38-
$ yarn netlify-lambda serve netlify-lambda-src
28+
# Build Nuxt app
29+
$ yarn build
3930

40-
# Serve nuxt app with hot reload at localhost:3000
41-
$ yarn dev
31+
# Serve Nuxt app and Netlify functions at localhost:8888
32+
$ netlify dev
4233

4334
# Generate static project
4435
$ yarn generate

components/Example1.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ export default {
2525
<template>
2626
<div>
2727
<h2>1. Hello, World!</h2>
28-
<ElButton type="primary" data-cy="btn-hello-world" @click="helloWorld()">Hello</ElButton>
28+
<ElButton type="primary" data-cy="btn-hello-world" @click="helloWorld()"
29+
>Hello</ElButton
30+
>
2931
<p>Response: {{ response }}</p>
30-
<p v-if="error" style="color:red;"><strong>Error {{ error.status }}</strong><br>{{ error.data }}</p>
32+
<p v-if="error" style="color:red;">
33+
<strong>Error {{ error.status }}</strong>
34+
<br />
35+
{{ error.data }}
36+
</p>
3137
</div>
3238
</template>

components/Example2.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,35 @@ export default {
2828
</script>
2929

3030
<template>
31-
<ElForm ref="form" :model="form" inline label-width="auto" label-position="left" @submit.native.prevent="helloName(form.name)">
31+
<ElForm
32+
ref="form"
33+
:model="form"
34+
inline
35+
label-width="auto"
36+
label-position="left"
37+
@submit.native.prevent="helloName(form.name)"
38+
>
3239
<h2>2. Hello, {name}</h2>
3340
<ElFormItem label="Name">
34-
<ElInput v-model="form.name" placeholder="Your name" required data-cy="input-hello-name" />
41+
<ElInput
42+
v-model="form.name"
43+
placeholder="Your name"
44+
required
45+
data-cy="input-hello-name"
46+
/>
3547
</ElFormItem>
36-
<ElButton type="primary" data-cy="btn-hello-name" @click="helloName(form.name)">👋 Say hello</ElButton>
48+
<ElButton
49+
type="primary"
50+
data-cy="btn-hello-name"
51+
@click="helloName(form.name)"
52+
>
53+
👋 Say hello
54+
</ElButton>
3755
<p>Response: {{ response }}</p>
38-
<p v-if="error" style="color:red;"><strong>Error {{ error.status }}</strong><br>{{ error.data }}</p>
56+
<p v-if="error" style="color:red;">
57+
<strong>Error {{ error.status }}</strong>
58+
<br />
59+
{{ error.data }}
60+
</p>
3961
</ElForm>
4062
</template>

components/Example3.vue

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
try {
1616
const res = await this.$axios.$post(
1717
'/.netlify/functions/hello-name-post',
18-
{ name: name }
18+
{ name }
1919
)
2020
this.response = res
2121
this.error = null
@@ -41,14 +41,41 @@ export default {
4141
</script>
4242

4343
<template>
44-
<ElForm ref="form" :model="form" inline label-width="auto" label-position="left" @submit.native.prevent="helloNamePost(form.name)">
44+
<ElForm
45+
ref="form"
46+
:model="form"
47+
inline
48+
label-width="auto"
49+
label-position="left"
50+
@submit.native.prevent="helloNamePost(form.name)"
51+
>
4552
<h2>3. Hello, {name} (POST version)</h2>
4653
<ElFormItem label="Name">
47-
<ElInput v-model="form.name" placeholder="Your name" data-cy="input-hello-name-post" />
54+
<ElInput
55+
v-model="form.name"
56+
placeholder="Your name"
57+
data-cy="input-hello-name-post"
58+
/>
4859
</ElFormItem>
49-
<ElButton type="primary" data-cy="btn-hello-name-post" @click="helloNamePost(form.name)">👋 Say hello</ElButton>
50-
<ElButton type="danger" data-cy="btn-hello-name-post-error" @click="helloNamePostError(form.name)">.$get() Error</ElButton>
60+
<ElButton
61+
type="primary"
62+
data-cy="btn-hello-name-post"
63+
@click="helloNamePost(form.name)"
64+
>
65+
👋 Say hello
66+
</ElButton>
67+
<ElButton
68+
type="danger"
69+
data-cy="btn-hello-name-post"
70+
@click="helloNamePostError(form.name)"
71+
>
72+
.$get() Error
73+
</ElButton>
5174
<p>Response: {{ response }}</p>
52-
<p v-if="error" style="color:red;"><strong>Error {{ error.status }}</strong><br>{{ error.data }}</p>
75+
<p v-if="error" style="color:red;">
76+
<strong>Error {{ error.status }}</strong>
77+
<br />
78+
{{ error.data }}
79+
</p>
5380
</ElForm>
5481
</template>

components/Example4.vue

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,35 @@ export default {
2828
</script>
2929

3030
<template>
31-
<ElForm ref="form" :model="form" inline label-width="auto" label-position="left" @submit.native.prevent="randomCat(form.name)">
31+
<ElForm
32+
ref="form"
33+
:model="form"
34+
inline
35+
label-width="auto"
36+
label-position="left"
37+
@submit.native.prevent="randomCat(form.name)"
38+
>
3239
<h2>4. Get a random cat with your name</h2>
3340
<p><em>API call done by your browser</em></p>
3441
<ElFormItem label="Name">
35-
<ElInput data-cy="input-random-cat" v-model="form.name" placeholder="Your name" required />
42+
<ElInput
43+
v-model="form.name"
44+
data-cy="input-random-cat"
45+
placeholder="Your name"
46+
required
47+
/>
3648
</ElFormItem>
37-
<ElButton type="primary" data-cy="btn-random-cat" @click="randomCat(form.name)">🐈 Meow</ElButton>
38-
<p>Response:
39-
<br><br><img data-cy="img-random-cat" v-show="response" :src="response" style="width:100%;height:auto;">
49+
<ElButton type="primary" @click="randomCat(form.name)">🐈 Meow</ElButton>
50+
<p>
51+
Response:
52+
<br />
53+
<br />
54+
<img v-show="response" :src="response" style="width:100%;height:auto;" />
55+
</p>
56+
<p v-if="error" style="color:red;">
57+
<strong>Error {{ error.status }}</strong>
58+
<br />
59+
{{ error.data }}
4060
</p>
41-
<p v-if="error" style="color:red;"><strong>Error {{ error.status }}</strong><br>{{ error.data }}</p>
4261
</ElForm>
4362
</template>

components/Example5.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,26 @@ export default {
3838
</script>
3939

4040
<template>
41-
<ElForm ref="form" :model="form" inline label-width="auto" label-position="left" @submit.native.prevent="icanhazip()">
41+
<ElForm
42+
ref="form"
43+
:model="form"
44+
inline
45+
label-width="auto"
46+
label-position="left"
47+
@submit.native.prevent="icanhazip()"
48+
>
4249
<h2>5. icanhazip.com</h2>
4350
<p><em>API call done by lambda function</em></p>
4451
<p>Your IP: {{ ip }}</p>
45-
<ElButton type="primary" @click="icanhazip()">🤖 Haz AWS IP please</ElButton>
52+
<ElButton type="primary" @click="icanhazip()">
53+
🤖 Haz AWS IP please
54+
</ElButton>
4655
<ElButton type="info" @click="response = '—'">Clear</ElButton>
4756
<p>Response: {{ response }}</p>
48-
<p v-if="error" style="color:red;"><strong>Error {{ error.status }}</strong><br>{{ error.data }}</p>
57+
<p v-if="error" style="color:red;">
58+
<strong>Error {{ error.status }}</strong>
59+
<br />
60+
{{ error.data }}
61+
</p>
4962
</ElForm>
5063
</template>

components/Example6.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,32 @@ export default {
6565
</script>
6666

6767
<template>
68-
<ElForm ref="mailgunForm" :rules="rules" :model="form" label-width="80px" label-position="left">
69-
<h2>6. Send form submission with <a href="https://www.mailgun.com/" target="_blank">Mailgun</a></h2>
68+
<ElForm
69+
ref="mailgunForm"
70+
:rules="rules"
71+
:model="form"
72+
label-width="80px"
73+
label-position="left"
74+
>
75+
<h2>
76+
6. Send form submission with
77+
<a href="https://www.mailgun.com/" target="_blank">Mailgun</a>
78+
</h2>
7079
<ElFormItem label="Name" prop="name">
7180
<ElInput v-model="form.name" placeholder="Your name" required />
7281
</ElFormItem>
7382
<ElFormItem label="Email" prop="email">
7483
<ElInput v-model="form.email" placeholder="Your email" required />
7584
</ElFormItem>
76-
<ElButton type="primary" @click="submitForm('mailgunForm')">💌 Send form</ElButton>
85+
<ElButton type="primary" @click="submitForm('mailgunForm')">
86+
💌 Send form
87+
</ElButton>
7788
<ElButton type="info" @click="resetForm('mailgunForm')">Reset</ElButton>
7889
<p>Response: {{ response }}</p>
79-
<p v-if="error" style="color:red;"><strong>Error {{ error.status }}</strong><br>{{ error.data }}</p>
90+
<p v-if="error" style="color:red;">
91+
<strong>Error {{ error.status }}</strong>
92+
<br />
93+
{{ error.data }}
94+
</p>
8095
</ElForm>
8196
</template>

components/Example7.vue

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
try {
1616
const res = await this.$axios.$post(
1717
'/.netlify/functions/slack-webhook',
18-
{ name: name }
18+
{ name }
1919
)
2020
this.response = res
2121
this.error = null
@@ -29,13 +29,26 @@ export default {
2929
</script>
3030

3131
<template>
32-
<ElForm ref="form" :model="form" inline label-width="auto" label-position="left" @submit.native.prevent="sendSlackMessage(form.name)">
32+
<ElForm
33+
ref="form"
34+
:model="form"
35+
inline
36+
label-width="auto"
37+
label-position="left"
38+
@submit.native.prevent="sendSlackMessage(form.name)"
39+
>
3340
<h2>7. Send a Slack message</h2>
3441
<ElFormItem label="Name">
3542
<ElInput v-model="form.name" placeholder="Your name" />
3643
</ElFormItem>
37-
<ElButton type="primary" @click="sendSlackMessage(form.name)">👋 Say hello</ElButton>
44+
<ElButton type="primary" @click="sendSlackMessage(form.name)">
45+
👋 Say hello
46+
</ElButton>
3847
<p>Response: {{ response }}</p>
39-
<p v-if="error" style="color:red;"><strong>Error {{ error.status }}</strong><br>{{ error.data }}</p>
48+
<p v-if="error" style="color:red;">
49+
<strong>Error {{ error.status }}</strong>
50+
<br />
51+
{{ error.data }}
52+
</p>
4053
</ElForm>
4154
</template>
File renamed without changes.
File renamed without changes.
File renamed without changes.

netlify-lambda-src/icanhazip.js renamed to functions/icanhazip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fetch from 'node-fetch'
1+
const fetch = require('node-fetch')
22

33
const API_ENDPOINT = 'https://icanhazip.com/'
44

0 commit comments

Comments
 (0)