Skip to content

Commit

Permalink
Merge pull request #1 from ac360/master
Browse files Browse the repository at this point in the history
add cors
  • Loading branch information
pmuens authored Oct 13, 2016
2 parents 116fc5a + 47ddad4 commit 8096b82
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.serverless
*.log
npm-debug.log
pids
*.pid
*.seed
dist
lib-cov
coverage
.grunt
.lock-wscript
node_modules
**/.idea
.DS_Store
.tmp
admin.env
.env
tmp
15 changes: 15 additions & 0 deletions handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module.exports.create = (event, context, callback) => {
todosCreate(event, (error, result) => {
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin" : "*"
},
body: JSON.stringify(result),
};

Expand All @@ -21,6 +24,9 @@ module.exports.readAll = (event, context, callback) => {
todosReadAll(event, (error, result) => {
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin" : "*"
},
body: JSON.stringify(result),
};

Expand All @@ -32,6 +38,9 @@ module.exports.readOne = (event, context, callback) => {
todosReadOne(event, (error, result) => {
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin" : "*"
},
body: JSON.stringify(result),
};

Expand All @@ -43,6 +52,9 @@ module.exports.update = (event, context, callback) => {
todosUpdate(event, (error, result) => {
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin" : "*"
},
body: JSON.stringify(result),
};

Expand All @@ -54,6 +66,9 @@ module.exports.delete = (event, context, callback) => {
todosDelete(event, (error, result) => {
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin" : "*"
},
body: JSON.stringify(result),
};

Expand Down
25 changes: 20 additions & 5 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,38 @@ functions:
create:
handler: handler.create
events:
- http: POST todos
- http:
path: todos
method: post
cors: true
readAll:
handler: handler.readAll
events:
- http: GET todos
- http:
path: todos
method: get
cors: true
readOne:
handler: handler.readOne
events:
- http: GET todos/{id}
- http:
path: todos/{id}
method: get
cors: true
update:
handler: handler.update
events:
- http: PUT todos/{id}
- http:
path: todos/{id}
method: put
cors: true
delete:
handler: handler.delete
events:
- http: DELETE todos/{id}
- http:
path: todos/{id}
method: delete
cors: true

resources:
Resources:
Expand Down

0 comments on commit 8096b82

Please sign in to comment.