NickRoach / blackheath-wind-meter

0 stars 0 forks source link

Convert frontend to typescript #101

Open NickRoach opened 1 month ago

NickRoach commented 1 month ago

Because we're going to need to do some more precise requests to the backend lambda when we migrate to use a database we should make sure our data types are right.

NickRoach commented 1 month ago

@burtscriptor this will probably be an easier place to start than the typescript conversion for the lambda because I don't yet know a way of testing the lambda locally. There is an example of the kind of thing I'm hoping to achieve here https://github.com/NickRoach/game-of-life/tree/main

burtscriptor commented 1 month ago

I'm reviewing it now. I've pulled the develop branch that you set up.

  1. Do I need to edit the tsconfig.json file to achieve that?
  2. Should I simply change script.js in the frontend directory to script.ts? Then I'll need to add types to script.ts.
  3. Edit the deploy.yml file.
NickRoach commented 1 month ago

Good questions! I don't have a clear idea in my own mind about exactly what needs to be done, but:

  1. Just make the output directory "build" instead of "dist"
  2. Yes, just rename it, then start dealing with whatever problems are highlighted by your IDE or by the typescript transpiler
  3. Yes. Rather than simply copy the files to the S3 bucket as is done now, there will need to be a transpilation step first. The command is simply "tsc"

The target outcome of this is that you can navigate to the frontEnd directory and type "npm start", which will do "tsc --watch" to transpile the ts file to js, and then open index.html in your browser. This means you'll need a package.json in the frontEnd directory

Sorry I know this is going to be hard for you, but see what you can figure out. I'm not able to help you too much at the moment because I'm getting ready to go up Zodiac

NickRoach commented 1 month ago

Oh, and you'll need to change the API endpoint in the script code. You can get it from the network calls from http://mtblackheathwind-test.s3-website-ap-southeast-2.amazonaws.com/ (right click, inspect, Network) It ends in /blackheath. Don't commit that change though. I know it's janky to have to paste that in for development. I'll fix it in about two weeks