Skip to content

🎥 Make videos programmatically with React

streamed response

Jonny Burger59863e37940e
diff --git a/packages/lambda/src/shared/return-values.ts b/packages/lambda/src/shared/return-values.ts
index 7309323ff9..902d0052b3 100644
--- a/packages/lambda/src/shared/return-values.ts
+++ b/packages/lambda/src/shared/return-values.ts
@@ -24,9 +24,3 @@ export interface LambdaReturnValues {
[LambdaRoutines.still]: ReturnType<typeof stillHandler>;
[LambdaRoutines.compositions]: ReturnType<typeof compositionsHandler>;
}
-
-export type StreamedResponse = {
- statusCode: number;
- headers: Record<string, string>;
- body: string;
-};
diff --git a/packages/lambda/src/test/integration/handlers.test.ts b/packages/lambda/src/test/integration/handlers.test.ts
index 5ffa78887b..90fc3f9657 100644
--- a/packages/lambda/src/test/integration/handlers.test.ts
+++ b/packages/lambda/src/test/integration/handlers.test.ts
@@ -12,11 +12,5 @@ test('Call function locally', async () => {
getRemainingTimeInMillis: () => 1000,
}
)
- ).toEqual({
- body: JSON.stringify({version: VERSION}),
- headers: {
- 'content-type': 'application/json',
- },
- statusCode: 200,
- });
+ ).toEqual(JSON.stringify({version: VERSION}));
});
diff --git a/packages/lambda/src/test/integration/renders/gif.test.ts b/packages/lambda/src/test/integration/renders/gif.test.ts
index d433afd832..3c764e1d8b 100644
--- a/packages/lambda/src/test/integration/renders/gif.test.ts
+++ b/packages/lambda/src/test/integration/renders/gif.test.ts
@@ -5,10 +5,7 @@ import {afterAll, beforeAll, expect, test} from 'vitest';
import {LambdaRoutines} from '../../../defaults';
import {handler} from '../../../functions';
import {lambdaReadFile} from '../../../functions/helpers/io';
-import type {
- LambdaReturnValues,
- StreamedResponse,
-} from '../../../shared/return-values';
+import type {LambdaReturnValues} from '../../../shared/return-values';
import {disableLogs, enableLogs} from '../../disable-logs';
const extraContext = {
@@ -31,7 +28,7 @@ afterAll(async () => {
test('Should make a distributed GIF', async () => {
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '2048';
- const res = (await handler(
+ const res = await handler(
{
type: LambdaRoutines.start,
serveUrl:
@@ -75,13 +72,13 @@ test('Should make a distributed GIF', async () => {
audioCodec: null,
},
extraContext
- )) as StreamedResponse;
+ );
- const startRes = JSON.parse(res.body) as Await<
+ const startRes = JSON.parse(res) as Await<
LambdaReturnValues[LambdaRoutines.start]
>;
- const progress = (await handler(
+ const progress = await handler(
{
type: LambdaRoutines.status,
bucketName: startRes.bucketName,
@@ -89,7 +86,7 @@ test('Should make a distributed GIF', async () => {
version: VERSION,
},
extraContext
- )) as StreamedResponse;
+ );
const parsed = JSON.parse(progress.body) as Await<
LambdaReturnValues[LambdaRoutines.status]
diff --git a/packages/lambda/src/test/integration/renders/other-bucket.test.ts b/packages/lambda/src/test/integration/renders/other-bucket.test.ts
index 134c87a95a..31246981a6 100644
--- a/packages/lambda/src/test/integration/renders/other-bucket.test.ts
+++ b/packages/lambda/src/test/integration/renders/other-bucket.test.ts
@@ -4,10 +4,7 @@ import {afterAll, beforeAll, expect, test} from 'vitest';
import {LambdaRoutines} from '../../../defaults';
import {handler} from '../../../functions';
import {lambdaReadFile} from '../../../functions/helpers/io';
-import type {
- LambdaReturnValues,
- StreamedResponse,
-} from '../../../shared/return-values';
+import type {LambdaReturnValues} from '../../../shared/return-values';
import {disableLogs, enableLogs} from '../../disable-logs';
const extraContext = {
@@ -30,7 +27,7 @@ afterAll(async () => {
test('Should be able to render to another bucket', async () => {
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '2048';
- const res = (await handler(
+ const res = await handler(
{
type: LambdaRoutines.start,
serveUrl:
@@ -78,12 +75,12 @@ test('Should be able to render to another bucket', async () => {
audioCodec: null,
},
extraContext
- )) as StreamedResponse;
- const startRes = JSON.parse(res.body) as Await<
+ );
+ const startRes = JSON.parse(res) as Await<
LambdaReturnValues[LambdaRoutines.start]
>;
- const progress = (await handler(
+ const progress = await handler(
{
type: LambdaRoutines.status,
bucketName: startRes.bucketName,
@@ -91,7 +88,7 @@ test('Should be able to render to another bucket', async () => {
version: VERSION,
},
extraContext
- )) as StreamedResponse;
+ );
const parsed = JSON.parse(progress.body) as Await<
LambdaReturnValues[LambdaRoutines.status]
diff --git a/packages/lambda/src/test/integration/renders/silent-audio.test.ts b/packages/lambda/src/test/integration/renders/silent-audio.test.ts
index 9eaf5585c9..77073c3e88 100644
--- a/packages/lambda/src/test/integration/renders/silent-audio.test.ts
+++ b/packages/lambda/src/test/integration/renders/silent-audio.test.ts
@@ -4,10 +4,7 @@ import {afterAll, beforeAll, expect, test} from 'vitest';
import {LambdaRoutines} from '../../../defaults';
import {handler} from '../../../functions';
import {lambdaReadFile} from '../../../functions/helpers/io';
-import type {
- LambdaReturnValues,
- StreamedResponse,
-} from '../../../shared/return-values';
+import type {LambdaReturnValues} from '../../../shared/return-values';
import {enableLogs} from '../../disable-logs';
const extraContext = {
@@ -30,7 +27,7 @@ afterAll(async () => {
test('Should add silent audio if there is no audio', async () => {
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '2048';
- const res = (await handler(
+ const res = await handler(
{
type: LambdaRoutines.start,
serveUrl:
@@ -75,12 +72,12 @@ test('Should add silent audio if there is no audio', async () => {
audioCodec: null,
},
extraContext
- )) as StreamedResponse;
- const startRes = JSON.parse(res.body) as Await<
+ );
+ const startRes = JSON.parse(res) as Await<
LambdaReturnValues[LambdaRoutines.start]
>;
- const progress = (await handler(
+ const progress = await handler(
{
type: LambdaRoutines.status,
bucketName: startRes.bucketName,
@@ -88,7 +85,7 @@ test('Should add silent audio if there is no audio', async () => {
version: VERSION,
},
extraContext
- )) as StreamedResponse;
+ );
const parsed = JSON.parse(progress.body) as Await<
LambdaReturnValues[LambdaRoutines.status]
diff --git a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts b/packages/lambda/src/test/integration/renders/transparent-webm.test.ts
index 0082163837..8b259eb8e2 100644
--- a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts
+++ b/packages/lambda/src/test/integration/renders/transparent-webm.test.ts
@@ -8,10 +8,7 @@ import {deleteRender} from '../../../api/delete-render';
import {LambdaRoutines, rendersPrefix} from '../../../defaults';
import {handler} from '../../../functions';
import {lambdaLs, lambdaReadFile} from '../../../functions/helpers/io';
-import type {
- LambdaReturnValues,
- StreamedResponse,
-} from '../../../shared/return-values';
+import type {LambdaReturnValues} from '../../../shared/return-values';
import {disableLogs, enableLogs} from '../../disable-logs';
const extraContext = {
@@ -33,7 +30,7 @@ afterAll(async () => {
test('Should make a transparent video', async () => {
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '2048';
- const res = (await handler(
+ const res = await handler(
{
type: LambdaRoutines.start,
serveUrl:
@@ -78,12 +75,12 @@ test('Should make a transparent video', async () => {
audioCodec: null,
},
extraContext
- )) as StreamedResponse;
- const startRes = JSON.parse(res.body) as Await<
+ );
+ const startRes = JSON.parse(res) as Await<
LambdaReturnValues[LambdaRoutines.start]
>;
- const progress = (await handler(
+ const progress = await handler(
{
type: LambdaRoutines.status,
bucketName: startRes.bucketName,
@@ -91,7 +88,7 @@ test('Should make a transparent video', async () => {
version: VERSION,
},
extraContext
- )) as StreamedResponse;
+ );
const parsed = JSON.parse(progress.body) as Await<
LambdaReturnValues[LambdaRoutines.status]
diff --git a/packages/lambda/src/test/integration/webhooks.test.ts b/packages/lambda/src/test/integration/webhooks.test.ts
index 5db259a4bb..c8bd306bf3 100644
--- a/packages/lambda/src/test/integration/webhooks.test.ts
+++ b/packages/lambda/src/test/integration/webhooks.test.ts
@@ -13,10 +13,7 @@ import {
import {LambdaRoutines} from '../../defaults';
import {handler} from '../../functions';
import {mockableHttpClients} from '../../shared/invoke-webhook';
-import type {
- LambdaReturnValues,
- StreamedResponse,
-} from '../../shared/return-values';
+import type {LambdaReturnValues} from '../../shared/return-values';
import {disableLogs, enableLogs} from '../disable-logs';
const extraContext = {
@@ -115,9 +112,9 @@ describe('Webhooks', () => {
},
extraContext
);
- const startRes = res as StreamedResponse;
+ const startRes = res;
- const parsed = JSON.parse(startRes.body) as Await<
+ const parsed = JSON.parse(startRes) as Await<
LambdaReturnValues[LambdaRoutines.start]
>;
diff --git a/packages/lambda/src/test/unit/handlers.test.ts b/packages/lambda/src/test/unit/handlers.test.ts
index 2ff81916d4..4003aeef5b 100644
--- a/packages/lambda/src/test/unit/handlers.test.ts
+++ b/packages/lambda/src/test/unit/handlers.test.ts
@@ -2,10 +2,7 @@ import {expect, test} from 'vitest';
import {handler} from '../../functions/index';
import type {Await} from '../../shared/await';
import {LambdaRoutines} from '../../shared/constants';
-import type {
- LambdaReturnValues,
- StreamedResponse,
-} from '../../shared/return-values';
+import type {LambdaReturnValues} from '../../shared/return-values';
test('Info handler should return version', async () => {
const response = await handler(
@@ -15,7 +12,7 @@ test('Info handler should return version', async () => {
{invokedFunctionArn: '::::::', getRemainingTimeInMillis: () => 1000}
);
- const res = response as StreamedResponse;
+ const res = response;
const parsed = JSON.parse(res.body) as Await<
LambdaReturnValues[LambdaRoutines.info]
>;