-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8e2855
commit c409b0a
Showing
43 changed files
with
2,676 additions
and
1,139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 1 addition & 10 deletions
11
...t-upload-example/src/app/upload/config.ts → ...pload-example/src/app/nextUploadConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,13 @@ | ||
import { type NextUploadConfig } from 'next-upload/client'; | ||
|
||
export enum NextUploadType { | ||
image = `image`, | ||
} | ||
|
||
export const config: NextUploadConfig = { | ||
export const nextUploadConfig: NextUploadConfig = { | ||
maxSize: process.env.NEXT_PUBLIC_MAX_SIZE || '1mb', | ||
// verifyAssets: true, | ||
client: { | ||
region: process.env.S3_REGION, | ||
endpoint: process.env.S3_ENDPOINT, | ||
credentials: { | ||
secretAccessKey: process.env.S3_SECRET_KEY, | ||
accessKeyId: process.env.S3_ACCESS_KEY, | ||
}, | ||
forcePathStyle: true, | ||
}, | ||
uploadTypes: { | ||
[NextUploadType.image]: {}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { nextUploadConfig } from '@/app/nextUploadConfig'; | ||
import { NextUpload } from 'next-upload'; | ||
|
||
export const nup = new NextUpload({ | ||
...nextUploadConfig, | ||
api: '/upload/basic', | ||
uploadTypes: { | ||
['basic']: {}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { NextRequest } from 'next/server'; | ||
import { nup } from './nup'; | ||
|
||
export const POST = (request: NextRequest) => nup.handler(request); | ||
|
||
export const dynamic = 'force-dynamic'; |
19 changes: 19 additions & 0 deletions
19
examples/next-upload-example/src/app/upload/drizzle-node-postgres/nup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { nextUploadConfig } from '@/app/nextUploadConfig'; | ||
import { getDbNodePostgres } from '@/db/getDbNodePostgres'; | ||
import { NextUpload } from 'next-upload'; | ||
import { DrizzlePostgresStore } from 'next-upload/store/drizzle/postgres-js'; | ||
|
||
export const nup = new NextUpload( | ||
{ | ||
...nextUploadConfig, | ||
api: '/upload/drizzle-node-postgres', | ||
uploadTypes: { | ||
['drizzle-node-postgres']: {}, | ||
}, | ||
}, | ||
async () => | ||
new DrizzlePostgresStore( | ||
// @ts-ignore | ||
await getDbNodePostgres() | ||
) | ||
); |
6 changes: 6 additions & 0 deletions
6
examples/next-upload-example/src/app/upload/drizzle-node-postgres/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { NextRequest } from 'next/server'; | ||
import { nup } from './nup'; | ||
|
||
export const POST = (request: NextRequest) => nup.handler(request); | ||
|
||
export const dynamic = 'force-dynamic'; |
15 changes: 15 additions & 0 deletions
15
examples/next-upload-example/src/app/upload/drizzle-postgres-js/nup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { nextUploadConfig } from '@/app/nextUploadConfig'; | ||
import { getDbPostgresJs } from '@/db/getDbPostgresJs'; | ||
import { NextUpload } from 'next-upload'; | ||
import { DrizzlePostgresStore } from 'next-upload/store/drizzle/postgres-js'; | ||
|
||
export const nup = new NextUpload( | ||
{ | ||
...nextUploadConfig, | ||
api: '/upload/drizzle-postgres-js', | ||
uploadTypes: { | ||
['drizzle-postgres-js']: {}, | ||
}, | ||
}, | ||
new DrizzlePostgresStore(getDbPostgresJs()) | ||
); |
6 changes: 6 additions & 0 deletions
6
examples/next-upload-example/src/app/upload/drizzle-postgres-js/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { NextRequest } from 'next/server'; | ||
import { nup } from './nup'; | ||
|
||
export const POST = (request: NextRequest) => nup.handler(request); | ||
|
||
export const dynamic = 'force-dynamic'; |
19 changes: 19 additions & 0 deletions
19
examples/next-upload-example/src/app/upload/edge-with-drizzle-neon/nup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { nextUploadConfig } from '@/app/nextUploadConfig'; | ||
import { getDbServerless } from '@/db/getDbServerless'; | ||
import { NextUpload } from 'next-upload'; | ||
import { DrizzlePostgresStore } from 'next-upload/store/drizzle/postgres-js'; | ||
|
||
export const nup = new NextUpload( | ||
{ | ||
...nextUploadConfig, | ||
api: '/edge-with-drizzle-neon', | ||
uploadTypes: { | ||
['edge-with-drizzle-neon']: {}, | ||
}, | ||
}, | ||
|
||
new DrizzlePostgresStore( | ||
// @ts-ignore | ||
getDbServerless() | ||
) | ||
); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { nextUploadConfig } from '@/app/nextUploadConfig'; | ||
import { NextUpload } from 'next-upload'; | ||
|
||
export const nup = new NextUpload({ | ||
...nextUploadConfig, | ||
api: '/upload/edge', | ||
uploadTypes: { | ||
['edge']: {}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { NextRequest } from 'next/server'; | ||
import { nup } from './nup'; | ||
|
||
export const POST = (request: NextRequest) => nup.handler(request); | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export const runtime = 'edge'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { nextUploadConfig } from '@/app/nextUploadConfig'; | ||
import KeyvPostgres from '@keyv/postgres'; | ||
import Keyv from 'keyv'; | ||
import { NextUpload } from 'next-upload'; | ||
import { KeyvStore } from 'next-upload/store/keyv'; | ||
|
||
export const nup = new NextUpload( | ||
{ | ||
...nextUploadConfig, | ||
api: '/upload/keyv', | ||
uploadTypes: { | ||
['keyv']: {}, | ||
}, | ||
}, | ||
new KeyvStore( | ||
new Keyv({ | ||
namespace: NextUpload.namespaceFromEnv(), | ||
store: new KeyvPostgres({ | ||
uri: `${process.env.PG_CONNECTION_STRING}/${process.env.PG_DB}`, | ||
}), | ||
}) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { NextRequest } from 'next/server'; | ||
import { nup } from './nup'; | ||
|
||
export const POST = (request: NextRequest) => nup.handler(request); | ||
|
||
export const dynamic = 'force-dynamic'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Pool } from 'pg'; | ||
import { drizzle } from 'drizzle-orm/node-postgres'; | ||
|
||
let db: ReturnType<typeof drizzle>; | ||
|
||
export const getDbNodePostgres = async () => { | ||
if (!db) { | ||
const client = new Pool({ | ||
connectionString: | ||
process.env.PG_CONNECTION_STRING + `/` + process.env.PG_DB, | ||
}); | ||
|
||
await client.connect(); | ||
db = drizzle(client); | ||
} | ||
|
||
return db; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { drizzle } from 'drizzle-orm/postgres-js'; | ||
import postgres from 'postgres'; | ||
|
||
let db: ReturnType<typeof drizzle>; | ||
|
||
export const getDbPostgresJs = () => { | ||
if (!db) { | ||
const client = postgres( | ||
`${process.env.PG_CONNECTION_STRING}/${process.env.PG_DB}` | ||
); | ||
|
||
db = drizzle(client); | ||
} | ||
|
||
return db; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { neon, neonConfig } from '@neondatabase/serverless'; | ||
import { drizzle } from 'drizzle-orm/neon-http'; | ||
|
||
neonConfig.fetchConnectionCache = true; | ||
|
||
const sql = neon(process.env.PG_CONNECTION_STRING + `/` + process.env.PG_DB); | ||
|
||
const db = drizzle(sql); | ||
|
||
export const getDbServerless = () => db; |
7 changes: 7 additions & 0 deletions
7
examples/next-upload-example/src/db/migrations/0000_careful_scorpion.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TABLE IF NOT EXISTS "next_upload_assets" ( | ||
"createdAt" timestamp with time zone DEFAULT now() NOT NULL, | ||
"updatedAt" timestamp with time zone DEFAULT now() NOT NULL, | ||
"id" varchar PRIMARY KEY NOT NULL, | ||
"data" jsonb NOT NULL, | ||
"expires" integer | ||
); |
2 changes: 2 additions & 0 deletions
2
examples/next-upload-example/src/db/migrations/0001_sticky_thunderbolt_ross.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "next_upload_assets" ADD COLUMN "presignedUrl" varchar;--> statement-breakpoint | ||
ALTER TABLE "next_upload_assets" ADD COLUMN "presignedUrlExpires" integer; |
2 changes: 2 additions & 0 deletions
2
examples/next-upload-example/src/db/migrations/0002_brave_argent.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "next_upload_assets" ALTER COLUMN "expires" SET DATA TYPE bigint;--> statement-breakpoint | ||
ALTER TABLE "next_upload_assets" ALTER COLUMN "presignedUrlExpires" SET DATA TYPE bigint; |
Oops, something went wrong.