• Stars
    star
    255
  • Rank 159,729 (Top 4 %)
  • Language
    JavaScript
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Nuxt.js Serverless SSR Starter on AWS (Lambda + API Gateway + S3) with Serverless Framework

πŸš€ Nuxt.js SSR on AWS Serverless Stack (Lambda + API Gateway + S3)

Nuxt.js Serverless Server-side Rendering Starter on AWS Serverless Stack (Lambda + API Gateway + S3) with Serverless Framework

Pre-Installed

  • Nuxt.js 2.8.1
  • Serverless Framework
  • TypeScript
  • Sass (SCSS)
  • TSLint

If you have a feature request, please create a new issue. And also, pull requests are always welcomeπŸ™

Caution

  • Libraries that are used in the client should be included in the devDependencies for Bundle size optimization. (because of Lambda Limit)
  • If you install a module for nuxt.js, it must be in a the dependencies not devDependencies
  • Auto generated URL https://*.execute-api.{region}.amazonaws.com/{stage}/ will result in a JavaScript error. (routing problem) Please use the Custom Domain.
  • If you encounter Cannot GET / error message, the error log can be founded in the AWS CloudWatch.

Pre-requisites

  • πŸ”‘ IAM Account for Serverless framework (Requires pre-configuration using aws configure)
$ aws configure

Configuration

Edit serverless.yml

service: nuxt-serverless  # 1. Edit whole service name

plugins:
  - serverless-s3-sync
  - serverless-apigw-binary
  - serverless-dotenv-plugin

package:
  individually: true
  excludeDevDependencies: true

provider:
  name: aws
  runtime: nodejs10.x
  stage: ${opt:stage, 'dev'}
  region: us-east-1  # 2. Edit AWS region name

custom:
  #######################################
  # Unique ID included in resource names.
  # Replace it with a random value for every first distribution.
  # https://www.random.org/strings/?num=1&len=6&digits=on&loweralpha=on&unique=on&format=html&rnd=new
  stackId: abcdef  # 3. Update Random Stack ID
  #######################################

  buckets:
    ASSETS_BUCKET_NAME: ${self:service}-${self:custom.stackId}-${self:provider.stage}-assets
    STATIC_BUCKET_NAME: ${self:service}-${self:custom.stackId}-${self:provider.stage}-static
  s3Sync:
    - bucketName: ${self:custom.buckets.ASSETS_BUCKET_NAME}
      localDir: .nuxt/dist/client
    - bucketName: ${self:custom.buckets.STATIC_BUCKET_NAME}
      localDir: static
  apigwBinary:
    types:
      - '*/*'

Build Setup

# Install dependencies
$ yarn

# Serve develop server at localhost:3000 using Nuxt.js
$ yarn dev

# Build
$ yarn build

# Prod server start with built assets
$ yarn start

## SERVERLESS DEPLOYMENT ##
# Build and deploy the function and bundled assets
$ yarn deploy:dev
$ yarn deploy:stage
$ yarn deploy:prod

# Remove Deployment
$ yarn undeploy:dev
$ yarn undeploy:stage
$ yarn undeploy:prod

Environment Variables

  • update .env.development, .env.production.
  • If env variable key started with NUXT_APP, it injected to client in this.$store.state.environments.
  • WARNING!: Untrack the .env.development and the .env.production before commit

Folder Structure

  • /api: You can create a sub-API based on Express.js. dynamic ajax Set-Cookie is mainly used.

    Let the URL be a * .json to distinguish it from the REST API that returns JSON.

  • /pages: File-based page routing. All ts files in /pages are only alias with export {default} to /services/${serviceName}/pages/**. all implementations should be done inside /services.

    export { default } from '~/services/home/pages/index'
  • /services: The application is divided into several services and should be implemented in a folder named by service name. (Example: /home, /auth, ...)

    • Inside a Service: /components, /queries, /pages, /helpers, /types, ...
  • /store: One Store that is globally used.

  • /types: Declare only .d.ts. The type used for each service should be stored in `/types' in each service.

To-do

  • optimize the lambda capacity (create SSR bundle with no dependencies)
  • static file serve
  • gzip Compression

More Repositories

1

next-starter

Next.js Starter using GraphQL, MobX (Next.js, TypeScript, Babel, Express.js, Apollo Client, React Apollo, React Apollo Hooks, GraphQL Codegen, MobX, mobx-state-tree, styled-components, next-optimized-images, Serverless Framework, AWS Lambda, Dotenv)
TypeScript
92
star
2

workshop-serverless-graphql

[AWSKRUG Serverless Group 2019] Serverless GraphQL Workshop
TypeScript
80
star
3

keynote-react-ssr

[AWS Community Day 2020] React.js SSR on AWS Demo
TypeScript
61
star
4

boiler

The Production-ready GraphQL boilerplate.
TypeScript
27
star
5

prisma-aws-cloudformation

Prisma Server Deployment on AWS(Fargate, RDS) with CloudFormation
16
star
6

monorepo-app-tony

πŸš€ Monorepo app template using ultra-runner
JavaScript
12
star
7

workshop-codelab-graphql

[μ–‘μž¬λ™μ½”λ“œλž© 2020] TypeScript + GraphQL 기반 API 개발 μ²΄ν—˜ν•˜κΈ°
TypeScript
6
star
8

graphql-codegen-typescript-resolvers-define

TypeScript
4
star
9

nact-persistence-mongodb

🐠 A MongoDB persistence plugin for NAct
TypeScript
4
star
10

graphql-cached

Write a cache layer for each resolver in GraphQL Shield style with Memcached
TypeScript
3
star
11

localstorage-queue

Queue(FIFO) implementation using LocalStorage API
TypeScript
3
star
12

apollo-starter

Apollo Server Starter Template
TypeScript
3
star
13

graphql-connection-resolver

Helps to easily implement the relay connection specification (inspired by Nexus.js Connection Plugin)
TypeScript
2
star
14

react-app-tony

❄️ React app template with Yarn 3+ Plug'n'Play and TypeScript, ESLint, Prettier, Vite
JavaScript
2
star
15

connectionify

Convert page-number-based pagination to cursor-based connection
TypeScript
2
star
16

colocate

WIP: colocate `vanilla-extract` code in your component.
TypeScript
2
star
17

keynote-typescript-korea-relay

[TypeScript Korea 2020] Online Meetup Relay Compiler Demo
TypeScript
1
star
18

fromundefined-comments

fromundefined.com의 λŒ“κΈ€ μ €μž₯μ†Œ
1
star
19

pnp-node-externals

Pnp support version of webpack-node-externals.
TypeScript
1
star
20

eventive

Event Sourcing Framework in MongoDB
TypeScript
1
star