- Copy body parser implementation from remix-storage-backup and do TDD
- How to create a Node server post Request with body?
- Try to use Zod schemas for body fields validations. Start with fields
- Try file fields
- Pass in the right way the file in the fixture. Is being read a binary application/optept-stream and it should be read as image/jpeg
- Try to create a custom z.ZodType // ZodFile.or(z.string()).optiona() it would be nice to be able to chain with the rest of Zod types. PR open for it: colinhacks/zod#1017
- FIX the mess with file extension
- To TODO test in line 152: Validate filenames are auto generated with random number if the filename already exist in the destination folder
- Validate mimetypes and return errors defined by user or default
- Clean up files if any file has errors or any field has errors.
- Finish passing existing fields to new way with supertest
- Validate file MAX size and return errors defined by user or default
- When having error on first file. Complete result with null data for the other fields
- Move schemas to each own file and use it on query
- Ensure required fields are present
- Throw FileShape on
validateFile
- Validate file MIN size and return errors defined by user or default
- Handle file input with
multiple=true
- Handle array of fields
my_field[]
return Array of strings or Enum - Make a wrapper around z.file to initialize with
FileShape
- Fix: "Type instantiation is excessively deep and possibly infinite. typescript (2589)" in Remix example app
- Fix: "No matching export in "node-modules-polyfills:fs" for import "createWriteStream" in Remix example dev server output
- Check why type of
FileShape
is not returning it as an instance. It's a pitty because it's not possible to dofile.size
and the rest. - Handle
busboy
limits errors - Improve internal Zod file. Looks zod maintainer only wants to support browser file validation. So we need a custom ZodFile implementation.
- [] Publish in npm.io 🎉
- [] Implement properly an
IFile
interface - Handle Error that is not a FileShape in Abort. Throw it again. Will be
done when implementing
@remix-storage/drive
- [] Add to parse a
baseData
argument. So this way you can pass data that is not expected in the request but is required by the zod validations and necesary to use in the code that comes after parsing
To see in action remix-storage
in a Remix app:
// nx dev [example remix app]
// Ex.:
nx dev basic
To create a new Remix app example:
npx nx g @nrwl/remix:app [NAME_OF_YOUR_EXAMPLE]
// Once the app is created edit remix config:
cd [NAME_OF_YOUR_EXAMPLE]
vim .remix.config.js
// Add this:
module.exports = {
// Rest of existing options
watchGlobs: ["../../packages/**/src/**/*.ts"]
}
Run test one of the packages
nx test:watch bodyparser
Author of zod explain his motivation for building zod An article linked on the previous link, "parse don't validate" Efficient Busboy stop processing data with p-queue Type of request with AJAX
Interesting read on Node streams and pull-streams