Subscriptions api for spreadshare
- install
serverless
- run
sls dynamodb install
to install the local version of dynamodb for development - run
yarn dev
- import postman api script from
/docs
into Postman and hit the api's 🍻any change to the package.json file break local dynamo db installation as per the bug mentioned here. The workaround is running
sls dynamodb remove && sls dynamodb install
See the scripts section in package.json
- for
dynamodb table
deployment, seespreadshare-devops
repo - deploy using
yarn deploy:stage
for stage deployment - deploy using
yarn deploy:prod
for prod deployment - note down the api key returned by deployments. The api are private and the key is needed to be passed in
x-api-key
header for authentication. - Please also refer serverless docs for detailed deployment config params.
- setup aws lambda project with serverless and dynamodb
- create and get api
- batch get apis
- unit test
- functional test
- deployment scripts
- ci-cd
- slack integration
- handle timeout alarms
- no pagination added to list api's
Following is the list of spradshare subscription api
POST /{userId}/subscriptions/{streamId}
Fields:
- channel -
rss
oremail
. - frequency -
monthly
,weekly
ordaily
. - email - required if channel type is
email
.
Example:
POST /125/subscriptions/abc
{
"channel": "email",
"frequency": "monthly",
"email": "example@email.com"
}
200
Result:
{
"userId": "125",
"streamId": "abc",
"channel": "email",
"frequency": "monthly",
"email": "example@email.com",
"createdAt": 1532880199167,
"updatedAt": 1532880199167
}
DELETE /{userId}/subscriptions/{streamId}/{channel}
200
GET /{userId}/subscriptions/{streamId}/{channel}
{
"userId": "125",
"streamId": "abc",
"channel": "email",
"email": "some@email.com",
"frequency": "monthly",
"updatedAt": 1531045707855,
"createdAt": 1531045707855
}
200, 404
GET /{userId}/subscriptions
channel: email | rss
[
{
"userId": "125",
"streamId": "abc",
"channel": "email",
"email": "some@email.com",
"frequency": "monthly",
"updatedAt": 1531045709237,
"createdAt": 1531045707855
},
{
"userId": "125",
"streamId": "efg",
"channel": "email",
"email": "some@email.com",
"frequency": "daily",
"updatedAt": 1531045707855,
"createdAt": 1531045707855
},
{
"userId": "125",
"streamId": "xyz",
"channel": "rss",
"frequency": "weekly",
"updatedAt": 1531045708152,
"createdAt": 1531045707855
},
...
]
200, 404
GET /subscriptions/{streamId}
channel: email | rss
[
{
"userId": "129",
"streamId": "abc",
"channel": "email",
"email": "some@email.com",
"frequency": "monthly",
"updatedAt": 1531045709237,
"createdAt": 1531045707855
},
{
"userId": "121",
"streamId": "abc",
"channel": "email",
"email": "some@email.com",
"frequency": "daily",
"updatedAt": 1531045707855,
"createdAt": 1531045707855
},
{
"userId": "562",
"streamId": "abc",
"channel": "rss",
"frequency": "weekly",
"updatedAt": 1531045708152,
"createdAt": 1531045707855
},
...
]
200, 404
Error format for all enpoints is based on jsonApi standard with status
and detail
field always present.
Example:
{
"errors": [
{
"status": "422",
"detail": "First name must contain at least three characters."
}
]
}