-
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.
- Loading branch information
1 parent
21ed855
commit 22faaac
Showing
8 changed files
with
90 additions
and
114 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,7 +1,6 @@ | ||
{ | ||
"private": true, | ||
"name": "deploy", | ||
"version": "0.1.14", | ||
"type": "module", | ||
"bin": { | ||
"deploy": "bin/deploy.js" | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,12 +1,41 @@ | ||
import { test, describe } from 'vitest'; | ||
import { test, describe, expect } from 'vitest'; | ||
import path from 'node:path'; | ||
import { createSvelteServerHandler } from '../svelte-server-handler.js'; | ||
import { createAwsProxyEvent } from './test-utils.js'; | ||
//import formDataToString from 'formdata-to-string'; | ||
|
||
describe('svelte-server-handler', () => { | ||
test('createSvelteServerHandler', async () => { | ||
const handler = await createSvelteServerHandler(path.resolve(__dirname, '../../example/svelte-app/build/server')); | ||
const rootResponse = await handler(createAwsProxyEvent('/', 'GET')); | ||
console.log(rootResponse.statusCode); | ||
const handler = createSvelteServerHandler( | ||
path.resolve(__dirname, '../../example/svelte-app/.svelte-kit/output/server') | ||
); | ||
|
||
const pages = ['/', '/about', '/sverdle', '/sverdle/how-to-play']; | ||
|
||
for (const page of pages) { | ||
const preRenderedResponse = await handler(createAwsProxyEvent(page, 'GET')); | ||
expect(preRenderedResponse.statusCode).toBe(200); | ||
expect(preRenderedResponse.headers?.['content-type']).toBe('text/html'); | ||
} | ||
|
||
//TODO: Get this working | ||
// const formData = new FormData(); | ||
// formData.append('guess', 'e'); | ||
// formData.append('guess', 'e'); | ||
// formData.append('guess', 'e'); | ||
// formData.append('guess', 'e'); | ||
|
||
// const formDataBody = await formDataToString(formData); | ||
// const [boundary] = formDataBody.split('\n'); | ||
// const formServerAction = await handler( | ||
// createAwsProxyEvent('/sverdle?/enter', 'POST', { | ||
// body: formDataBody, | ||
// headers: { | ||
// 'content-type': `multipart/form-data; boundary=${boundary}`, | ||
// 'content-length': formDataBody.length.toString(), | ||
// origin: 'https://localhost' | ||
// } | ||
// }) | ||
// ); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
# CDK Svelte App | ||
|
||
- [] Add turbo to project | ||
- [] Refactor server handler to create function | ||
- [] Use @codegenie/serverless-express to convert AWS Lambda Event to node req, res | ||
- [] Parametrize Svelte output path to get Svelte server | ||
- [] Update CDK version and use core apigw constructs | ||
- [] Add testing for server lambda | ||
- [] Check if SvelteKit Lambda Layer is needed or not, I assume it is not needed | ||
- [] Proxy all methods | ||
- [] PUT | ||
- [] PATCH | ||
- [] DELETE | ||
- [x] Refactor server handler to create function | ||
- [x] Use @codegenie/serverless-express to convert AWS Lambda Event to node req, res | ||
- [x] Parametrize Svelte output path to get Svelte server | ||
- [x] Update CDK version and use core apigw constructs | ||
- [x] Add testing for server lambda | ||
- [x] Check if SvelteKit Lambda Layer is needed or not, I assume it is not needed | ||
- [] Check if check for no-cache control header makes sense, some of those 300 are permanent and caching makes sense in this case | ||
- [] Figure TS dev import vs Prd import | ||
- [] Remove the need for package.json magic for esm support in lambda | ||
- [] Check the use if a Lambda Layer for the resulting svelte server code | ||
- [x] Figure TS dev import vs Prd import | ||
- [x] Remove the need for package.json magic for esm support in lambda | ||
- [x] Check the use if a Lambda Layer for the resulting svelte server code |