Rewriting note-service using CDK, TypeScript, and GraphQL. It's a CRUD app for storing notes.
- Sign up for an AWS account.
- Follow the instructions to install and configure the AWS CLI on your computer.
- Bootstrap your AWS account ("environment") with the CDK.
- Install NodeJS on your computer. We recommend the version specified in the
.nvmrc
file in the root of this project.
- Clone this repo and run
npm install
from the project root. - From the project root run
npm run deploy
. This will build and deploy this application using thecdk
to your bootstrapped AWS account/region. Note: the first time running this command might result in an error...if that happens runnpm run build
first. 2a. If using a non-default AWS profile, you cannpm run build
to build the TypeScript and then runnpm run cdk deploy -- --profile <your-profile-name-here>
- Get the
apiId
andapiURL
from the output in your console. You will need these values later to make requets to the API. - Send requests to the application using a third party client or login to the AWS AppSync console and make requests from
Queries
. I personally like to use Postman, but here's some other suggestions if you don't have a preferred way to send requests to an API.
Currently this application is using the API key authorization setting. You can obtain the API key by logging into the AWS AppSync console after a successful deploy. Alternatively, you can run this command using the AWS CLI and the apiId
that printed out to your console after a successfuly deploy to obtain your key:
aws appsync list-api-keys --api-id <api id here>
The key is good for 30 days after deploy. After that you'll need to generate a new one.
If you're using Postman or making API calls through a client make sure to set a header x-api-key
to the value of your API key.
- List notes
query ListNotes {
listNotes {
items {
author
content
createdAt
updatedAt
id
}
total
}
}
- Get note by id
query GetNote($id: ID = "Note id goes here") {
getNote(id: $id) {
author
content
createdAt
id
updatedAt
}
}
- Create note
mutation CreateNote($author: String = "Author goes here", $content: String = "Content goes here") {
createNote(note: {author: $author, content: $content}) {
author
content
createdAt
id
updatedAt
}
}
- Delete note
mutation DeleteNote($id: ID = "ID to delete goes here") {
deleteNote(id: $id)
}
- Update note
mutation UpdateNote($content: String = "add note content here") {
updateNote(content: $content, id: "add note id here") {
updatedAt
id
createdAt
content
author
}
}
To remote the CloudFormation stack and created resources run npm run destroy
and confirm on the command line from the project root.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run deploy
run typescript compiler then deploy to your default AWS account/region via the cdknpm install
installs all dependencies including thepostinstall
scriptnpm run test
perform the jest unit testsnpm run cdk diff
compare deployed stack with current statenpm run cdk synth
emits the synthesized CloudFormation template
The cdk.json
file tells the CDK Toolkit how to execute the app.
See CONTRIBUTING.md for more info on our guildelines.