-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from cmgriffing/feat/login-signup
feat: add pages and endpoints for login and signup
- Loading branch information
Showing
26 changed files
with
1,343 additions
and
32 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
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 |
---|---|---|
|
@@ -27,3 +27,5 @@ gitignore | |
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
src/db/local.db |
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,13 @@ | ||
require('dotenv').config() | ||
|
||
import type { Config } from 'drizzle-kit' | ||
|
||
export default { | ||
schema: './src/db/schema.ts', | ||
out: './migrations', | ||
dialect: 'turso', | ||
dbCredentials: { | ||
url: process.env.TURSO_DATABASE_URL!, | ||
authToken: process.env.TURSO_AUTH_TOKEN || 'foo', | ||
}, | ||
} satisfies Config |
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,24 @@ | ||
CREATE TABLE `snippets_table` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`userId` text NOT NULL, | ||
`title` text NOT NULL, | ||
`codeLeft` text NOT NULL, | ||
`codeRight` text NOT NULL, | ||
`createdAt` integer DEFAULT 0 NOT NULL, | ||
`updatedAt` integer DEFAULT 0 NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `users_table` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`email` text NOT NULL, | ||
`githubId` text NOT NULL, | ||
`githubUsername` text NOT NULL, | ||
`githubAvatarUrl` text NOT NULL, | ||
`createdAt` integer DEFAULT 0 NOT NULL, | ||
`updatedAt` integer DEFAULT 0 NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE UNIQUE INDEX `users_table_email_unique` ON `users_table` (`email`);--> statement-breakpoint | ||
CREATE UNIQUE INDEX `users_table_githubId_unique` ON `users_table` (`githubId`);--> statement-breakpoint | ||
CREATE UNIQUE INDEX `users_table_githubUsername_unique` ON `users_table` (`githubUsername`);--> statement-breakpoint | ||
CREATE UNIQUE INDEX `users_table_githubAvatarUrl_unique` ON `users_table` (`githubAvatarUrl`); |
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,169 @@ | ||
{ | ||
"version": "6", | ||
"dialect": "sqlite", | ||
"id": "05492c90-59bd-45e4-99e5-29a29eb2d4ef", | ||
"prevId": "00000000-0000-0000-0000-000000000000", | ||
"tables": { | ||
"snippets_table": { | ||
"name": "snippets_table", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "text", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"userId": { | ||
"name": "userId", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"title": { | ||
"name": "title", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"codeLeft": { | ||
"name": "codeLeft", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"codeRight": { | ||
"name": "codeRight", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"createdAt": { | ||
"name": "createdAt", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": 0 | ||
}, | ||
"updatedAt": { | ||
"name": "updatedAt", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": 0 | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {}, | ||
"checkConstraints": {} | ||
}, | ||
"users_table": { | ||
"name": "users_table", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "text", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"email": { | ||
"name": "email", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"githubId": { | ||
"name": "githubId", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"githubUsername": { | ||
"name": "githubUsername", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"githubAvatarUrl": { | ||
"name": "githubAvatarUrl", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"createdAt": { | ||
"name": "createdAt", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": 0 | ||
}, | ||
"updatedAt": { | ||
"name": "updatedAt", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": 0 | ||
} | ||
}, | ||
"indexes": { | ||
"users_table_email_unique": { | ||
"name": "users_table_email_unique", | ||
"columns": [ | ||
"email" | ||
], | ||
"isUnique": true | ||
}, | ||
"users_table_githubId_unique": { | ||
"name": "users_table_githubId_unique", | ||
"columns": [ | ||
"githubId" | ||
], | ||
"isUnique": true | ||
}, | ||
"users_table_githubUsername_unique": { | ||
"name": "users_table_githubUsername_unique", | ||
"columns": [ | ||
"githubUsername" | ||
], | ||
"isUnique": true | ||
}, | ||
"users_table_githubAvatarUrl_unique": { | ||
"name": "users_table_githubAvatarUrl_unique", | ||
"columns": [ | ||
"githubAvatarUrl" | ||
], | ||
"isUnique": true | ||
} | ||
}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {}, | ||
"checkConstraints": {} | ||
} | ||
}, | ||
"views": {}, | ||
"enums": {}, | ||
"_meta": { | ||
"schemas": {}, | ||
"tables": {}, | ||
"columns": {} | ||
}, | ||
"internal": { | ||
"indexes": {} | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"version": "7", | ||
"dialect": "sqlite", | ||
"entries": [ | ||
{ | ||
"idx": 0, | ||
"version": "6", | ||
"when": 1729551859421, | ||
"tag": "0000_last_patch", | ||
"breakpoints": true | ||
} | ||
] | ||
} |
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
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
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,11 @@ | ||
import 'dotenv/config' | ||
import { drizzle } from 'drizzle-orm/libsql' | ||
import { schema } from './schema' | ||
|
||
export const db = drizzle({ | ||
schema: schema, | ||
connection: { | ||
url: process.env.TURSO_DATABASE_URL!, | ||
authToken: process.env.TURSO_AUTH_TOKEN, | ||
}, | ||
}) |
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,28 @@ | ||
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core' | ||
|
||
export const usersTable = sqliteTable('users_table', { | ||
id: text().primaryKey(), | ||
email: text().notNull().unique(), | ||
githubId: text().notNull().unique(), | ||
githubUsername: text().notNull().unique(), | ||
githubAvatarUrl: text().notNull().unique(), | ||
createdAt: int().notNull().default(0), | ||
updatedAt: int().notNull().default(0), | ||
}) | ||
|
||
export const snippetsTable = sqliteTable('snippets_table', { | ||
id: text().primaryKey(), | ||
userId: text() | ||
.notNull() | ||
.references(() => usersTable.id), | ||
title: text().notNull(), | ||
codeLeft: text().notNull(), | ||
codeRight: text().notNull(), | ||
createdAt: int().notNull().default(0), | ||
updatedAt: int().notNull().default(0), | ||
}) | ||
|
||
export const schema = { | ||
users: usersTable, | ||
snippets: snippetsTable, | ||
} |
Oops, something went wrong.