Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simmmpleweb committed Aug 26, 2024
1 parent 434bc3c commit f2dbbd3
Show file tree
Hide file tree
Showing 66 changed files with 2,893 additions and 2,226 deletions.
26 changes: 26 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
NEXT_PUBLIC_SUPABASE_URL=https://********************.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=****************************************************************************************************************************************************************************************************************

NEXT_PUBLIC_OPENAI_API_KEY=sk-************************************************
NEXT_PUBLIC_OPENAI_ASSISTANT_KEY=asst_************************

# Update these with your Supabase details from your project settings > API
SUPABASE_SERVICE_ROLE_KEY=***************************************************************************************************************************************************************************************************************************

# Update these with your Stripe credentials from https://dashboard.stripe.com/apikeys
# NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_***************************************************************************************************
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_***************************************************************************************************
# STRIPE_SECRET_KEY=sk_live_***************************************************************************************************
STRIPE_SECRET_KEY=sk_test_***************************************************************************************************
# The commented variable is usually for production webhook key. This you get in the Stripe dashboard and is usually shorter.
# STRIPE_WEBHOOK_SECRET=whsec_********************************
STRIPE_WEBHOOK_SECRET=whsec_****************************************************************

# Update this with your stable site URL only for the production environment.
# NEXT_PUBLIC_SITE_URL=https://horizon-ui.com/shadcn-nextjs-boilerplate
# NEXT_PUBLIC_SITE_URL=https://******************.com

NEXT_PUBLIC_AWS_S3_REGION=eu-north-1
NEXT_PUBLIC_AWS_S3_ACCESS_KEY_ID=********************
NEXT_PUBLIC_AWS_S3_SECRET_ACCESS_KEY=****************************************
NEXT_PUBLIC_AWS_S3_BUCKET_NAME=mybucket
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# misc
.DS_Store
*.pem
.supabase/seed.sql
supabase/seed.sql
supabase/migrations

# debug
npm-debug.log*
Expand All @@ -40,10 +43,13 @@ yarn-error.log*
next-env.d.ts

package-lock.json
.env.local.production
.env.local.new
.env.local.non-docker

components/ui

yarn.lock

# editors
.vscode
.vscode
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## [2.0.0] 2024-08-26

### Big update: Supabase SSR, Refactoring & custom auth components

- #### Supabase SSR
- Utils ⁠ folder refactored, now functions are organized in separate folders based on usage
- ⁠New auth-related utils
- ⁠Functions like ⁠ getSessions ⁠ were removed because of the use of Supabase SSR
- session ⁠ object was replaced with ⁠ user ⁠ throughout the project

- #### Layout refactoring
- ⁠The multiple addition of functionalities led to prop drilling, which was fixed by using contexts.

- #### Separate auth pages
- ⁠Auth pages are dynamic Next.js pages, one for each of Update password, sign up, password sign in, etc.
- ⁠The forms for each type of authentication types are located in ⁠ @/components/auth-ui 

- #### Added Docker support
- You can now develop locally via Docker by using Supabase CLI

## [1.1.0] 2024-07-18

### Added Main Dashboard Page
Expand Down
30 changes: 8 additions & 22 deletions app/api/chatAPI/route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { ChatBody } from '@/types/types';
import { OpenAIStream } from '@/utils/chatStream';
import { OpenAIStream } from '@/utils/streams/chatStream';

export const runtime = 'edge';

export const runtime = 'edge'

export async function GET(req: Request): Promise<Response>{
export async function GET(req: Request): Promise<Response> {
try {
const { inputMessage, model, apiKey } =
(await req.json()) as ChatBody;
const { inputMessage, model, apiKey } = (await req.json()) as ChatBody;

let apiKeyFinal;
if (apiKey) {
Expand All @@ -16,23 +14,17 @@ export async function GET(req: Request): Promise<Response>{
apiKeyFinal = process.env.NEXT_PUBLIC_OPENAI_API_KEY;
}

const stream = await OpenAIStream(
inputMessage,
model,
apiKeyFinal,
);
const stream = await OpenAIStream(inputMessage, model, apiKeyFinal);

return new Response(stream);
} catch (error) {
console.error(error);
return new Response('Error', { status: 500 });
}

}
export async function POST(req: Request): Promise<Response>{
export async function POST(req: Request): Promise<Response> {
try {
const { inputMessage, model, apiKey } =
(await req.json()) as ChatBody;
const { inputMessage, model, apiKey } = (await req.json()) as ChatBody;

let apiKeyFinal;
if (apiKey) {
Expand All @@ -41,17 +33,11 @@ export async function POST(req: Request): Promise<Response>{
apiKeyFinal = process.env.NEXT_PUBLIC_OPENAI_API_KEY;
}

const stream = await OpenAIStream(
inputMessage,
model,
apiKeyFinal,
);
const stream = await OpenAIStream(inputMessage, model, apiKeyFinal);

return new Response(stream);
} catch (error) {
console.error(error);
return new Response('Error', { status: 500 });
}

}

90 changes: 0 additions & 90 deletions app/api/create-checkout-session/route.ts

This file was deleted.

45 changes: 0 additions & 45 deletions app/api/create-portal-link/route.ts

This file was deleted.

34 changes: 20 additions & 14 deletions app/api/essayAPI/route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { EssayBody } from '@/types/types';
import { OpenAIStream } from '@/utils/essayStream';
import { OpenAIStream } from '@/utils/streams/essayStream';

export const runtime = 'edge';

export const runtime = 'edge'

export async function GET(req: Request): Promise<Response>{
export async function GET(req: Request): Promise<Response> {
try {
const { topic, words, essayType, model, apiKey } =
(await req.json()) as EssayBody;
const {
topic,
words,
essayType,
model,
apiKey
} = (await req.json()) as EssayBody;

let apiKeyFinal;
if (apiKey) {
Expand All @@ -21,20 +25,24 @@ export async function GET(req: Request): Promise<Response>{
essayType,
words,
model,
apiKeyFinal,
apiKeyFinal
);

return new Response(stream);
} catch (error) {
console.error(error);
return new Response('Error', { status: 500 });
}

}
export async function POST(req: Request): Promise<Response>{
export async function POST(req: Request): Promise<Response> {
try {
const { topic, words, essayType, model, apiKey } =
(await req.json()) as EssayBody;
const {
topic,
words,
essayType,
model,
apiKey
} = (await req.json()) as EssayBody;

let apiKeyFinal;
if (apiKey) {
Expand All @@ -48,14 +56,12 @@ export async function POST(req: Request): Promise<Response>{
essayType,
words,
model,
apiKeyFinal,
apiKeyFinal
);

return new Response(stream);
} catch (error) {
console.error(error);
return new Response('Error', { status: 500 });
}

}

4 changes: 2 additions & 2 deletions app/api/webhooks/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Stripe from 'stripe';
import { stripe } from '@/utils/stripe';
import { stripe } from '@/utils/stripe/config';
import {
upsertProductRecord,
upsertPriceRecord,
Expand Down Expand Up @@ -27,7 +27,7 @@ export async function POST(req: Request) {
try {
if (!sig || !webhookSecret) return;
event = stripe.webhooks.constructEvent(body, sig, webhookSecret);
} catch (err: any) {
} catch (err) {
console.log(`❌ Error message: ${err.message}`);
return new Response(`Webhook Error: ${err.message}`, { status: 400 });
}
Expand Down
Loading

0 comments on commit f2dbbd3

Please sign in to comment.