Skip to content
Draft
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_CLERK_PUBLISHABLE_KEY=pk_test_your_key_here
18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Environment variables
.env
.env.local
.env.production.local
.env.development.local

# Convex
.convex
7 changes: 7 additions & 0 deletions convex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"functions": "convex/",
"generateCommonJSApi": false,
"node": {
"externalPackages": []
}
}
41 changes: 41 additions & 0 deletions convex/_generated/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* prettier-ignore-start */

/* eslint-disable */
/**
* Generated `api` utility.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* To regenerate, run `npx convex dev` or `npx convex codegen`.
* @module
*/

import type {
ApiFromModules,
FilterApi,
FunctionReference,
} from "convex/server";
import * as auth from "../auth";

/**
* A utility for referencing Convex functions in your app's API.
*
* Usage:
* ```js
* const myFunctionReference = api.myModule.myFunction;
* ```
*/
type FullApi = ApiFromModules<{
auth: typeof auth;
}>;
export type Api = FilterApi<
FullApi,
FunctionReference<any, "public">
>;

export const api = {
auth: {
getCurrentUser: auth.getCurrentUser,
},
} as Api;
/* prettier-ignore-end */
53 changes: 53 additions & 0 deletions convex/_generated/server.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* prettier-ignore-start */

/* eslint-disable */
/**
* Generated server utility.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* To regenerate, run `npx convex dev` or `npx convex codegen`.
* @module
*/

import type { FunctionReference } from "convex/server";
import type { QueryBuilder, MutationBuilder, ActionBuilder, HttpActionBuilder } from "convex/server";

/**
* A utility for referencing Convex server functions.
*
* Usage:
* ```js
* const myServerFunction = server.myModule.myFunction;
* ```
*/
declare const fullServer: Record<string, Record<string, FunctionReference>>;
export type Server = typeof fullServer;

export const server: Server;

// Export query, mutation, action, httpAction helpers
export declare function query<Args extends Record<string, any>, Output>(
queryDefinition: {
handler: (ctx: { auth: { getSessionId: () => Promise<string | null>; getToken: () => Promise<string | null> } }, args: Args) => Promise<Output>;
}
): QueryBuilder<Args, Output, "public">;

export declare function mutation<Args extends Record<string, any>, Output>(
mutationDefinition: {
handler: (ctx: { auth: { getSessionId: () => Promise<string | null>; getToken: () => Promise<string | null> } }, args: Args) => Promise<Output>;
}
): MutationBuilder<Args, Output, "public">;

export declare function action<Args extends Record<string, any>, Output>(
actionDefinition: {
handler: (ctx: { auth: { getSessionId: () => Promise<string | null>; getToken: () => Promise<string | null> } }, args: Args) => Promise<Output>;
}
): ActionBuilder<Args, Output, "public">;

export declare function httpAction(
handler: (ctx: { auth: { getSessionId: () => Promise<string | null>; getToken: () => Promise<string | null> } }, request: Request) => Promise<Response>
): HttpActionBuilder;

export declare function getAuthToken(ctx: { auth: { getToken: () => Promise<string | null> } }): Promise<string | null>;
/* prettier-ignore-end */
5 changes: 5 additions & 0 deletions convex/auth.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Convex auth configuration for Clerk
// The auth token is passed from the frontend via ConvexProvider
// and can be accessed in queries/mutations using getAuthToken()

export {};
16 changes: 16 additions & 0 deletions convex/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { query, getAuthToken } from "./_generated/server.js";

export const getCurrentUser = query({
handler: async (ctx) => {
const token = await getAuthToken(ctx);
if (!token) {
return null;
}
// Token is present, indicating user is authenticated via Clerk
// In a production app, you would decode the Clerk JWT token here
// and fetch user info from your user table
return {
authenticated: true,
};
},
});
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Todo App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "todo",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"convex:dev": "convex dev",
"convex:deploy": "convex deploy"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"convex": "^1.12.0",
"@clerk/clerk-react": "^5.0.0"
},
"devDependencies": {
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"typescript": "^5.2.2",
"vite": "^5.0.8"
}
}
Loading