@jahidul.activity/webpack-demo
v1.0.0
Published
## Cheat sheet
Readme
MessageAPI Definiton and Code Autogenerator
Cheat sheet
npm run build-devcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform the jest unit tests
Introduction
This folder defines a simple website that will call the message api defined and autogenerated in the api_definition subdirectory
of this project.
Getting Started
Prerequisites
To get started with this api, you will need to have the following items setup:
- Software dependencies installed
- The current long term support version of node (18.12.0)
To fully set up your local host to interact with your deployed CDK stack, you'll need to do the following
Build and deploy your cdk stack (note: that the website that's deployed won't work yet but that's okay)
Get the api endpoint from the cdk deploy output that looks a bit like this
Outputs: CloudFormationStack.MessageServerAPIEndpoint92232D23 = https://####.execute-api.us-west-2.amazonaws.com/dev/Take api
https://####.execute-api.us-west-2.amazonaws.com/dev/value and paste it in the filewebsite/dist/config.jsonfile under the"apiEndpoint"option.
Development Process
To locally build the application you'll need to run the following commands with the project subdirectory that contains this readme file.
npm install # Install dependencies if not done so already
npm build-dev # rebuild autogenerated codeLocal Testing
To test this code with an observable website locally you'll need a way to run a local server within the website/dist
folder. This can be done a number of ways, but I use the VSCode extension LivePreview which will host a mini-server
within your local env.
To compile changes to the typescript code as you go, run the command npm run watch which will poll every
one second to see if any of the sources have changed. If any sources change, it'll regenerate the code.
Adding New API Call Support
Any autogenerated content will be included within the src/.generated-sources/, with the openapi content stored under openapi.
To pick up any changes to the api you'll need to re-run the api autogeneration within the api_definition folder. Once that is
done the autogenerated api will include any new api calls.
