2 |
3 | The following loaded from api backend:
4 | {{ message }}
5 |
6 |
7 |
8 |
29 |
--------------------------------------------------------------------------------
/template/scripts/build-nuxt-es5.js:
--------------------------------------------------------------------------------
1 | /* eslint no-console: 0 */
2 | const shell = require('shelljs')
3 | shell.rm('-rf', 'nuxt-es5')
4 | shell.cp('-r', 'node_modules/nuxt/lib', 'nuxt-es5')
5 |
6 | shell.rm('-rf', 'nuxt-es5/builder')
7 | shell.rm('-rf', 'nuxt-es5/common')
8 | shell.rm('-rf', 'nuxt-es5/core')
9 |
10 | shell.exec('npx babel-cli -D -d nuxt-es5/builder node_modules/nuxt/lib/builder')
11 | shell.exec('npx babel-cli -D -d nuxt-es5/common node_modules/nuxt/lib/common')
12 | shell.exec('npx babel-cli -D -d nuxt-es5/core node_modules/nuxt/lib/core')
13 |
14 | shell.mkdir('nuxt-es5/bin')
15 | shell.cp('node_modules/nuxt/bin/nuxt-build', 'nuxt-es5/bin/nuxt-build')
16 |
--------------------------------------------------------------------------------
/meta.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | helpers: {
3 | raw: function(options) {
4 | return options.fn(this)
5 | }
6 | },
7 | prompts: {
8 | name: {
9 | 'type': 'string',
10 | 'required': true,
11 | 'message': 'Project name'
12 | },
13 | description: {
14 | 'type': 'string',
15 | 'required': false,
16 | 'message': 'Project description',
17 | 'default': 'a perfect-paca project'
18 | },
19 | author: {
20 | 'type': 'string',
21 | 'message': 'Author'
22 | },
23 | },
24 | skipInterpolation: "**/*.vue",
25 | completeMessage: '{{#inPlace}}see https://github.com/phlogisticfugu/perfect-paca to get started{{/inPlace}}'
26 | };
27 |
--------------------------------------------------------------------------------
/template/serve-local.js:
--------------------------------------------------------------------------------
1 | const IS_LAMBDA = process.env.AWS_EXECUTION_ENV === 'nodejs6.10'
2 | if (IS_LAMBDA) {
3 | require('./util/node-8-backcompat')
4 | }
5 | const { Nuxt, Builder } = require(IS_LAMBDA ? './nuxt-es5' : 'nuxt')
6 | const express = require('express')
7 |
8 | const HOST = process.env.HOST || 'localhost'
9 | const PORT = process.env.PORT || 3000
10 | const app = express()
11 |
12 | process.env.HOST = HOST
13 | process.env.PORT = PORT
14 |
15 | app.use('/api', require('./src-api'))
16 |
17 | let nuxtConfig = require('./nuxt.config.js')
18 | nuxtConfig.dev = (process.env.NODE_ENV !== 'production')
19 |
20 | const nuxt = new Nuxt(nuxtConfig)
21 | app.use(nuxt.render)
22 |
23 | if (nuxtConfig.dev) {
24 | new Builder(nuxt).build()
25 | .catch((error) => {
26 | console.error(error)
27 | process.exit(1)
28 | })
29 | }
30 |
31 | app.listen(PORT, HOST)
32 | console.log(`Server listening on ${HOST}:${PORT}`)
33 |
--------------------------------------------------------------------------------
/template/handler.js:
--------------------------------------------------------------------------------
1 | require('./src-nuxt/lib/node-8-backcompat')
2 | /*
3 | * Handler definition for https://serverless.com/
4 | */
5 | const Nuxt = require('./nuxt-es5/core/nuxt')
6 |
7 | let nuxtConfig = require('./nuxt.config.js')
8 | nuxtConfig.dev = false
9 | const nuxt = new Nuxt(nuxtConfig)
10 |
11 | const awsServerlessExpressMiddleware = require('aws-serverless-express/middleware')
12 | const awsServerlessExpress = require('aws-serverless-express')
13 | const app = require('express')()
14 | const server = awsServerlessExpress.createServer(app)
15 |
16 | app.use('/api', require('./src-api'))
17 |
18 | app.use(awsServerlessExpressMiddleware.eventContext())
19 | app.use(nuxt.render)
20 |
21 | module.exports.main = (event, context) => {
22 | // workaround for double gzip encoding issue
23 | // HTTP gzip encoding should be done higher-up via something like CloudFront/CloudFlare
24 | event.headers['Accept-Encoding'] = 'identity'
25 |
26 | console.log('proxying event=', event)
27 |
28 | awsServerlessExpress.proxy(server, event, context)
29 | }
30 |
--------------------------------------------------------------------------------
/template/nuxt.config.js:
--------------------------------------------------------------------------------
1 | const IS_LAMBDA = process.env.AWS_EXECUTION_ENV === 'nodejs6.10'
2 |
3 | module.exports = {
4 | head: {
5 | titleTemplate: '%s - Paca',
6 | htmlAttrs: {
7 | 'lang': 'en-US'
8 | },
9 | meta: [
10 | { charset: 'utf-8' },
11 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }
12 | ],
13 | link: [
14 | { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
15 | ]
16 | },
17 | srcDir: 'src-nuxt/',
18 | build: {
19 | babel: {
20 | presets: ({ isServer }) => [
21 | [
22 | require.resolve('babel-preset-vue-app'),
23 | { targets: isServer ? { node: IS_LAMBDA ? '6.10.0' : '8.0.0' } : { ie: 9, uglify: true } }
24 | ]
25 | ]
26 | },
27 | /*
28 | ** Run ESLINT on save
29 | */
30 | extend (config, ctx) {
31 | if (ctx.isClient) {
32 | config.module.rules.push({
33 | enforce: 'pre',
34 | test: /\.(js|vue)$/,
35 | loader: 'eslint-loader',
36 | exclude: /(node_modules)/
37 | })
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Brad Ito
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/template/src-nuxt/layouts/default.vue:
--------------------------------------------------------------------------------
1 |