Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
TimMikeladze committed Dec 3, 2023
1 parent 0171cd1 commit 3de08a5
Show file tree
Hide file tree
Showing 39 changed files with 260 additions and 279 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
- name: Run tests
run: yarn test:ci

- name: Build storybook
run: yarn build-storybook

- name: Build package
run: yarn build

Expand Down
3 changes: 1 addition & 2 deletions examples/next-upload-example/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ S3_ENDPOINT="http://localhost:9000"
S3_REGION="us-west-1"
PG_DB="postgres"
PG_CONNECTION_STRING="postgresql://postgres:postgres@localhost:5432"
NEXT_PUBLIC_MAX_SIZE="1mb"
CRON_KEY="password"
NEXT_PUBLIC_MAX_SIZE="1mb"
9 changes: 7 additions & 2 deletions examples/next-upload-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "node vercel.js && next build",
"build": "next build",
"start": "next start",
"lint": "next lint",
"link:self": "yarn yalc link next-upload && yarn link next-upload"
"link:self": "yarn yalc link next-upload && yarn link next-upload",
"migrate:generate": "drizzle-kit generate:pg --out src/drizzle/migrations --schema src/drizzle/schema.ts",
"migrate": "yarn ts src/drizzle/migrate",
"ts": "node node_modules/.bin/ts-node -r tsconfig-paths/register -O '{\"module\": \"commonjs\", \"moduleResolution\": \"classic\", \"resolveJsonModule\": false }' --transpile-only --project ./tsconfig.json"
},
"dependencies": {
"@keyv/postgres": "^1.4.9",
Expand Down Expand Up @@ -35,6 +38,8 @@
"dotenv": "^16.3.1",
"drizzle-kit": "^0.20.6",
"pg": "^8.11.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"yalc": "^1.0.0-pre.53"
}
}
22 changes: 0 additions & 22 deletions examples/next-upload-example/src/app/cron/route.ts

This file was deleted.

2 changes: 2 additions & 0 deletions examples/next-upload-example/src/app/nextUploadConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { type NextUploadConfig } from 'next-upload/client';
import { NextUpload } from 'next-upload';

export const nextUploadConfig: NextUploadConfig = {
maxSize: process.env.NEXT_PUBLIC_MAX_SIZE || '1mb',
bucket: NextUpload.bucketFromEnv('next-upload-example'),
client: {
region: process.env.S3_REGION,
endpoint: process.env.S3_ENDPOINT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { nextUploadConfig } from '@/app/nextUploadConfig';
import { getDbNodePostgres } from '@/db/getDbNodePostgres';
import { getDbNodePostgres } from '@/drizzle/getDbNodePostgres';
import { NextUpload } from 'next-upload';
import { DrizzlePgStore } from 'next-upload/store/drizzle/node-postgres';
import { NextUploadDrizzlePgStore } from 'next-upload/store/drizzle/node-postgres';

export const nup = new NextUpload(
{
Expand All @@ -11,5 +11,5 @@ export const nup = new NextUpload(
['drizzle-node-postgres']: {},
},
},
async () => new DrizzlePgStore(await getDbNodePostgres())
async () => new NextUploadDrizzlePgStore(await getDbNodePostgres())
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { nextUploadConfig } from '@/app/nextUploadConfig';
import { getDbPostgresJs } from '@/db/getDbPostgresJs';
import { getDbPostgresJs } from '@/drizzle/getDbPostgresJs';
import { NextUpload } from 'next-upload';
import { DrizzlePgStore } from 'next-upload/store/drizzle/postgres-js';
import { NextUploadDrizzlePgStore } from 'next-upload/store/drizzle/postgres-js';

export const nup = new NextUpload(
{
Expand All @@ -11,5 +11,5 @@ export const nup = new NextUpload(
['drizzle-postgres-js']: {},
},
},
new DrizzlePgStore(getDbPostgresJs())
new NextUploadDrizzlePgStore(getDbPostgresJs())
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { nextUploadConfig } from '@/app/nextUploadConfig';
import { getDbServerless } from '@/db/getDbServerless';
import { getDbServerless } from '@/drizzle/getDbServerless';
import { NextUpload } from 'next-upload';
import { DrizzlePgStore } from 'next-upload/store/drizzle/neon';
import { NextUploadDrizzlePgStore } from 'next-upload/store/drizzle/neon';

export const nup = new NextUpload(
{
Expand All @@ -12,5 +12,5 @@ export const nup = new NextUpload(
},
},

new DrizzlePgStore(getDbServerless())
new NextUploadDrizzlePgStore(getDbServerless())
);
4 changes: 2 additions & 2 deletions examples/next-upload-example/src/app/upload/keyv/nup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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';
import { NextUploadKeyvStore } from 'next-upload/store/keyv';

export const nup = new NextUpload(
{
Expand All @@ -12,7 +12,7 @@ export const nup = new NextUpload(
['keyv']: {},
},
},
new KeyvStore(
new NextUploadKeyvStore(
new Keyv({
namespace: NextUpload.namespaceFromEnv(),
store: new KeyvPostgres({
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions examples/next-upload-example/src/db/migrations/meta/_journal.json

This file was deleted.

40 changes: 40 additions & 0 deletions examples/next-upload-example/src/drizzle/migrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import { migrate as serverlessMigrate } from 'drizzle-orm/neon-http/migrator';
import dotenv from 'dotenv';
import { resolve } from 'path';

import { getDbPostgresJs } from '@/drizzle/getDbPostgresJs';

(async () => {
dotenv.config();

if (process.env.VERCEL) {
const getDbServerless = (await import(`@/drizzle/getDbServerless`))
.getDbServerless;
await serverlessMigrate(await getDbServerless(), {
migrationsFolder: resolve(`src/drizzle/migrations`),
})
.then(() => {
console.log(`Migrations complete!`);
process.exit(0);
})
.catch((err) => {
console.error(`Migrations failed!`, err);
process.exit(1);
});
} else {
await migrate(await getDbPostgresJs(), {
migrationsFolder: resolve(`src/drizzle/migrations`),
})
.then(() => {
console.log(`Migrations complete!`);
process.exit(0);
})
.catch((err) => {
console.error(`Migrations failed!`, err);
process.exit(1);
});
}

process.exit(0);
})();
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ CREATE TABLE IF NOT EXISTS "next_upload_assets" (
"updatedAt" timestamp with time zone DEFAULT now() NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"data" jsonb NOT NULL,
"expires" integer
"expires" bigint,
"presignedUrl" varchar,
"presignedUrlExpires" bigint
);
Loading

0 comments on commit 3de08a5

Please sign in to comment.