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

bun #672

Merged
merged 47 commits into from
Oct 26, 2023
Merged

bun #672

Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
962fd64
chore: remove console.log
chronark Oct 10, 2023
a76aa0e
Merge branch 'main' of https://github.com/upstash/upstash-redis
chronark Oct 10, 2023
c2183e6
Merge branch 'main' of https://github.com/upstash/upstash-redis
chronark Oct 10, 2023
dc46ca5
Merge branch 'main' of https://github.com/upstash/upstash-redis
chronark Oct 17, 2023
855b20a
Merge branch 'main' of https://github.com/upstash/upstash-redis
chronark Oct 17, 2023
85c7b79
Merge branch 'main' of https://github.com/upstash/upstash-redis
chronark Oct 17, 2023
672b3a3
Merge branch 'main' of https://github.com/upstash/upstash-redis
chronark Oct 19, 2023
ba999bf
refactor: tests
chronark Oct 19, 2023
32173e6
ci: so it begins
chronark Oct 19, 2023
f67ece6
Merge branch 'main' of https://github.com/upstash/upstash-redis into bun
chronark Oct 19, 2023
b052361
ci: wip
chronark Oct 19, 2023
adea804
ci: wip
chronark Oct 19, 2023
cf70d4c
ci: wip
chronark Oct 19, 2023
996539a
ci: wip
chronark Oct 19, 2023
ba58b4a
ci: wip
chronark Oct 19, 2023
58dfec5
ci: wip
chronark Oct 19, 2023
3b3a10c
ci: wip
chronark Oct 19, 2023
14cf117
ci: wip
chronark Oct 19, 2023
263a8b3
ci: wip
chronark Oct 19, 2023
ac395d6
ci: wip
chronark Oct 19, 2023
6cac254
ci: wip
chronark Oct 19, 2023
ccd372d
ci: wip
chronark Oct 19, 2023
be78fac
ci: wip
chronark Oct 19, 2023
d6be2b2
ci: wip
chronark Oct 19, 2023
0624851
ci: wip
chronark Oct 19, 2023
f70718d
ci: wip
chronark Oct 19, 2023
70275e3
ci: wip
chronark Oct 19, 2023
cccbfa1
ci: wip
chronark Oct 19, 2023
1e9bcd7
ci: wip
chronark Oct 19, 2023
9293298
ci: wip
chronark Oct 19, 2023
dd9731d
ci: wip
chronark Oct 19, 2023
66fd7a9
ci: wip
chronark Oct 19, 2023
8e628df
ci: wip
chronark Oct 19, 2023
06854f3
ci: wip
chronark Oct 19, 2023
8cbd894
ci: wip
chronark Oct 19, 2023
dfe7d4e
ci: wip
chronark Oct 19, 2023
b0f7e36
ci: wip
chronark Oct 19, 2023
bd72e88
ci: wip
chronark Oct 19, 2023
7a29aa5
ci: wip
chronark Oct 19, 2023
7074909
ci: wip
chronark Oct 23, 2023
51446ac
ci: wip
chronark Oct 23, 2023
32297c5
ci: wip
chronark Oct 23, 2023
855bbea
ci: wip
chronark Oct 23, 2023
45fd3cb
docs(README.md): update Deno installation link to Bun installation link
chronark Oct 23, 2023
adde737
docs: explain build step
chronark Oct 23, 2023
5af8a64
Add verbose to understand the npm issue
ogzhanolguncu Oct 23, 2023
592d82a
Disable sourcemaps and allow minify
ogzhanolguncu Oct 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: tests
chronark committed Oct 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ba999bf2bf5ba3f0f7d4940c78b8b96e308b4a62
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ npm install @upstash/redis
#### Deno

```ts
import { Redis } from "https://deno.land/x/upstash_redis/mod.ts";
import { Redis } from "https://deno.land/x/upstash_redis/mod";
```

### Create database
37 changes: 37 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://biomejs.dev/schemas/1.0.0/schema.json",

"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"noSvgWithoutTitle": "off"
},
"correctness": {
"noUnusedVariables": "warn"
},
"security": {
"noDangerouslySetInnerHtml": "off"
},
"style": {
"useBlockStatements": "error",
"noNonNullAssertion": "off"
},
"performance": {
"noDelete": "off"
},
"suspicious":{
"noExplicitAny": "off"
}
},
"ignore": ["node_modules", ".next", "dist", ".nuxt", ".contentlayer"]
},
"formatter": {
"indentStyle": "space",
"indentWidth": 2,
"enabled": true,
"lineWidth": 100,
"ignore": ["node_modules", ".next", "dist", ".nuxt", ".contentlayer"]
}
}
Binary file added bun.lockb
Binary file not shown.
94 changes: 0 additions & 94 deletions cmd/build.ts

This file was deleted.

2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * as dnt from "https://deno.land/x/[email protected]/mod.ts";
export * as dnt from "https://deno.land/x/[email protected]/mod";
6 changes: 1 addition & 5 deletions examples/aws-lambda/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const { Redis } = require("@upstash/redis/with-fetch");
import type {
APIGatewayEvent,
APIGatewayProxyResult,
Context,
} from "aws-lambda";
import type { APIGatewayEvent, APIGatewayProxyResult, Context } from "aws-lambda";

export const handler = async (
_event: APIGatewayEvent,
6 changes: 1 addition & 5 deletions examples/cloudflare-workers-with-typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -6,11 +6,7 @@ export interface Env {
}

export default {
async fetch(
_request: Request,
env: Env,
_ctx: ExecutionContext,
): Promise<Response> {
async fetch(_request: Request, env: Env, _ctx: ExecutionContext): Promise<Response> {
const redis = Redis.fromEnv(env);

const count = await redis.incr("cloudflare-workers-with-typescript-count");
8 changes: 4 additions & 4 deletions examples/cloudflare-workers-with-typescript/test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { expect } from "https://deno.land/std/testing/asserts";

const deploymentURL = Deno.env.get("DEPLOYMENT_URL");
if (!deploymentURL) {
throw new Error("DEPLOYMENT_URL not set");
}

Deno.test("works", async () => {
test("works", async () => {
console.log({ deploymentURL });
const url = `${deploymentURL}/`;
const res = await fetch(url);
if (res.status !== 200) {
console.log(await res.text());
}
assertEquals(res.status, 200);
expect(res.status, 200);
const json = (await res.json()) as { count: number };
assertEquals(typeof json.count, "number");
expect(typeof json.count, "number");
});
4 changes: 1 addition & 3 deletions examples/cloudflare-workers/index.js
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@ export default {

const count = await redis.incr("cloudflare-workers-count");

return new Response(
JSON.stringify({ count }),
);
return new Response(JSON.stringify({ count }));
},
};
8 changes: 4 additions & 4 deletions examples/cloudflare-workers/test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { expect } from "https://deno.land/std/testing/asserts";

const deploymentURL = Deno.env.get("DEPLOYMENT_URL");
if (!deploymentURL) {
throw new Error("DEPLOYMENT_URL not set");
}

Deno.test("works", async () => {
test("works", async () => {
console.log({ deploymentURL });
const url = `${deploymentURL}/`;
const res = await fetch(url);
if (res.status !== 200) {
console.log(await res.text());
}
assertEquals(res.status, 200);
expect(res.status, 200);
const json = (await res.json()) as { count: number };
assertEquals(typeof json.count, "number");
expect(typeof json.count, "number");
});
8 changes: 3 additions & 5 deletions examples/deno/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";

const deploymentURL = Deno.env.get("DEPLOYMENT_URL");
if (!deploymentURL) {
throw new Error("DEPLOYMENT_URL not set");
}

Deno.test("works", async () => {
test("works", async () => {
console.log({ deploymentURL });
const res = await fetch(deploymentURL);
const body = await res.text();
console.log({ body });
assertEquals(res.status, 200);
expect(res.status, 200);
const json = JSON.parse(body) as { counter: number };
assertEquals(typeof json.counter, "number");
expect(typeof json.counter, "number");
});
4 changes: 2 additions & 2 deletions examples/deno/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { Redis } from "https://deno.land/x/upstash_redis/mod.ts";
import { serve } from "https://deno.land/[email protected]/http/server";
import { Redis } from "https://deno.land/x/upstash_redis/mod";

serve(async (_req: Request) => {
const redis = Redis.fromEnv();
8 changes: 4 additions & 4 deletions examples/fastly/test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { expect } from "https://deno.land/std/testing/asserts";

const deploymentURL = Deno.env.get("DEPLOYMENT_URL");
if (!deploymentURL) {
throw new Error("DEPLOYMENT_URL not set");
}

Deno.test("works", async () => {
test("works", async () => {
console.log({ deploymentURL });
const res = await fetch(deploymentURL);
assertEquals(res.status, 200);
expect(res.status, 200);
const json = (await res.json()) as { count: number };
assertEquals(typeof json.count, "number");
expect(typeof json.count, "number");
});
10 changes: 6 additions & 4 deletions examples/netlify-edge/netlify/edge-functions/incr.ts
Original file line number Diff line number Diff line change
@@ -4,10 +4,12 @@ const redis = Redis.fromEnv();
export default async (_req: Request) => {
console.log("Hello");
try {
return new Response(JSON.stringify({
message: "Hello World",
counter: await redis.incr("netlify-edge"),
}));
return new Response(
JSON.stringify({
message: "Hello World",
counter: await redis.incr("netlify-edge"),
}),
);
} catch (err) {
console.error(err);
return new Response(err.message, { status: 500 });
8 changes: 3 additions & 5 deletions examples/netlify-edge/test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";

const deploymentURL = Deno.env.get("DEPLOYMENT_URL");
if (!deploymentURL) {
throw new Error("DEPLOYMENT_URL not set");
}

Deno.test("works", async () => {
test("works", async () => {
console.log({ deploymentURL });
const url = `${deploymentURL}/incr`;
console.log({ url });
const res = await fetch(url);
const body = await res.text();
console.log({ body });
assertEquals(res.status, 200);
expect(res.status, 200);
const json = JSON.parse(body) as { counter: number };
assertEquals(typeof json.counter, "number");
expect(typeof json.counter, "number");
});
8 changes: 4 additions & 4 deletions examples/netlify/test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { expect } from "https://deno.land/std/testing/asserts";

const deploymentURL = Deno.env.get("DEPLOYMENT_URL");
if (!deploymentURL) {
throw new Error("DEPLOYMENT_URL not set");
}

Deno.test("works", async () => {
test("works", async () => {
console.log({ deploymentURL });
const url = `${deploymentURL}/.netlify/functions/handler`;
console.log({ url });

const res = await fetch(url);
assertEquals(res.status, 200);
expect(res.status, 200);
const json = (await res.json()) as { counter: number };
assertEquals(typeof json.counter, "number");
expect(typeof json.counter, "number");
});
6 changes: 1 addition & 5 deletions examples/nextjs/app/random/page.tsx
Original file line number Diff line number Diff line change
@@ -8,9 +8,5 @@ export default async function Page() {

const random = await redis.srandmember<string>("random");

return (
<div>
{random}
</div>
);
return <div>{random}</div>;
}
7 changes: 1 addition & 6 deletions examples/nextjs/components/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -31,12 +31,7 @@ export function BreadcrumbItem({ url, name }: BreadcrumbItemProps) {
export function Breadcrumb({ data, showRoot = true }: BreadcrumbProps) {
return (
<div className="flex items-center gap-1.5">
<svg
width="20"
height="20"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
>
<svg width="20" height="20" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path
fill="currentColor"
fillRule="evenodd"
2 changes: 1 addition & 1 deletion examples/nextjs/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Breadcrumb, BreadcrumbProps } from "./Breadcrumb";
import StarButton from "./StarButton";
import React from "react";

export type HeaderProps = {
breadcrumbOptions: BreadcrumbProps;
3 changes: 1 addition & 2 deletions examples/nextjs/components/StarButton.tsx
Original file line number Diff line number Diff line change
@@ -19,8 +19,7 @@ export default function StarButton({ url }: StarButtonProps) {
fill="currentColor"
fillRule="evenodd"
d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z"
>
</path>
></path>
</svg>
<span>Star on GitHub</span>
</a>
6 changes: 1 addition & 5 deletions examples/nextjs/middleware.ts
Original file line number Diff line number Diff line change
@@ -12,11 +12,7 @@ export default async function middleware(_request: Request) {
* We're prefixing the key for our automated tests.
* This is to avoid collisions with other tests.
*/
const key = [
"vercel",
process.env.VERCEL_GIT_COMMIT_SHA,
"middleware_counter",
].join("_");
const key = ["vercel", process.env.VERCEL_GIT_COMMIT_SHA, "middleware_counter"].join("_");
const value = await incr(key);
console.log("mw", { value });
return NextResponse.next();
Loading