Skip to content

Commit

Permalink
feat(remix-cloudflare): deprecate createCloudflareKVSessionStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Nov 19, 2022
1 parent f7b896b commit b723402
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-dancers-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/cloudflare": minor
---

Rename `createCloudflareKVSessionStorage` to `createWorkersKVSessionStorage`
1 change: 1 addition & 0 deletions integration/cf-compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ test.describe("cloudflare compiler", () => {
"createMemorySessionStorage",
"createSessionStorage",
"createSession",
"createCloudflareKVSessionStorage",
"isCookie",
"isSession",
"json",
Expand Down
20 changes: 16 additions & 4 deletions packages/remix-cloudflare/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import "./globals";

export {
import {createWorkersKVSessionStorage} from './sessions/workersKVStorage';

const warn = <T extends Function>(fn: T, message: string): T =>
((...args: unknown[]) => {
console.warn(message);

return fn(...args);
}) as unknown as T;


/** @deprecated Use `createWorkersKVSessionStorage` instead. */
export const createCloudflareKVSessionStorage = warn(
createWorkersKVSessionStorage,
// TODO: Deprecate createCloudflareKVSessionStorage
createWorkersKVSessionStorage as createCloudflareKVSessionStorage,
} from "./sessions/workersKVStorage";
"`createCloudflareKVSessionStorage` is deprecated. Please use `createWorkersKVSessionStorage` instead.",
);

export { createWorkersKVSessionStorage } from "./sessions/workersKVStorage";

export {
createCookie,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ const defaultRuntimeExports: ExportNames = {

const exportNamesByRuntime: Record<Runtime, Partial<ExportNames>> = {
cloudflare: {
value: ["createCloudflareKVSessionStorage"],
value: [
"createCloudflareKVSessionStorage",
"createWorkersKVSessionStorage",
],
},
node: {
type: ["HeadersInit", "RequestInfo", "RequestInit", "ResponseInit"],
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-eslint-config/rules/packageExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const architectSpecificExports = {
};

const cloudflareSpecificExports = {
value: ["createCloudflareKVSessionStorage"],
value: ["createCloudflareKVSessionStorage", "createWorkersKVSessionStorage"],
type: [],
};

Expand Down

0 comments on commit b723402

Please sign in to comment.