MCPcopy
hub / github.com/FoalTS/foal / createAppWithHook

Function createAppWithHook

packages/storage/src/parse-and-validate-files.hook.spec.ts:49–60  ·  view source on GitHub ↗
(schema: { files: FilesSchema, fields?: FieldsSchema }, actual: Actual)

Source from the content-addressed store, hash-verified

47 // Note: Unfortunatly, in order to have a multipart request object,
48 // we need to create an Express server to test the hook.
49 function createAppWithHook(schema: { files: FilesSchema, fields?: FieldsSchema }, actual: Actual): Promise<any> {
50 @ParseAndValidateFiles(schema.files, schema.fields)
51 class AppController {
52 @Post('/')
53 index(ctx: Context) {
54 actual.body = ctx.request.body;
55 actual.files = ctx.files;
56 return new HttpResponseOK();
57 }
58 }
59 return createApp(AppController);
60 }
61
62 it('should return an HttpResponseBadRequest if the request is not of type multipart/form-data.', async () => {
63 const app = await createAppWithHook({

Calls 1

createAppFunction · 0.90

Tested by

no test coverage detected