-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Marjan Kalanaki <15894063+marjisound@users.noreply.github.com>
- Loading branch information
1 parent
723e989
commit 1adc2f6
Showing
5 changed files
with
80 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# dependencies | ||
node_modules/ | ||
|
||
./dist | ||
./target | ||
dist/ | ||
target/ |
This file contains 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,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<!-- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> --> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="Guardian Transcription Service" | ||
/> | ||
<!-- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> --> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> --> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>Transcribe</title> | ||
<!-- <script src="https://accounts.google.com/gsi/client" async></script> --> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"> | ||
<p>Hello world</p> | ||
</div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
This file contains 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 |
---|---|---|
@@ -1,73 +1,60 @@ | ||
// import { | ||
// APIGatewayProxyEvent, | ||
// APIGatewayEventRequestContext, | ||
// APIGatewayProxyCallback, | ||
// APIGatewayProxyStructuredResultV2, | ||
// } from 'aws-lambda'; | ||
import express from 'express'; | ||
import asyncHandler from "express-async-handler"; | ||
import serverlessExpress from "@codegenie/serverless-express"; | ||
import asyncHandler from 'express-async-handler'; | ||
import serverlessExpress from '@codegenie/serverless-express'; | ||
import bodyParser from 'body-parser'; | ||
|
||
// export const handler = ( | ||
// event: APIGatewayProxyEvent, | ||
// context: APIGatewayEventRequestContext, | ||
// callback: APIGatewayProxyCallback, | ||
// ): Promise<APIGatewayProxyStructuredResultV2> => { | ||
// const message = 'Hello World!'; | ||
// console.log(message); | ||
// console.log(event.body, context.accountId, callback.name); | ||
// const result = { | ||
// "isBase64Encoded": true, | ||
// "statusCode": 200, | ||
// "headers": { }, | ||
// "body": message | ||
// } | ||
// return Promise.resolve(result); | ||
// }; | ||
import path from 'path'; | ||
|
||
const getApp = async () => { | ||
const app = express(); | ||
const apiRouter = express.Router(); | ||
|
||
app.use(bodyParser.json({ limit: "40mb" })); | ||
app.use(bodyParser.json({ limit: '40mb' })); | ||
|
||
apiRouter.get( | ||
"/healthcheck", | ||
'/healthcheck', | ||
asyncHandler(async (req, res) => { | ||
res.send("It lives!") | ||
}) | ||
res.send('It lives!'); | ||
}), | ||
); | ||
|
||
app.use("/api", apiRouter); | ||
app.use('/api', apiRouter); | ||
|
||
if (process.env['AWS_EXECUTION_ENV'] !== undefined) { | ||
app.use(express.static('frontend')); | ||
app.get('/*', (req, res) => { | ||
res.sendFile(path.resolve(__dirname, 'frontend', 'index.html')); | ||
}); | ||
} | ||
|
||
return app; | ||
} | ||
}; | ||
|
||
let api; | ||
if (process.env["AWS_EXECUTION_ENV"] !== undefined){ | ||
console.log("Running on lambda") | ||
if (process.env['AWS_EXECUTION_ENV'] !== undefined) { | ||
console.log('Running on lambda'); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
let serverlessExpressHandler: any | ||
const serverlessHandler = getApp().then((app) => (serverlessExpressHandler = serverlessExpress({ app }).handler)); | ||
let serverlessExpressHandler: any; | ||
const serverlessHandler = getApp().then( | ||
(app) => (serverlessExpressHandler = serverlessExpress({ app }).handler), | ||
); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
api = async (event: any, context: any) => { | ||
if (!serverlessExpressHandler) { | ||
await serverlessHandler; | ||
} | ||
return serverlessExpressHandler(event, context) | ||
} | ||
return serverlessExpressHandler(event, context); | ||
}; | ||
} else { | ||
console.log("running locally"); | ||
console.log('running locally'); | ||
// Running locally. Start Express ourselves | ||
const port = 9103 | ||
const port = 9103; | ||
getApp().then((app) => { | ||
app.listen(port, () => { | ||
console.log(`Server now listening on port: ${port}`) | ||
}) | ||
}) | ||
console.log(`Server now listening on port: ${port}`); | ||
}); | ||
}); | ||
} | ||
|
||
export { api } | ||
export { api }; |
This file contains 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 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