Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chiubaca authored Jun 1, 2024
0 parents commit e72741a
Show file tree
Hide file tree
Showing 31 changed files with 13,394 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# build output
dist/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# jetbrains setting folder
.idea/

# cloudflare
.wrangler
.dev.vars
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Astro Starter Kit: Minimal

```sh
npm create astro@latest -- --template minimal
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/minimal/devcontainer.json)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
## 🚀 Project Structure

Inside of your Astro project, you'll see the following folders and files:

```text
/
├── public/
├── src/
│ └── pages/
│ └── index.astro
└── package.json
```

Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.

There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.

Any static assets, like images, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
23 changes: 23 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from "astro/config";
import react from "@astrojs/react";

import cloudflare from "@astrojs/cloudflare";

// https://astro.build/config
export default defineConfig({
integrations: [react()],
output: "server",
vite: {
ssr: {
external: ["node:async_hooks"],
},
},
adapter: cloudflare({
platformProxy: {
enabled: true,
}
}),
experimental: {
actions: true,
},
});
38 changes: 38 additions & 0 deletions db/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { sql } from "drizzle-orm";
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";

export const message = sqliteTable("message", {
id: integer("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => userTable.id),
text: text("text").notNull(),
createdAt: text("timestamp")
.notNull()
.default(sql`(current_timestamp)`),
imageRef: text("image_ref").unique(),
});

export const userTable = sqliteTable("user", {
id: text("id").notNull().primaryKey(),
oauthId: text("oauth_id", { length: 255 }).unique().notNull(),
authType: text("oauth_type", { enum: ["google", "github"] }).notNull(),
avatarUrl: text("avatar_url"),
userName: text("user_name").notNull(), // The user alias or handle name
fullName: text("full_name").notNull(), // Full name of the user
email: text("email").notNull(),
createdAt: text("timestamp")
.notNull()
.default(sql`(current_timestamp)`),
});

export const sessionTable = sqliteTable("session", {
id: text("id").notNull().primaryKey(),
userId: text("user_id")
.notNull()
.references(() => userTable.id),
expiresAt: integer("expires_at").notNull(),
createdAt: text("timestamp")
.notNull()
.default(sql`(current_timestamp)`),
});
21 changes: 21 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from "drizzle-kit";

const config = defineConfig({
schema: "./db/schema.ts",
dialect: "sqlite",
verbose: true,
strict: true,
driver: "d1-http",
// dbCredentials:{
// wranglerConfigPath: "./wrangler.toml",
// dbName: 'fullstack-astro-cloudflare-db'
// },
dbCredentials: {
accountId: "6fba426cae95d09cbd43f7d359f87924",
databaseId: "307c117f-ab77-485c-a26e-deb8586cbd3b",
token: "T8xfT6Gppkkd2UXC7g_qVeP3im6ajLQs3rJRmT2H",
},
});


export default config
30 changes: 30 additions & 0 deletions drizzle/0000_cute_post.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE TABLE `message` (
`id` integer PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`text` text NOT NULL,
`timestamp` text DEFAULT (current_timestamp) NOT NULL,
`image_ref` text,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `session` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`expires_at` integer NOT NULL,
`timestamp` text DEFAULT (current_timestamp) NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `user` (
`id` text PRIMARY KEY NOT NULL,
`oauth_id` text(255) NOT NULL,
`oauth_type` text NOT NULL,
`avatar_url` text,
`user_name` text NOT NULL,
`full_name` text NOT NULL,
`email` text NOT NULL,
`timestamp` text DEFAULT (current_timestamp) NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `message_image_ref_unique` ON `message` (`image_ref`);--> statement-breakpoint
CREATE UNIQUE INDEX `user_oauth_id_unique` ON `user` (`oauth_id`);
Loading

0 comments on commit e72741a

Please sign in to comment.