diff --git a/client/package.json b/client/package.json index 117170c..25a1b90 100644 --- a/client/package.json +++ b/client/package.json @@ -5,7 +5,7 @@ "description": "tech tools hosted on cloudflare worker", "main": "index.js", "scripts": { - "build": "tsc && webpack", + "build": "webpack", "deploy": "wrangler deploy src/index.js", "dev": "webpack-dev-server --config webpack-dev.config.js --open", "prepare": "husky", @@ -28,7 +28,6 @@ "@babel/core": "^7.24.8", "@babel/preset-env": "^7.24.8", "@babel/preset-react": "^7.24.7", - "@babel/preset-typescript": "^7.24.7", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@types/react-router-dom": "^5.3.3", diff --git a/client/src/pages/Home.tsx b/client/src/pages/Home.tsx index 701f95f..6ef5431 100644 --- a/client/src/pages/Home.tsx +++ b/client/src/pages/Home.tsx @@ -12,14 +12,14 @@ const Home = () => {

This is a basic React page deployed on Cloudflare Workers.


-
Your name: { tester }
+
Your name: {tester}
-

Count: { count }

+

Count: {count}


diff --git a/client/src/routers/encoding/base64/router.ts b/client/src/routers/encoding/base64/router.ts index ba6949c..86d2325 100644 --- a/client/src/routers/encoding/base64/router.ts +++ b/client/src/routers/encoding/base64/router.ts @@ -1,26 +1,26 @@ import { Buffer } from 'buffer'; -export const base64Handler = async ({ params }) => { - // Decode text like "Hello%20world" into "Hello world" - let input = decodeURIComponent(params.text) +export const base64Handler = async ({ params }: any) => { + // Decode text like "Hello%20world" into "Hello world" + let input = decodeURIComponent(params.text) - // Construct a buffer from our input - let buffer = Buffer.from(input, "utf8") + // Construct a buffer from our input + let buffer = Buffer.from(input, "utf8") - // Serialise the buffer into a base64 string - let base64 = buffer.toString("base64") + // Serialise the buffer into a base64 string + let base64 = buffer.toString("base64") - const backendApi = 'https://6wkf624dt4.execute-api.us-east-1.amazonaws.com/prod/'; - const response = await fetch(backendApi) - const data = await response.json() + const backendApi = 'https://6wkf624dt4.execute-api.us-east-1.amazonaws.com/prod/'; + const response = await fetch(backendApi) + const data = await response.json() - // Return the HTML with the string to the client - return new Response(` + // Return the HTML with the string to the client + return new Response(`

Base64 encoding: ${base64}

${JSON.stringify(data, null, 2)}

`, { - headers: { - "Content-Type": "text/html" - } - }) + headers: { + "Content-Type": "text/html" + } + }) }; \ No newline at end of file diff --git a/client/src/routers/handler.ts b/client/src/routers/handler.ts index 5235c42..d32bc56 100644 --- a/client/src/routers/handler.ts +++ b/client/src/routers/handler.ts @@ -9,7 +9,7 @@ import { getAssetFromKV } from "@cloudflare/kv-asset-handler"; * @param {Router} router - The router object responsible for handling non-static asset requests. * @returns {Response} A Response object containing the requested asset or routed content. */ -export const routesAndAssetsHandler = async (event, router) => { +export const routesAndAssetsHandler = async (event: any, router: any): Promise => { // Extract the request from the event const request = event.request; diff --git a/client/src/routers/post/router.ts b/client/src/routers/post/router.ts index 52cc4bd..53a7eed 100644 --- a/client/src/routers/post/router.ts +++ b/client/src/routers/post/router.ts @@ -7,24 +7,24 @@ Try the below curl command to send JSON: $ curl -X POST -H "Content-Type: application/json" -d '{"abc": "def"}' */ -export const postHandler = async request => { - // Create a base object with some fields. - let fields = { - "asn": request.cf.asn, - "colo": request.cf.colo - } +export const postHandler = async (request: any) => { + // Create a base object with some fields. + let fields: any = { + "asn": request.cf.asn, + "colo": request.cf.colo + } - // If the POST data is JSON then attach it to our response. - if (request.headers.get("Content-Type") === "application/json") { - fields["json"] = await request.json() - } + // If the POST data is JSON then attach it to our response. + if (request.headers.get("Content-Type") === "application/json") { + fields["json"] = await request.json() + } - // Serialise the JSON to a string. - const returnData = JSON.stringify(fields, null, 2); + // Serialise the JSON to a string. + const returnData = JSON.stringify(fields, null, 2); - return new Response(returnData, { - headers: { - "Content-Type": "application/json" - } - }) + return new Response(returnData, { + headers: { + "Content-Type": "application/json" + } + }) }; \ No newline at end of file diff --git a/client/src/routers/root/router.ts b/client/src/routers/root/router.ts index bddfb5e..1fc4a10 100644 --- a/client/src/routers/root/router.ts +++ b/client/src/routers/root/router.ts @@ -4,7 +4,7 @@ import indexHTML from '../../../dist/index.html'; * Handles requests to serve the index.html file. * Uses the indexHTML imported from the public directory. */ -export const rootHandler = async (request) => { +export const rootHandler = async (request: any) => { return new Response(indexHTML, { headers: { 'Content-Type': 'text/html', diff --git a/client/tsconfig.json b/client/tsconfig.json index 4c546dd..e5771ec 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -9,22 +9,17 @@ "allowJs": true, "skipLibCheck": true, "strict": true, - "noImplicitAny": false, + "noImplicitAny": true, "noEmit": false, "outDir": "dist", "esModuleInterop": true, - "module": "commonjs", "target": "esnext", + "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, - "plugins": [ - { - "name": "next" - } - ], "paths": { "@/*": [ "./src/*" diff --git a/client/webpack.config.js b/client/webpack.config.js index 9534300..e80ea30 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -17,14 +17,19 @@ module.exports = { module: { rules: [ { - test: /\.(ts|tsx)$/, + test: /\.ts(x?)$/, exclude: /node_modules/, - use: { - loader: 'babel-loader', - options: { - configFile: './.babelrc', + use: [ + { + loader: 'babel-loader', + options: { + configFile: './.babelrc', + }, }, - }, + { + loader: 'ts-loader' + } + ] }, { test: /\.[s]?css$/,