This application is a Twitter-like clone using AWS Lambda and Serverless framework.
It consists of the backend
and an additional client
implemented with React.
As a user you are able to see all posts that have been created so far. This includes your own posts and all posts created by others.
You can also only have a list of your own posts.
Own posts, which are highlighted with a green color, can be edited or deleted. Once you edit a post, there's the possibility to upload an image which will be displayed together with the post.
In order to deploy the backend run the following command inside the backend
directory:
serverless deploy -v
The Client application uses Auth0 to authenticate with the service. Therefore you need to create an Auth0 account and afterwards a new application.
To have a connection to the backend, provide the apiId
and Auth0 configuration in the config file.
// client/src/config.ts
const apiId = '' // AWS apiId created by Serverless framework
const auth0Domain = '' // Domain of your Auth0 account
const auth0ClientId = '' // ClientId of your Auth0 application
To run the React client run the following command inside the client
directory. This will start a development server.
npm start
// or
yarn start
Returns all posts that have been created so far.
GET /posts
{
"items": [
{
"createdAt": string,
"text": string,
"postId": string,
"userId": string,
"title": string,
"imageUrl": string (optional)
}
]
}
Returns all posts that have been created by a specific user.
GET /users/{userId}/posts
Parameter | Type | Description |
---|---|---|
userId |
string |
Required The users ID |
{
"items": [
{
"createdAt": string,
"text": string,
"postId": string,
"userId": string,
"title": string,
"imageUrl": string (optional)
}
]
}
Create a new post.
POST /posts
{
"title": string,
"text": string
}
{
"item": {
"userId": string,
"postId": string,
"createdAt": string,
"title": string,
"text": string
}
}
Update an existing post.
PATCH /posts/{postId}
Parameter | Type | Description |
---|---|---|
postId |
string |
Required The ID of the existing post |
{
"title": string,
"text": string
}
"";
Delete an existing post.
DELETE /posts/{postId}
Parameter | Type | Description |
---|---|---|
postId |
string |
Required The ID of the existing post |
"";
Get an URL to upload an image to S3.
POST /posts/{postId}/image
Parameter | Type | Description |
---|---|---|
postId |
string |
Required The ID of the existing post |
{
"uploadUrl": string
}