Git Product home page Git Product logo

amplify-datastore-sample's Introduction

vue-base-source

VueでWebアプリケーションを開発するときの雛形です。 clone して serve したらログイン画面(SignIn / SignUp / PasswordReset)まで出来上がっています。

Setup

  1. リポジトリを変更する

clone したらリポジトリの向き先を変えて使ってください。

$ git remote remove origin
$ git remote add origin <repository_url>
  1. node_moduleをインストールする
$ yarn (or npm i)
  1. VSCode上で .ts ファイルと .vue ファイルで eslint を有効になるようにして、保存したときに prettier が走るようにするために、 .vscode/settings.json に下記を追記する

.vscode/settings.json がない場合は作成する

{
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    {
      "language": "typescript",
      "autoFix": true
    },
    {
      "language": "vue",
      "autoFix": true
    }
  ]
}
  1. envファイルを作成する

Cognito や APIGateway のエンドポイント等をenvファイルに記述します。

開発時のエンドポイントを切り替えたい場合は .env.development を生成すると開発時はそちらを見てくれます。

VUE_APP_COGNITO_IDENTITY_ID=""
VUE_APP_COGNITO_USER_POOL_ID=""
VUE_APP_COGNITO_CLIENT_ID=""
VUE_APP_API_ENDPOINT=""
  • VUE_APP_COGNITO_IDENTITY_ID: CognitoアイデンティティープールのID
  • VUE_APP_COGNITO_USER_POOL_ID: CognitoユーザープールのID
  • VUE_APP_COGNITO_CLIENT_ID: Cognitoユーザープールに紐付いているアプリクライアントのID
  • VUE_APP_API_ENDPOINT: APIGatewayのエンドポイント

Amplify Settings

Amplifyに関係する設定については plugins/aws_exports.ts に記述している

  • Auth: Cognitoに関係する情報

  • API: APIGatewayに関係する情報(AppSyncについてもここで設定する)

    • APIのエンドポイントについては配列で複数のエンドポイントを設定することができる
    endpoints: [
      {
        name: "rest-api",
        endpoint: process.env.VUE_APP_API_ENDPOINT
      }
    ]
    
    • custom_header を使って、ヘッダーにCognitoのTokenを埋め込むこともできます
    • Auth.currentSession() を呼び出したときにTokenの期限が切れていたらリフレッシュしてくれます
    endpoints: [
      {
        name: "rest-api",
        endpoint: process.env.VUE_APP_API_ENDPOINT,
        custom_header: async () => {
          return {
            Authorization: `${(await Auth.currentSession())
              .getIdToken()
              .getJwtToken()}`
          }
        }
      }
    ]
    

amplify-datastore-sample's People

Contributors

ryo-is avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.