Skip to content
Merged
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
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ The Exicon and Lexicon pages support URL query parameters for filtering and sear

The Exicon (`/exicon`) supports the following query parameters:

| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| `search` | string | Search exercises by name or alias | - |
| `letter` | string | Filter by first letter (A-Z) | `All` |
| `tags` | string | Comma-separated tag names | - |
| `tagLogic` | string | Tag combination logic: `AND` or `OR` | `OR` |
| Parameter | Type | Description | Default |
| ---------- | ------ | ------------------------------------ | ------- |
| `search` | string | Search exercises by name or alias | - |
| `letter` | string | Filter by first letter (A-Z) | `All` |
| `tags` | string | Comma-separated tag names | - |
| `tagLogic` | string | Tag combination logic: `AND` or `OR` | `OR` |

**Examples:**

Expand All @@ -50,10 +50,10 @@ The Exicon (`/exicon`) supports the following query parameters:

The Lexicon (`/lexicon`) supports the following query parameters:

| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| `search` | string | Search terms by name, alias, or description | - |
| `letter` | string | Filter by first letter (A-Z) | `All` |
| Parameter | Type | Description | Default |
| --------- | ------ | ------------------------------------------- | ------- |
| `search` | string | Search terms by name, alias, or description | - |
| `letter` | string | Filter by first letter (A-Z) | `All` |

**Examples:**

Expand Down
2 changes: 1 addition & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
}
}
2 changes: 1 addition & 1 deletion docs/blueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
- Accent: A bright blue (#007BFF) for interactive elements and links.
- Clean and modern sans-serif fonts for readability and accessibility.
- Use consistent and recognizable icons for navigation and actions.
- Responsive layout that adapts to different screen sizes.
- Responsive layout that adapts to different screen sizes.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import nextConfig from 'eslint-config-next';
import nextConfig from "eslint-config-next";

export default nextConfig;
32 changes: 19 additions & 13 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import { NextRequest, NextResponse } from 'next/server';
import { NextRequest, NextResponse } from "next/server";

export function middleware(request: NextRequest) {
// Handle CORS for callback routes
if (
request.nextUrl.pathname.startsWith('/callback') ||
request.nextUrl.pathname.startsWith('/api/callback')
request.nextUrl.pathname.startsWith("/callback") ||
request.nextUrl.pathname.startsWith("/api/callback")
) {
// Handle preflight requests
if (request.method === 'OPTIONS') {
if (request.method === "OPTIONS") {
return new NextResponse(null, {
status: 200,
headers: {
'Access-Control-Allow-Origin': 'https://auth.f3nation.com',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
'Access-Control-Max-Age': '86400',
"Access-Control-Allow-Origin": "https://auth.f3nation.com",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
"Access-Control-Max-Age": "86400",
},
});
}

// Add CORS headers to all callback responses
const response = NextResponse.next();

response.headers.set('Access-Control-Allow-Origin', 'https://auth.f3nation.com');
response.headers.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
response.headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization');

response.headers.set(
"Access-Control-Allow-Origin",
"https://auth.f3nation.com",
);
response.headers.set("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
response.headers.set(
"Access-Control-Allow-Headers",
"Content-Type, Authorization",
);

return response;
}
Expand All @@ -33,5 +39,5 @@ export function middleware(request: NextRequest) {
}

export const config = {
matcher: ['/callback/:path*', '/api/callback/:path*'],
matcher: ["/callback/:path*", "/api/callback/:path*"],
};
72 changes: 41 additions & 31 deletions migrations/1747064544503_create-tags-table.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,50 @@ exports.shorthands = undefined;
* @returns {Promise<void> | void}
*/
exports.up = (pgm) => {
console.log('[MIGRATION_LOG] Starting migration: 1747064544503_create-tags-table.js UP');
pgm.createTable('tags', {
id: { type: 'text', primaryKey: true },
name: { type: 'text', notNull: true, unique: true },
console.log(
"[MIGRATION_LOG] Starting migration: 1747064544503_create-tags-table.js UP",
);
pgm.createTable("tags", {
id: { type: "text", primaryKey: true },
name: { type: "text", notNull: true, unique: true },
created_at: {
type: 'timestamp',
type: "timestamp",
notNull: true,
default: pgm.func('current_timestamp'),
default: pgm.func("current_timestamp"),
},
});

const initialTags = [
{ id: 't1', name: 'Arms' },
{ id: 't2', name: 'Legs' },
{ id: 't3', name: 'Core' },
{ id: 't4', name: 'Cardio' },
{ id: 't5', name: 'Full Body' },
{ id: 't6', name: 'Partner' },
{ id: 't7', name: 'Coupon' },
{ id: 't8', name: 'Music' },
{ id: 't9', name: 'Mosey' },
{ id: 't10', name: 'Static' },
{ id: 't11', name: 'Strength' },
{ id: 't12', name: 'AMRAP' },
{ id: 't13', name: 'EMOM' },
{ id: 't14', name: 'Reps' },
{ id: 't15', name: 'Timed' },
{ id: 't16', name: 'Distance' },
{ id: 't17', name: 'Routine' },
{ id: 't18', name: 'Run' },
{ id: 't19', name: 'Warm-Up' },
{ id: 't20', name: 'Mary' },
{ id: "t1", name: "Arms" },
{ id: "t2", name: "Legs" },
{ id: "t3", name: "Core" },
{ id: "t4", name: "Cardio" },
{ id: "t5", name: "Full Body" },
{ id: "t6", name: "Partner" },
{ id: "t7", name: "Coupon" },
{ id: "t8", name: "Music" },
{ id: "t9", name: "Mosey" },
{ id: "t10", name: "Static" },
{ id: "t11", name: "Strength" },
{ id: "t12", name: "AMRAP" },
{ id: "t13", name: "EMOM" },
{ id: "t14", name: "Reps" },
{ id: "t15", name: "Timed" },
{ id: "t16", name: "Distance" },
{ id: "t17", name: "Routine" },
{ id: "t18", name: "Run" },
{ id: "t19", name: "Warm-Up" },
{ id: "t20", name: "Mary" },
];

for (const tag of initialTags) {
pgm.sql(`INSERT INTO tags (id, name) VALUES ('${tag.id}', '${tag.name.replace(/'/g, "''")}');`);
pgm.sql(
`INSERT INTO tags (id, name) VALUES ('${tag.id}', '${tag.name.replace(/'/g, "''")}');`,
);
}
console.log('[MIGRATION_LOG] Finished migration: 1747064544503_create-tags-table.js UP');
console.log(
"[MIGRATION_LOG] Finished migration: 1747064544503_create-tags-table.js UP",
);
};

/**
Expand All @@ -55,7 +61,11 @@ exports.up = (pgm) => {
* @returns {Promise<void> | void}
*/
exports.down = (pgm) => {
console.log('[MIGRATION_LOG] Starting migration: 1747064544503_create-tags-table.js DOWN');
pgm.dropTable('tags');
console.log('[MIGRATION_LOG] Finished migration: 1747064544503_create-tags-table.js DOWN');
console.log(
"[MIGRATION_LOG] Starting migration: 1747064544503_create-tags-table.js DOWN",
);
pgm.dropTable("tags");
console.log(
"[MIGRATION_LOG] Finished migration: 1747064544503_create-tags-table.js DOWN",
);
};
10 changes: 5 additions & 5 deletions migrations/1747064552223_create-user-submissions-table.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports.shorthands = undefined;
*/
exports.up = (pgm) => {
console.log(
"[MIGRATION_LOG] Starting migration: create-user-submissions-table UP"
"[MIGRATION_LOG] Starting migration: create-user-submissions-table UP",
);

pgm.createTable("user_submissions", {
Expand Down Expand Up @@ -59,7 +59,7 @@ exports.up = (pgm) => {
`);

console.log(
"[MIGRATION_LOG] Finished migration: create-user-submissions-table UP"
"[MIGRATION_LOG] Finished migration: create-user-submissions-table UP",
);
};

Expand All @@ -69,17 +69,17 @@ exports.up = (pgm) => {
*/
exports.down = (pgm) => {
console.log(
"[MIGRATION_LOG] Starting migration: create-user-submissions-table DOWN"
"[MIGRATION_LOG] Starting migration: create-user-submissions-table DOWN",
);

pgm.sql(
`DROP TRIGGER IF EXISTS trigger_user_submissions_updated_at ON user_submissions;`
`DROP TRIGGER IF EXISTS trigger_user_submissions_updated_at ON user_submissions;`,
);
pgm.sql(`DROP FUNCTION IF EXISTS update_updated_at_column;`);

pgm.dropTable("user_submissions");

console.log(
"[MIGRATION_LOG] Finished migration: create-user-submissions-table DOWN"
"[MIGRATION_LOG] Finished migration: create-user-submissions-table DOWN",
);
};
10 changes: 5 additions & 5 deletions migrations/1752677590715_create-entries-and-entry-tags-table.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.shorthands = undefined;
*/
exports.up = (pgm) => {
console.log(
"[MIGRATION_LOG] Starting migration: create_entries_and_entry_tags_table UP"
"[MIGRATION_LOG] Starting migration: create_entries_and_entry_tags_table UP",
);

// Create 'entries' table (this part remains as is, as it's working)
Expand All @@ -36,7 +36,7 @@ exports.up = (pgm) => {
},
{
ifNotExists: true,
}
},
);

pgm.createIndex("entries", "title", { ifNotExists: true });
Expand All @@ -58,7 +58,7 @@ exports.up = (pgm) => {
// This migration file now ONLY defines the database schema.

console.log(
"[MIGRATION_LOG] Finished migration: create_entries_and_entry_tags_table UP"
"[MIGRATION_LOG] Finished migration: create_entries_and_entry_tags_table UP",
);
};

Expand All @@ -69,7 +69,7 @@ exports.up = (pgm) => {
*/
exports.down = (pgm) => {
console.log(
"[MIGRATION_LOG] Starting migration: create_entries_and_entry_tags_table DOWN"
"[MIGRATION_LOG] Starting migration: create_entries_and_entry_tags_table DOWN",
);
// When using pgm.sql for UP, you should use pgm.sql for DOWN too for consistency,
// or ensure pgm.dropTable can correctly identify the table created by pgm.sql.
Expand All @@ -80,6 +80,6 @@ exports.down = (pgm) => {
pgm.dropIndex("entries", "type", { ifExists: true });
pgm.dropIndex("entries", "title", { ifExists: true });
console.log(
"[MIGRATION_LOG] Finished migration: create_entries_and_entry_tags_table DOWN"
"[MIGRATION_LOG] Finished migration: create_entries_and_entry_tags_table DOWN",
);
};
8 changes: 4 additions & 4 deletions migrations/1752732000000_add-mentioned-entries-column.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.shorthands = undefined;
*/
exports.up = (pgm) => {
console.log(
"[MIGRATION_LOG] Starting migration: add_mentioned_entries_column_to_entries UP"
"[MIGRATION_LOG] Starting migration: add_mentioned_entries_column_to_entries UP",
);

pgm.sql(`
Expand All @@ -30,7 +30,7 @@ exports.up = (pgm) => {
`);

console.log(
"[MIGRATION_LOG] Finished migration: add_mentioned_entries_column_to_entries UP"
"[MIGRATION_LOG] Finished migration: add_mentioned_entries_column_to_entries UP",
);
};

Expand All @@ -41,7 +41,7 @@ exports.up = (pgm) => {
*/
exports.down = (pgm) => {
console.log(
"[MIGRATION_LOG] Starting migration: add_mentioned_entries_column_to_entries DOWN"
"[MIGRATION_LOG] Starting migration: add_mentioned_entries_column_to_entries DOWN",
);

pgm.sql(`
Expand All @@ -50,6 +50,6 @@ exports.down = (pgm) => {
`);

console.log(
"[MIGRATION_LOG] Finished migration: add_mentioned_entries_column_to_entries DOWN"
"[MIGRATION_LOG] Finished migration: add_mentioned_entries_column_to_entries DOWN",
);
};
30 changes: 19 additions & 11 deletions migrations/1752732100000_create-entry-references-table.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.shorthands = undefined;
*/
exports.up = (pgm) => {
console.log(
"[MIGRATION_LOG] Starting migration: create_entry_references_table UP"
"[MIGRATION_LOG] Starting migration: create_entry_references_table UP",
);

pgm.createTable(
Expand Down Expand Up @@ -45,12 +45,16 @@ exports.up = (pgm) => {
},
{
ifNotExists: true,
}
},
);

pgm.addConstraint("entry_references", "entry_references_unique_source_target", {
unique: ["source_entry_id", "target_entry_id"],
});
pgm.addConstraint(
"entry_references",
"entry_references_unique_source_target",
{
unique: ["source_entry_id", "target_entry_id"],
},
);

pgm.createIndex("entry_references", ["source_entry_id"], {
ifNotExists: true,
Expand All @@ -61,7 +65,7 @@ exports.up = (pgm) => {
});

console.log(
"[MIGRATION_LOG] Finished migration: create_entry_references_table UP"
"[MIGRATION_LOG] Finished migration: create_entry_references_table UP",
);
};

Expand All @@ -72,17 +76,21 @@ exports.up = (pgm) => {
*/
exports.down = (pgm) => {
console.log(
"[MIGRATION_LOG] Starting migration: create_entry_references_table DOWN"
"[MIGRATION_LOG] Starting migration: create_entry_references_table DOWN",
);

pgm.dropIndex("entry_references", ["target_entry_id"], { ifExists: true });
pgm.dropIndex("entry_references", ["source_entry_id"], { ifExists: true });
pgm.dropConstraint("entry_references", "entry_references_unique_source_target", {
ifExists: true,
});
pgm.dropConstraint(
"entry_references",
"entry_references_unique_source_target",
{
ifExists: true,
},
);
pgm.dropTable("entry_references", { ifExists: true });

console.log(
"[MIGRATION_LOG] Finished migration: create_entry_references_table DOWN"
"[MIGRATION_LOG] Finished migration: create_entry_references_table DOWN",
);
};
Loading