• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

hardyscc/aws-nestjs-starter: Serverless, AWS, NestJS, GraphQL and DynamoDB start ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

hardyscc/aws-nestjs-starter

开源软件地址(OpenSource Url):

https://github.com/hardyscc/aws-nestjs-starter

开源编程语言(OpenSource Language):

TypeScript 91.8%

开源软件介绍(OpenSource Introduction):

Serverless, AWS, NestJS, GraphQL and DynamoDB starter

CI Alert Status Coverage Bugs Code Smells License

Description

A starter project that makes creating a deployable AWS Serverless project extremely easy.

Technologies

Usage

git clone https://github.com/hardyscc/aws-nestjs-starter.git <Your_Project_Name>
cd <Your_Project_Name>

npm install

After that find and replace aws-nestjs-starter to your project name on the following files:

  • package.json
  • serverless.yml
  • .env

Setup AWS Credentials

  1. Sign up for an AWS account

  2. Login to your AWS account and go to the Identity & Access Management (IAM) page.

  3. Click on Users and then Add user. Enter a name in the first field to remind you this User is related to the Serverless Framework, like serverless-admin. Enable Programmatic access by clicking the checkbox. Click Next to go through to the Permissions page. Click on Attach existing policies directly. Search for and select AdministratorAccess then click Next: Review. Check to make sure everything looks good and click Create user.

  4. View and copy the API Key & Secret to a temporary place. You'll need it in the next step.

Setup Workstation

Install AWS CLI

  • Windows: choco install awscli
  • MacOS: brew install awscli

Config AWS CLI

$ aws configure

AWS Access Key ID [****************TKYQ]:
AWS Secret Access Key [****************yNO2]:
Default region name [None]:
Default output format [None]:

Please enter your AWS Access Key ID and AWS Secret Access Key

Deployment

# deploy to AWS
$ npm run deploy

Local Offline Development

# install dynamodb local
$ npm run ddb:install

# start serverless-offline server
$ npm run sls:start

# start serverless-offline server and connect to online dynamodb
$ npm run sls:online

Local NestJS Development - (Optional)

# install dynamodb local
$ npm run ddb:install

# start dynamodb local
$ npm run ddb:start

# start local nestjs server
$ npm start

# start local nestjs server in watch mode
$ npm run start:watch

# start local nestjs server and connect to online dynamodb
$ npm run start:online

Tools

# re-generate the resources/dynamodb.yml from schemas
$ npm run genres

Unit Testing

# run unit test
$ npm test

# run unit test with coverage
$ npm run test:cov

E2E Testing

# start dynamodb local
$ npm run ddb:start

# run unit test with coverage
$ npm run test:e2e

GraphQL Endpoint Test

mutation {
  createNotification(
    input: { targetId: "device1", userId: "user1", content: "Hello World" }
  ) {
    id
  }
}
query {
  notificationByUserId(userId: "user1") {
    id
    targetId
    userId
    content
    createAt
  }
}
query {
  notificationByTargetId(targetId: "device1") {
    id
    targetId
    userId
    content
    createAt
  }
}
mutation {
  updateNotification(
    id: "1ca7726e-0af8-4ff1-8ef1-4eae97377162"
    input: { status: Deleted }
  ) {
    id
    targetId
    userId
    content
    createAt
  }
}

RESTful Endpoint Test

Please remove /dev from path if test using local nestjs mode

curl -X POST 'http://localhost:3000/dev/notification' \
  -H 'Content-Type: application/json' \
  --data-raw '{ "targetId": "device1", "userId": "user1", "content": "Hello" }'
curl -X GET 'http://localhost:3000/dev/notification?targetId=device1'
curl -X GET 'http://localhost:3000/dev/notification?userId=user1'
curl -X PATCH 'http://localhost:3000/dev/notification/a30f7101-2434-4443-87fa-493c9d9d3358' \
  -H 'Content-Type: application/json' \
  --data-raw '{ "status": "Deleted" }'

Stay in touch




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap