forked from javayhu/free-directory-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 2a3b4e7
Showing
435 changed files
with
43,658 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@commitlint/config-conventional"] | ||
} |
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,36 @@ | ||
# ----------------------------------------------------------------------------- | ||
# App | ||
# ----------------------------------------------------------------------------- | ||
NEXT_PUBLIC_APP_URL=http://localhost:3000 | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Authentication (NextAuth.js) | ||
# ----------------------------------------------------------------------------- | ||
NEXTAUTH_SECRET= | ||
|
||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= | ||
|
||
GITHUB_OAUTH_TOKEN= | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Database (MySQL - Neon DB) | ||
# ----------------------------------------------------------------------------- | ||
DATABASE_URL='postgres://[user]:[password]@[neon_hostname]/[dbname]?sslmode=require' | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Email (Resend) | ||
# ----------------------------------------------------------------------------- | ||
RESEND_API_KEY= | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Subscriptions (Stripe) | ||
# ----------------------------------------------------------------------------- | ||
STRIPE_API_KEY= | ||
STRIPE_WEBHOOK_SECRET= | ||
|
||
NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PLAN_ID= | ||
NEXT_PUBLIC_STRIPE_PRO_YEARLY_PLAN_ID= | ||
|
||
NEXT_PUBLIC_STRIPE_BUSINESS_MONTHLY_PLAN_ID= | ||
NEXT_PUBLIC_STRIPE_BUSINESS_YEARLY_PLAN_ID= |
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,31 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/eslintrc", | ||
"root": true, | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"prettier", | ||
"plugin:tailwindcss/recommended" | ||
], | ||
"plugins": ["tailwindcss"], | ||
"rules": { | ||
"@next/next/no-html-link-for-pages": "off", | ||
"react/jsx-key": "off", | ||
"tailwindcss/no-custom-classname": "off", | ||
"tailwindcss/classnames-order": "off" | ||
}, | ||
"settings": { | ||
"tailwindcss": { | ||
"callees": ["cn"], | ||
"config": "tailwind.config.ts" | ||
}, | ||
"next": { | ||
"rootDir": true | ||
} | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"parser": "@typescript-eslint/parser" | ||
} | ||
] | ||
} |
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,43 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
/.react-email/ | ||
|
||
.vscode | ||
.contentlayer |
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,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx commitlint --edit $1 |
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,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx pretty-quick --staged |
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 @@ | ||
v16.18.0 |
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,5 @@ | ||
dist | ||
node_modules | ||
.next | ||
build | ||
.contentlayer |
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,35 @@ | ||
# https://github.com/someu/aigotools/blob/main/packages/aigotools/Dockerfile | ||
FROM node:20-alpine AS base | ||
|
||
# Install dependencies only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY . . | ||
RUN apk add --no-cache libc6-compat \ | ||
&& npm config set strict-ssl false \ | ||
&& npm config set fetch-retries 10 \ | ||
&& corepack enable pnpm \ | ||
&& pnpm i \ | ||
&& mv next.config.docker.js next.config.js \ | ||
&& pnpm run build | ||
|
||
# Production image, copy all the files and run next | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
|
||
RUN addgroup --system --gid 1001 nodejs \ | ||
&& adduser --system --uid 1001 nextjs \ | ||
&& mkdir .next \ | ||
&& chown nextjs:nodejs .next | ||
|
||
COPY --from=builder /app/public ./public | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
CMD HOSTNAME="0.0.0.0" node server.js |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 mickasmt | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,5 @@ | ||
# Indie Hackers | ||
|
||
This project works as the main website for indie-hackers-site. | ||
|
||
Link: [https://vercel.indiehackers.site](https://vercel.indiehackers.site) |
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,39 @@ | ||
"use server"; | ||
|
||
import { auth } from "@/auth"; | ||
import { client } from "@/sanity/lib/client"; | ||
import { revalidatePath } from "next/cache"; | ||
|
||
export type deleteApplicationFormData = { | ||
lang: string; | ||
applicationId: string; | ||
}; | ||
|
||
// https://nextjs.org/learn/dashboard-app/mutating-data | ||
export async function deleteApplication(userId: string, data: deleteApplicationFormData) { | ||
try { | ||
const session = await auth(); | ||
if (!session?.user || session?.user.id !== userId) { | ||
console.log("deleteApplication, unauthorized"); | ||
throw new Error("Unauthorized"); | ||
} | ||
console.log("deleteApplication, username:", session?.user?.name); | ||
|
||
// console.log("deleteApplication, data:", data); | ||
const { lang, applicationId } = data; | ||
console.log("deleteApplication, lang:", lang, " applicationId:", applicationId); | ||
|
||
const res = await client.delete(applicationId); | ||
if (!res) { | ||
console.log("deleteApplication, fail"); | ||
return { status: "error" }; | ||
} | ||
|
||
console.log("deleteApplication, success, res:", res); | ||
revalidatePath(`/${lang}/dashboard/app`); | ||
return { status: "success" }; | ||
} catch (error) { | ||
console.log("deleteApplication, error", error); | ||
return { status: "error" }; | ||
} | ||
} |
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,65 @@ | ||
"use server"; | ||
|
||
import { auth } from "@/auth"; | ||
import { stripe } from "@/lib/stripe"; | ||
import { getUserSubscriptionPlan } from "@/lib/subscription"; | ||
import { absoluteUrl } from "@/lib/utils"; | ||
import { redirect } from "next/navigation"; | ||
|
||
export type responseAction = { | ||
status: "success" | "error"; | ||
stripeUrl?: string; | ||
} | ||
|
||
// const billingUrl = absoluteUrl("/dashboard/billing") | ||
const billingUrl = absoluteUrl("/pricing") | ||
|
||
export async function generateUserStripe(priceId: string): Promise<responseAction> { | ||
let redirectUrl: string = ""; | ||
|
||
try { | ||
const session = await auth() | ||
|
||
if (!session?.user || !session?.user.email) { | ||
throw new Error("Unauthorized"); | ||
} | ||
|
||
const subscriptionPlan = await getUserSubscriptionPlan(session.user.id) | ||
|
||
if (subscriptionPlan.isPaid && subscriptionPlan.stripeCustomerId) { | ||
// User on Paid Plan - Create a portal session to manage subscription. | ||
const stripeSession = await stripe.billingPortal.sessions.create({ | ||
customer: subscriptionPlan.stripeCustomerId, | ||
return_url: billingUrl, | ||
}) | ||
|
||
redirectUrl = stripeSession.url as string | ||
} else { | ||
// User on Free Plan - Create a checkout session to upgrade. | ||
const stripeSession = await stripe.checkout.sessions.create({ | ||
success_url: billingUrl, | ||
cancel_url: billingUrl, | ||
payment_method_types: ["card"], | ||
mode: "subscription", | ||
billing_address_collection: "auto", | ||
customer_email: session.user.email, | ||
line_items: [ | ||
{ | ||
price: priceId, | ||
quantity: 1, | ||
}, | ||
], | ||
metadata: { | ||
userId: session.user.id, | ||
}, | ||
}) | ||
|
||
redirectUrl = stripeSession.url as string | ||
} | ||
} catch (error) { | ||
throw new Error("Failed to generate user stripe session"); | ||
} | ||
|
||
// no revalidatePath because redirect | ||
redirect(redirectUrl) | ||
} |
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,42 @@ | ||
"use server"; | ||
|
||
import { redirect } from "next/navigation"; | ||
import { auth } from "@/auth"; | ||
|
||
import { stripe } from "@/lib/stripe"; | ||
import { getUserSubscriptionPlan } from "@/lib/subscription"; | ||
import { absoluteUrl } from "@/lib/utils"; | ||
|
||
export type responseAction = { | ||
status: "success" | "error"; | ||
stripeUrl?: string; | ||
}; | ||
|
||
const billingUrl = absoluteUrl("/dashboard/billing"); | ||
|
||
export async function openCustomerPortal( | ||
userStripeId: string, | ||
): Promise<responseAction> { | ||
let redirectUrl: string = ""; | ||
|
||
try { | ||
const session = await auth(); | ||
|
||
if (!session?.user || !session?.user.email) { | ||
throw new Error("Unauthorized"); | ||
} | ||
|
||
if (userStripeId) { | ||
const stripeSession = await stripe.billingPortal.sessions.create({ | ||
customer: userStripeId, | ||
return_url: billingUrl, | ||
}); | ||
|
||
redirectUrl = stripeSession.url as string; | ||
} | ||
} catch (error) { | ||
throw new Error("Failed to generate user stripe session"); | ||
} | ||
|
||
redirect(redirectUrl); | ||
} |
Oops, something went wrong.