File tree 15 files changed +758
-0
lines changed
15 files changed +758
-0
lines changed Original file line number Diff line number Diff line change
1
+ # prod
2
+ dist /
3
+
4
+ # dev
5
+ .yarn /
6
+ ! .yarn /releases
7
+ .vscode /*
8
+ ! .vscode /launch.json
9
+ ! .vscode /* .code-snippets
10
+ .idea /workspace.xml
11
+ .idea /usage.statistics.xml
12
+ .idea /shelf
13
+
14
+ # deps
15
+ node_modules /
16
+ .wrangler
17
+
18
+ # env
19
+ .env
20
+ .env.production
21
+ .dev.vars
22
+
23
+ # logs
24
+ logs /
25
+ * .log
26
+ npm-debug.log *
27
+ yarn-debug.log *
28
+ yarn-error.log *
29
+ pnpm-debug.log *
30
+ lerna-debug.log *
31
+
32
+ # misc
33
+ .DS_Store
Original file line number Diff line number Diff line change
1
+ ```
2
+ npm install
3
+ npm run dev
4
+ ```
5
+
6
+ ```
7
+ npm run deploy
8
+ ```
Original file line number Diff line number Diff line change
1
+
2
+ -- Drop github_users table
3
+ DROP TABLE IF EXISTS github_users;
4
+
5
+ -- Create temporary table without last_reset
6
+ CREATE TABLE rate_limits_old (
7
+ ip TEXT PRIMARY KEY ,
8
+ requests INTEGER DEFAULT 0
9
+ );
10
+
11
+ -- Copy essential data
12
+ INSERT INTO rate_limits_old (ip, requests)
13
+ SELECT ip, requests FROM rate_limits;
14
+
15
+ -- Drop new table
16
+ DROP TABLE rate_limits;
17
+
18
+ -- Rename old table
19
+ ALTER TABLE rate_limits_old RENAME TO rate_limits;
Original file line number Diff line number Diff line change
1
+
2
+ -- Update rate_limits table
3
+ ALTER TABLE rate_limits ADD COLUMN IF NOT EXISTS last_reset DATETIME DEFAULT CURRENT_TIMESTAMP ;
4
+
5
+ -- Create github_users table
6
+ CREATE TABLE IF NOT EXISTS github_users (
7
+ username TEXT PRIMARY KEY ,
8
+ followers INTEGER DEFAULT 0 ,
9
+ following INTEGER DEFAULT 0 ,
10
+ last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
11
+ );
12
+
13
+ -- Create temporary table for rate_limits
14
+ CREATE TABLE IF NOT EXISTS rate_limits_new (
15
+ ip TEXT PRIMARY KEY ,
16
+ requests INTEGER DEFAULT 0 ,
17
+ last_reset DATETIME DEFAULT CURRENT_TIMESTAMP
18
+ );
19
+
20
+ -- Copy data from old table
21
+ INSERT INTO rate_limits_new (ip, requests)
22
+ SELECT ip, requests FROM rate_limits;
23
+
24
+ -- Drop old table
25
+ DROP TABLE rate_limits;
26
+
27
+ -- Rename new table
28
+ ALTER TABLE rate_limits_new RENAME TO rate_limits;
Original file line number Diff line number Diff line change
1
+ -- Create migrations table
2
+ CREATE TABLE IF NOT EXISTS _migrations (
3
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
4
+ name TEXT NOT NULL ,
5
+ applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
6
+ );
7
+
8
+ -- Create rate limits table
9
+ CREATE TABLE IF NOT EXISTS rate_limits (
10
+ ip TEXT PRIMARY KEY ,
11
+ requests INTEGER DEFAULT 0 ,
12
+ last_reset DATETIME DEFAULT CURRENT_TIMESTAMP
13
+ );
14
+
15
+ -- Create github users table
16
+ CREATE TABLE IF NOT EXISTS github_users (
17
+ username TEXT PRIMARY KEY ,
18
+ followers INTEGER DEFAULT 0 ,
19
+ following INTEGER DEFAULT 0 ,
20
+ last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
21
+ );
22
+
23
+ -- Create visitors table with last_updated column
24
+ CREATE TABLE IF NOT EXISTS visitors (
25
+ repo TEXT PRIMARY KEY ,
26
+ count INTEGER DEFAULT 0 ,
27
+ last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
28
+ );
29
+
30
+ -- Record migration
31
+ INSERT INTO _migrations (name) VALUES (' 0000_init' );
Original file line number Diff line number Diff line change
1
+
2
+ CREATE TABLE IF NOT EXISTS _migrations (
3
+ id INTEGER PRIMARY KEY ,
4
+ name TEXT NOT NULL ,
5
+ applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
6
+ );
Original file line number Diff line number Diff line change
1
+
2
+ -- Initialize migrations tracking
3
+ CREATE TABLE IF NOT EXISTS _migrations (
4
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
5
+ name TEXT NOT NULL ,
6
+ applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
7
+ );
8
+
9
+ -- Record this migration
10
+ INSERT INTO _migrations (name) VALUES (' 0000_init_migrations' );
Original file line number Diff line number Diff line change
1
+
2
+ -- Record this migration
3
+ INSERT INTO _migrations (name) VALUES (' 0001_add_user_tracking' );
4
+
5
+ -- Create initial tables if they don't exist
6
+ CREATE TABLE IF NOT EXISTS rate_limits (
7
+ ip TEXT PRIMARY KEY ,
8
+ requests INTEGER DEFAULT 0 ,
9
+ last_reset DATETIME DEFAULT CURRENT_TIMESTAMP
10
+ );
11
+
12
+ CREATE TABLE IF NOT EXISTS github_users (
13
+ username TEXT PRIMARY KEY ,
14
+ followers INTEGER DEFAULT 0 ,
15
+ following INTEGER DEFAULT 0 ,
16
+ last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
17
+ );
18
+
19
+ CREATE TABLE IF NOT EXISTS visitors (
20
+ repo TEXT PRIMARY KEY ,
21
+ count INTEGER DEFAULT 0
22
+ );
Original file line number Diff line number Diff line change
1
+
2
+ -- Add migrations record
3
+ INSERT INTO _migrations (name) VALUES (' 0001_add_user_tracking' );
4
+
5
+ -- Update rate_limits table
6
+ ALTER TABLE rate_limits ADD COLUMN IF NOT EXISTS last_reset DATETIME DEFAULT CURRENT_TIMESTAMP ;
7
+
8
+ -- Create github_users table
9
+ CREATE TABLE IF NOT EXISTS github_users (
10
+ username TEXT PRIMARY KEY ,
11
+ followers INTEGER DEFAULT 0 ,
12
+ following INTEGER DEFAULT 0 ,
13
+ last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
14
+ );
15
+
16
+ -- Create temporary table for rate_limits
17
+ CREATE TABLE IF NOT EXISTS rate_limits_new (
18
+ ip TEXT PRIMARY KEY ,
19
+ requests INTEGER DEFAULT 0 ,
20
+ last_reset DATETIME DEFAULT CURRENT_TIMESTAMP
21
+ );
22
+
23
+ -- Copy data from old table
24
+ INSERT INTO rate_limits_new (ip, requests)
25
+ SELECT ip, requests FROM rate_limits;
26
+
27
+ -- Drop old table
28
+ DROP TABLE rate_limits;
29
+
30
+ -- Rename new table
31
+ ALTER TABLE rate_limits_new RENAME TO rate_limits;
Original file line number Diff line number Diff line change
1
+ -- Record this migration
2
+ INSERT INTO _migrations (name) VALUES (' 0002_add_last_updated' );
3
+
4
+ -- Create temporary table with desired schema
5
+ CREATE TABLE visitors_new (
6
+ repo TEXT PRIMARY KEY ,
7
+ count INTEGER DEFAULT 0 ,
8
+ last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
9
+ );
10
+
11
+ -- Copy existing data with current timestamp
12
+ INSERT INTO visitors_new (repo, count, last_updated)
13
+ SELECT repo, count, CURRENT_TIMESTAMP
14
+ FROM visitors;
15
+
16
+ -- Drop old table
17
+ DROP TABLE visitors;
18
+
19
+ -- Rename new table to original name
20
+ ALTER TABLE visitors_new RENAME TO visitors;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " github-profile-views-counter" ,
3
+ "scripts" : {
4
+ "dev" : " wrangler dev" ,
5
+ "deploy" : " wrangler deploy --minify"
6
+ },
7
+ "dependencies" : {
8
+ "hono" : " ^4.6.12"
9
+ },
10
+ "devDependencies" : {
11
+ "@cloudflare/workers-types" : " ^4.20241112.0" ,
12
+ "wrangler" : " ^3.88.0"
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments