Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it
- uses: actions/checkout@v2

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
Expand All @@ -36,7 +36,7 @@ jobs:
with:
args: deploy
env:
# SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
# or if using AWS creds directly
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
11 changes: 6 additions & 5 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const addCorsHeaders = (response) => {
};

const getNote = async (event) => {
const response = { statusCode: 200 };
const response = { statusCode: 200, headers };

try {
const params = {
Expand All @@ -36,6 +36,7 @@ const getNote = async (event) => {
};
const { Item } = await db.send(new GetItemCommand(params));

console.log({ Item });
response.body = JSON.stringify({
message: "Successfully retrieved note.",
data: (Item) ? unmarshall(Item) : {},
Expand All @@ -55,7 +56,7 @@ const getNote = async (event) => {
};

const createNote = async (event) => {
const response = { statusCode: 200 };
const response = { statusCode: 200, headers };

try {
const body = JSON.parse(event.body);
Expand Down Expand Up @@ -83,7 +84,7 @@ const createNote = async (event) => {
};

const updateNote = async (event) => {
const response = { statusCode: 200 };
const response = { statusCode: 200, headers };

try {
const body = JSON.parse(event.body);
Expand Down Expand Up @@ -121,7 +122,7 @@ const updateNote = async (event) => {
};

const deleteNote = async (event) => {
const response = { statusCode: 200 };
const response = { statusCode: 200, headers };

try {
const params = {
Expand All @@ -148,7 +149,7 @@ const deleteNote = async (event) => {
};

const getAllNotes = async () => {
const response = { statusCode: 200 };
const response = { statusCode: 200, headers };

try {
const { Items } = await db.send(new ScanCommand({ TableName: process.env.DYNAMODB_TABLE_NAME }));
Expand Down
5 changes: 5 additions & 0 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ functions:
- http:
path: note/{noteId}
method: GET
cors: true
iamRoleStatements:
- Effect: "Allow"
Action:
Expand All @@ -38,6 +39,7 @@ functions:
- http:
path: note
method: POST
cors: true
iamRoleStatements:
- Effect: "Allow"
Action:
Expand All @@ -52,6 +54,7 @@ functions:
- http:
path: note/{noteId}
method: PUT
cors: true
iamRoleStatements:
- Effect: "Allow"
Action:
Expand All @@ -66,6 +69,7 @@ functions:
- http:
path: note/{noteId}
method: DELETE
cors: true
iamRoleStatements:
- Effect: "Allow"
Action:
Expand All @@ -80,6 +84,7 @@ functions:
- http:
path: notes
method: GET
cors: true
iamRoleStatements:
- Effect: "Allow"
Action:
Expand Down