-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
125 lines (109 loc) · 2.9 KB
/
serverless.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
service: ecommerce-api
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, 'dev'}
profile: chris
region: us-east-1
memorySize: 128
#Setting variables for CI/CD pipeline.
environment:
DATABASE_URL: ${env:DATABASE_URL}
REDIS_HOST: ${env:REDIS_HOST}
REDIS_PASS: ${env:REDIS_PASS}
REDIS_PORT: ${env:REDIS_PORT}
REDIS_ACTIVE: ${env:REDIS_ACTIVE}
REDIS_TTL: ${env:REDIS_TTL}
JWT_KEY: ${env:JWT_KEY}
JWT_EXPIRES: ${env:JWT_EXPIRES}
plugins:
- serverless-offline
- serverless-dotenv-plugin
package:
patterns:
- '!node_modules/.prisma/client/query-engine-*'
- 'node_modules/.prisma/client/query-engine-rhel-*'
functions:
auth:
handler: src/controllers/authController.auth
getUsers:
handler: src/controllers/userController.getUsers
description: Get all users
events:
- http:
path: /users
method: GET
cors: true
authorizer: auth
getUserById:
handler: src/controllers/userController.getUserById
description: Get user by id
events:
- http:
path: /users/{id}
method: GET
cors: true
createUser:
handler: src/controllers/userController.createUser
description: Create users
events:
- http:
path: /users
method: POST
cors: true
login:
handler: src/controllers/userController.login
description: Login
events:
- http:
path: /login
method: POST
cors: true
updateUser:
handler: src/controllers/userController.updateUser
description: Update User
events:
- http:
path: /users/{id}
method: PUT
cors: true
authorizer: auth
deleteUser:
handler: src/controllers/userController.deleteUser
description: Delete User
events:
- http:
path: /users/{id}
method: DELETE
cors: true
authorizer: auth
getProducts:
handler: src/controllers/productController.getProducts
description: Get Products
events:
- http:
path: /products
method: GET
cors: true
resources:
Resources:
GatewayResponse:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: EXPIRED_TOKEN
RestApiId:
Ref: 'ApiGatewayRestApi'
StatusCode: '401'
AuthFailureGatewayResponse:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: UNAUTHORIZED
RestApiId:
Ref: 'ApiGatewayRestApi'
StatusCode: '401'