Skip to content
Open
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
3 changes: 3 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ENVIRONMENT="dev"
SHARE_PORT=3333
SHARE_MAX_SIZE_IN_MB=10
15 changes: 0 additions & 15 deletions .editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ dist
.pnp.\*

# wrangler project

.dev.vars

.wrangler
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lint-staged
9 changes: 9 additions & 0 deletions .idea/cloudflare-drop.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/git_toolbox_blame.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/.*
dist
node_modules
/data/migrations
*.toml
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}
7 changes: 7 additions & 0 deletions data/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'drizzle-kit'

export default defineConfig({
schema: './data/schemas/*.schema.ts',
out: './data/migrations',
dialect: 'sqlite',
})
8 changes: 8 additions & 0 deletions data/migrations/0000_military_gateway.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE `tasks` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`slug` text NOT NULL,
`description` text,
`completed` integer DEFAULT false,
`due_date` integer
);
11 changes: 11 additions & 0 deletions data/migrations/0001_shocking_risque.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE `files` (
`id` text PRIMARY KEY NOT NULL,
`object_id` text NOT NULL,
`filename` text,
`type` text,
`hash` text NOT NULL,
`code` text NOT NULL,
`due_date` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `files_code_unique` ON `files` (`code`);
71 changes: 71 additions & 0 deletions data/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"version": "6",
"dialect": "sqlite",
"id": "8478d988-2dea-452f-bade-9bb672920d97",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"tasks": {
"name": "tasks",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"slug": {
"name": "slug",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"completed": {
"name": "completed",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
},
"due_date": {
"name": "due_date",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
138 changes: 138 additions & 0 deletions data/migrations/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"version": "6",
"dialect": "sqlite",
"id": "b317b683-3017-4501-b7de-cedbe98e6142",
"prevId": "8478d988-2dea-452f-bade-9bb672920d97",
"tables": {
"files": {
"name": "files",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"object_id": {
"name": "object_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"filename": {
"name": "filename",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hash": {
"name": "hash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"code": {
"name": "code",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"due_date": {
"name": "due_date",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"files_code_unique": {
"name": "files_code_unique",
"columns": [
"code"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"tasks": {
"name": "tasks",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"slug": {
"name": "slug",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"completed": {
"name": "completed",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
},
"due_date": {
"name": "due_date",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
20 changes: 20 additions & 0 deletions data/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "7",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1736300515801,
"tag": "0000_military_gateway",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1737452058197,
"tag": "0001_shocking_risque",
"breakpoints": true
}
]
}
32 changes: 32 additions & 0 deletions data/schemas/files.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { z } from 'zod'
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
import {
createSelectSchema,
createInsertSchema,
createUpdateSchema,
} from 'drizzle-zod'
import { createId } from '@paralleldrive/cuid2'

export const files = sqliteTable('files', {
id: text('id')
.primaryKey()
.$defaultFn(() => createId()),
objectId: text('object_id').notNull(), // 文件 id
filename: text('filename'), // 文件名
type: text('type'), // 类型
hash: text('hash').notNull(), // hash 值
code: text('code').notNull().unique(), // 分享码
due_date: integer('due_date', { mode: 'timestamp' }).notNull(), // 过期时间
})

export const fileSelectSchema = createSelectSchema(files)

export const fileInsertSchema = createInsertSchema(files)

export const fileUpdateSchema = createUpdateSchema(files)

export type SelectFileType = z.output<typeof fileSelectSchema>

export type InsertFileType = z.output<typeof fileInsertSchema>

export type UpdateFileType = z.output<typeof fileUpdateSchema>
2 changes: 2 additions & 0 deletions data/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './tasks.schema'
export * from './files.schema'
Loading