Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
TinsFox committed Sep 20, 2024
1 parent 13fb33a commit 3a17717
Show file tree
Hide file tree
Showing 25 changed files with 2,840 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SECRET_KEY = ""
COOKIE_KEY = "token"
16 changes: 16 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Deploy Worker
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Build & Deploy Worker
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# prod
dist/

# dev
.yarn/
!.yarn/releases
.vscode/*
!.vscode/launch.json
!.vscode/*.code-snippets
.idea/workspace.xml
.idea/usage.statistics.xml
.idea/shelf

# deps
node_modules/
.wrangler

# env
.env
.env.production
.dev.vars

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

# misc
.DS_Store
prisma/dev.db

wrangler.toml
.dev.vars
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Mock Service

```bash
pnpm install
pnpm run dev
```

```bash
pnpm run deploy
```

## Prisma Note

```bash
npx wrangler d1 migrations create mock-service init

npx prisma migrate diff \
--from-empty \
--to-schema-datamodel ./prisma/schema.prisma \
--script \
--output migrations/0001_init.sql

npx wrangler d1 migrations apply mock-service --local

npx wrangler d1 migrations apply mock-service --remote

npx prisma generate
```
64 changes: 64 additions & 0 deletions migrations/0001_init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL PRIMARY KEY,
"email" TEXT NOT NULL,
"username" TEXT,
"name" TEXT,
"avatar" TEXT,
"birthdate" DATETIME,
"bio" TEXT,
"password" TEXT NOT NULL,
"registeredAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "Album" (
"id" TEXT NOT NULL PRIMARY KEY,
"title" TEXT NOT NULL,
"cover" TEXT,
"url" TEXT,
"slogan" TEXT,
"digitalDownloads" REAL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "TeamUser" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"email" TEXT,
"avatar" TEXT,
"status" TEXT NOT NULL,
"role" TEXT NOT NULL,
"bio" TEXT,
"amount" REAL NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "Role" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL DEFAULT '',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "Permission" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL DEFAULT '',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "mock-service",
"type": "module",
"scripts": {
"dev": "wrangler dev src/index.ts",
"deploy": "wrangler deploy --minify src/index.ts",
"test": "vitest",
"setup": "prisma generate && prisma migrate deploy && prisma db seed"
},
"dependencies": {
"@hono/swagger-ui": "^0.4.1",
"@prisma/adapter-d1": "^5.19.1",
"@prisma/client": "5.19.1",
"@prisma/extension-accelerate": "^1.1.0",
"bcryptjs": "^2.4.3",
"hono": "^4.6.2",
"@faker-js/faker": "^9.0.1"
},
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.5.6",
"@cloudflare/workers-types": "^4.20240919.0",
"@types/bcryptjs": "^2.4.6",
"@types/node": "^22.5.5",
"prisma": "^5.19.1",
"ts-node": "^10.9.2",
"typescript": "^5.6.2",
"vitest": "^2.1.1",
"wrangler": "^3.78.6"
}
}
Loading

0 comments on commit 3a17717

Please sign in to comment.