Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(uploads): Reorganise, change uploads package to storage #11411

Merged
merged 11 commits into from
Sep 2, 2024

Conversation

dac09
Copy link
Contributor

@dac09 dac09 commented Sep 2, 2024

This PR does the following:

  • renames @redwoodjs/uploads -> @redwoodjs/storage
  • Renames processors -> savers

They now look like this:

  // reads much nicer ✅
  const processedInput = await saveFiles.forProfile(input)

  // avatar is a File becomes a string
  // processedInput.avatar =
  // '/basePath/uploads/profile-avatar-01J6ACDPWAER8B1SAXPKQK5YA1.png'

  const profile = await db.profile.update({
    data: processedInput,
    where: { id },
  })

even though when you export it, it looks weird

// api/src/lib/uploads.ts
const { saveFiles, storagePrismaExtension } = setupStorage({
  uploadsConfig,
  storageAdapter: fsStorage,
  urlSigner,
})

export { saveFiles, storagePrismaExtension }

The naming convention is:
for<Model> - takes inputs in the shape of a Prisma data for that model but with Files instead of strings. The files get saved to storage, and a key/path is replaced in the value.

inList - does the same, but only takes an array of File, and returns an array of stored paths/keys

@dac09 dac09 added this to the next-release milestone Sep 2, 2024
@dac09 dac09 self-assigned this Sep 2, 2024
@dac09 dac09 added the release:chore This PR is a chore (means nothing for users) label Sep 2, 2024
@dac09 dac09 changed the title choreuploads): Reorganise, change uploads package to storage chore(uploads): Reorganise, change uploads package to storage Sep 2, 2024
@dac09 dac09 merged commit f9978fc into redwoodjs:main Sep 2, 2024
50 checks passed
@dac09 dac09 deleted the chore/upload-pkg-becomes-storage branch September 2, 2024 14:23
dac09 added a commit to dac09/redwood that referenced this pull request Sep 2, 2024
…ads-storage

* 'main' of github.com:redwoodjs/redwood: (32 commits)
  chore(uploads): Reorganise, change uploads package to storage (redwoodjs#11411)
  fix(cli-helpers): Don't add spaces around `=` for env vars (redwoodjs#11414)
  feat(uploads): Increase default fastify body limit to 100MB (redwoodjs#11412)
  chore: Rebuild fixture (redwoodjs#11413)
  chore(rsc): Refactor: Rename RscFetcher -> RscRoutes (redwoodjs#11409)
  chore(test-project): Update postcss to 8.4.42 (redwoodjs#11408)
  chore(rsc): Rename rscFetch to rscFetchRoutes and hardcode the rscId (redwoodjs#11407)
  feat(rsc): Initial support for RSA rerender (redwoodjs#11406)
  chore(router): Switch to experimental types (redwoodjs#11405)
  chore(router): Make React a normal dependency (redwoodjs#11404)
  feat(rsc): Return flight from RSAs (redwoodjs#11403)
  rscRequestHandler.ts: Make BASE_PATH naming match client.ts (redwoodjs#11401)
  fix(template): api type declaration merging for scripts (redwoodjs#11367)
  RSC: Disable client side flight caching for now (redwoodjs#11400)
  chore(fixtures): Use proper name for AuthLayout component (redwoodjs#11399)
  feat(storage): Add support for createMany, updateMany and upsert (redwoodjs#11390)
  feat(codegen): support sdl generation for model with compound id (redwoodjs#8556)
  chore(ci): Follow up to workflow permissions (redwoodjs#11397)
  chore(deps): Bump 'loader-utils' within docs (redwoodjs#11396)
  chore(ci): Pin action dependencies by digest (redwoodjs#11395)
  ...
@Josh-Walker-GM Josh-Walker-GM modified the milestones: next-release, v8.0.0 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:chore This PR is a chore (means nothing for users)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants