-
Notifications
You must be signed in to change notification settings - Fork 0
Added APIs for product #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sujit-epam
wants to merge
2
commits into
main
Choose a base branch
from
task3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #### What was done? | ||
|
|
||
| - Service is done, but FE is not working | ||
|
|
||
| #### Link to Product Service API - | ||
| - All Products: https://9hm5ojtl48.execute-api.us-east-1.amazonaws.com/dev/products | ||
| - Specific Products: https://9hm5ojtl48.execute-api.us-east-1.amazonaws.com/dev/products/2 | ||
|
|
||
| #### Link to FE PR - ... | ||
| https://github.com/sujit-epam/shop-react-redux-cloudfront/pull/2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "jscc-aws-backend", | ||
| "version": "1.0.0", | ||
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/sujit-epam/jscc-aws-backend.git" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/sujit-epam/jscc-aws-backend/issues" | ||
| }, | ||
| "homepage": "https://github.com/sujit-epam/jscc-aws-backend#readme" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # package directories | ||
| node_modules | ||
| jspm_packages | ||
|
|
||
| # Serverless directories | ||
| .serverless | ||
|
|
||
| # esbuild directories | ||
| .esbuild |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| lts/fermium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # Serverless - AWS Node.js Typescript | ||
|
|
||
| This project has been generated using the `aws-nodejs-typescript` template from the [Serverless framework](https://www.serverless.com/). | ||
|
|
||
| For detailed instructions, please refer to the [documentation](https://www.serverless.com/framework/docs/providers/aws/). | ||
|
|
||
| ## Installation/deployment instructions | ||
|
|
||
| Depending on your preferred package manager, follow the instructions below to deploy your project. | ||
|
|
||
| > **Requirements**: NodeJS `lts/fermium (v.14.15.0)`. If you're using [nvm](https://github.com/nvm-sh/nvm), run `nvm use` to ensure you're using the same Node version in local and in your lambda's runtime. | ||
|
|
||
| ### Using NPM | ||
|
|
||
| - Run `npm i` to install the project dependencies | ||
| - Run `npx sls deploy` to deploy this stack to AWS | ||
|
|
||
| ### Using Yarn | ||
|
|
||
| - Run `yarn` to install the project dependencies | ||
| - Run `yarn sls deploy` to deploy this stack to AWS | ||
|
|
||
| ## Test your service | ||
|
|
||
| This template contains a single lambda function triggered by an HTTP request made on the provisioned API Gateway REST API `/hello` route with `POST` method. The request body must be provided as `application/json`. The body structure is tested by API Gateway against `src/functions/hello/schema.ts` JSON-Schema definition: it must contain the `name` property. | ||
|
|
||
| - requesting any other path than `/hello` with any other method than `POST` will result in API Gateway returning a `403` HTTP error code | ||
| - sending a `POST` request to `/hello` with a payload **not** containing a string property named `name` will result in API Gateway returning a `400` HTTP error code | ||
| - sending a `POST` request to `/hello` with a payload containing a string property named `name` will result in API Gateway returning a `200` HTTP status code with a message saluting the provided name and the detailed event processed by the lambda | ||
|
|
||
| > :warning: As is, this template, once deployed, opens a **public** endpoint within your AWS account resources. Anybody with the URL can actively execute the API Gateway endpoint and the corresponding lambda. You should protect this endpoint with the authentication method of your choice. | ||
|
|
||
| ### Locally | ||
|
|
||
| In order to test the hello function locally, run the following command: | ||
|
|
||
| - `npx sls invoke local -f hello --path src/functions/hello/mock.json` if you're using NPM | ||
| - `yarn sls invoke local -f hello --path src/functions/hello/mock.json` if you're using Yarn | ||
|
|
||
| Check the [sls invoke local command documentation](https://www.serverless.com/framework/docs/providers/aws/cli-reference/invoke-local/) for more information. | ||
|
|
||
| ### Remotely | ||
|
|
||
| Copy and replace your `url` - found in Serverless `deploy` command output - and `name` parameter in the following `curl` command in your terminal or in Postman to test your newly deployed application. | ||
|
|
||
| ``` | ||
| curl --location --request POST 'https://myApiEndpoint/dev/hello' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --data-raw '{ | ||
| "name": "Frederic" | ||
| }' | ||
| ``` | ||
|
|
||
| ## Template features | ||
|
|
||
| ### Project structure | ||
|
|
||
| The project code base is mainly located within the `src` folder. This folder is divided in: | ||
|
|
||
| - `functions` - containing code base and configuration for your lambda functions | ||
| - `libs` - containing shared code base between your lambdas | ||
|
|
||
| ``` | ||
| . | ||
| ├── src | ||
| │ ├── functions # Lambda configuration and source code folder | ||
| │ │ ├── hello | ||
| │ │ │ ├── handler.ts # `Hello` lambda source code | ||
| │ │ │ ├── index.ts # `Hello` lambda Serverless configuration | ||
| │ │ │ ├── mock.json # `Hello` lambda input parameter, if any, for local invocation | ||
| │ │ │ └── schema.ts # `Hello` lambda input event JSON-Schema | ||
| │ │ │ | ||
| │ │ └── index.ts # Import/export of all lambda configurations | ||
| │ │ | ||
| │ └── libs # Lambda shared code | ||
| │ └── apiGateway.ts # API Gateway specific helpers | ||
| │ └── handlerResolver.ts # Sharable library for resolving lambda handlers | ||
| │ └── lambda.ts # Lambda middleware | ||
| │ | ||
| ├── package.json | ||
| ├── serverless.ts # Serverless service file | ||
| ├── tsconfig.json # Typescript compiler configuration | ||
| ├── tsconfig.paths.json # Typescript paths | ||
| └── webpack.config.js # Webpack configuration | ||
| ``` | ||
|
|
||
| ### 3rd party libraries | ||
|
|
||
| - [json-schema-to-ts](https://github.com/ThomasAribart/json-schema-to-ts) - uses JSON-Schema definitions used by API Gateway for HTTP request validation to statically generate TypeScript types in your lambda's handler code base | ||
| - [middy](https://github.com/middyjs/middy) - middleware engine for Node.Js lambda. This template uses [http-json-body-parser](https://github.com/middyjs/middy/tree/master/packages/http-json-body-parser) to convert API Gateway `event.body` property, originally passed as a stringified JSON, to its corresponding parsed object | ||
| - [@serverless/typescript](https://github.com/serverless/typescript) - provides up-to-date TypeScript definitions for your `serverless.ts` service file | ||
|
|
||
| ### Advanced usage | ||
|
|
||
| Any tsconfig.json can be used, but if you do, set the environment variable `TS_NODE_CONFIG` for building the application, eg `TS_NODE_CONFIG=./tsconfig.app.json npx serverless webpack` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid casting to any if you remove unrelevant schema import and usage.