Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions base_files/after_issue_3/server/src/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {Subscription} from "./models/Subscription.js";

const addSubscription= async (req, res) => {
const {userId, name, amount, billingCycle, renewalDate, isTrial, source} = req.body;

if(!userId || !name || !amount || !billingCycle || !renewalDate || !isTrial || !source){
return res.json({error: "Missing fields!"});
}

const data= await Subscription.create(req.body);
console.log(data);

return res.json({success: "Subscription added successfully!"});

}

const fetchSubscriptions= async (req, res) => {
const {userId} = req.body;

if(!userId){
return res.json({error: "UserID required!"});
}

const subs= await Subscription.find(
{userId: userId},
{name:1, amount:1, billingCycle:1, renewalDate:1, _id: 0}
);

if(!subs){
return res.json({error: "Failes to fetch subscriptions!"});
}

if(subs.length == 0){
return res.json({error: "No data found!"});
}

return res.json(subs);
}

export {addSubscription, fetchSubscriptions};
Empty file.
14 changes: 14 additions & 0 deletions base_files/after_issue_3/server/src/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import express from 'express';
import { addSubscription, fetchSubscriptions } from './controller.js';
const router = express.Router();

router.get("/healthCheck", (req, res) => {

return res.json({health: "Working fine!"})

})

router.get("/subscriptions", fetchSubscriptions);
router.post("/subscriptions", addSubscription);

export default router;
44 changes: 44 additions & 0 deletions contributors/Anshdeep-Singh-9/client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# 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*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# clerk configuration (can include secrets)
/.clerk/
36 changes: 36 additions & 0 deletions contributors/Anshdeep-Singh-9/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
2 changes: 2 additions & 0 deletions contributors/Anshdeep-Singh-9/client/envExample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_PLACEHOLDER
CLERK_SECRET_KEY=sk_test_PLACEHOLDER
18 changes: 18 additions & 0 deletions contributors/Anshdeep-Singh-9/client/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";

const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);

export default eslintConfig;
7 changes: 7 additions & 0 deletions contributors/Anshdeep-Singh-9/client/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
27 changes: 27 additions & 0 deletions contributors/Anshdeep-Singh-9/client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"@clerk/nextjs": "^6.36.5",
"next": "16.1.1",
"react": "19.2.3",
"react-dom": "19.2.3"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.1.1",
"tailwindcss": "^4",
"typescript": "^5"
}
}
7 changes: 7 additions & 0 deletions contributors/Anshdeep-Singh-9/client/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};

export default config;
1 change: 1 addition & 0 deletions contributors/Anshdeep-Singh-9/client/public/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions contributors/Anshdeep-Singh-9/client/public/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions contributors/Anshdeep-Singh-9/client/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions contributors/Anshdeep-Singh-9/client/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions contributors/Anshdeep-Singh-9/client/public/window.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions contributors/Anshdeep-Singh-9/client/src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { UserButton } from '@clerk/nextjs';
import { currentUser } from '@clerk/nextjs/server';
import { redirect } from 'next/navigation';

export default async function DashboardPage() {
const user = await currentUser();

if (!user) {
redirect('/sign-in');
}

return (
<div className="min-h-screen p-8 bg-gray-50 dark:bg-gray-900">
<div className="max-w-4xl mx-auto">
<div className="flex justify-between items-center mb-8">
<h1 className="text-3xl font-bold text-gray-800 dark:text-white">
Dashboard
</h1>

<UserButton afterSignOutUrl="/" />
</div>

<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
<h2 className="text-xl font-semibold mb-4 text-gray-700 dark:text-gray-200">
Welcome, {user.firstName ?? 'User'} 👋
</h2>

<div className="space-y-2 text-gray-600 dark:text-gray-400">
<p>
<strong>Email:</strong> {user.emailAddresses[0]?.emailAddress}
</p>
<p>
<strong>User ID:</strong> {user.id}
</p>
</div>
</div>
</div>
</div>
);
}
Binary file not shown.
26 changes: 26 additions & 0 deletions contributors/Anshdeep-Singh-9/client/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@import "tailwindcss";

:root {
--background: #ffffff;
--foreground: #171717;
}

@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}

body {
background: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
}
37 changes: 37 additions & 0 deletions contributors/Anshdeep-Singh-9/client/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ClerkProvider } from "@clerk/nextjs";

const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});

const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<ClerkProvider>
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
</html>
</ClerkProvider>
);
}
42 changes: 42 additions & 0 deletions contributors/Anshdeep-Singh-9/client/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { SignedIn, SignedOut, SignInButton } from '@clerk/nextjs';
import Link from 'next/link';

export default function Home() {
return (
<div className="grid min-h-screen place-items-center p-8 sm:p-20">
<main className="flex flex-col gap-6 items-center text-center max-w-xl">
<h1 className="text-4xl font-bold">SubSentry</h1>

<p className="text-lg text-muted-foreground">
Secure subscription management with industry-grade authentication.
</p>

<div className="flex gap-4 flex-wrap justify-center">
<SignedOut>
<SignInButton>
<button className="rounded-full bg-black text-white px-6 py-3 hover:bg-gray-800 transition">
Sign In
</button>
</SignInButton>

<Link
href="/sign-up"
className="rounded-full border px-6 py-3 hover:bg-gray-100 transition"
>
Sign Up
</Link>
</SignedOut>

<SignedIn>
<Link
href="/dashboard"
className="rounded-full bg-black text-white px-6 py-3 hover:bg-gray-800 transition"
>
Go to Dashboard
</Link>
</SignedIn>
</div>
</main>
</div>
);
}
23 changes: 23 additions & 0 deletions contributors/Anshdeep-Singh-9/client/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';

const isPublicRoute = createRouteMatcher([
'/',
'/sign-in(.*)', // sign-in routes
'/sign-up(.*)',
]);

export default clerkMiddleware(async (auth, request) => {
if (!isPublicRoute(request)) {
await auth.protect();
}
});

export const config = {
matcher: [
// Skip _next, static files, images, fonts, etc.
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|png|webp|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',

// Always run middleware for API & tRPC routes
'/(api|trpc)(.*)',
],
};
Loading