nurev 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@
13
13
  "jsonwebtoken": "^9.0.3",
14
14
  "nuxt": "^4.4.2",
15
15
  "pocketbase": "^0.26.8",
16
- "vue": "^3.5.30",
16
+ "vue": "^3.5.31",
17
17
  "vue-router": "^5.0.4"
18
18
  },
19
19
  "devDependencies": {
@@ -47,33 +47,23 @@ Tech stack:
47
47
  NUXT_JWT_SECRET=secretjwt
48
48
  ```
49
49
 
50
- 2. Create symbolic links for the environment variables with
51
-
52
- ```bash
53
- make setup
54
- ```
55
-
56
- 3. Start backend dev mode
50
+ 2. Start backend dev mode
57
51
 
58
52
  ```bash
59
53
  make backend-dev
60
54
  ```
61
55
 
62
- 4. Open [http://localhost:8090](`http://localhost:8090/_/) and create a superuser
63
-
64
- 5. Create a user inside `users` collection with the same values inside `NUXT_POCKETBASE_USER` and `NUXT_POCKETBASE_PASSWORD`
65
-
66
- 6. Create a collection named `posts` and change API Rules for give permissions with `@request.auth.id != ""`
56
+ 3. Create a collection named `posts` and change API Rules for give permissions with `@request.auth.id != ""`
67
57
 
68
- 7. Create a new post
58
+ 4. Create a new post
69
59
 
70
- 8. Start frontend dev mode
60
+ 5. Start frontend dev mode
71
61
 
72
62
  ```bash
73
63
  make frontend-dev
74
64
  ```
75
65
 
76
- 8. Open `http://localhost:3000/posts/[id]` and replace `[id]` with the post id created in the 6. step
66
+ 6. Open `http://localhost:3000/posts/[id]` and replace `[id]` with the post id created in the 6. step
77
67
 
78
68
  ## Build
79
69
 
@@ -5,7 +5,7 @@ go 1.25.0
5
5
  require (
6
6
  github.com/golang-jwt/jwt/v5 v5.3.1
7
7
  github.com/joho/godotenv v1.5.1
8
- github.com/pocketbase/pocketbase v0.36.7
8
+ github.com/pocketbase/pocketbase v0.36.8
9
9
  )
10
10
 
11
11
  require (
@@ -13,7 +13,7 @@ require (
13
13
  github.com/disintegration/imaging v1.6.2 // indirect
14
14
  github.com/domodwyer/mailyak/v3 v3.6.2 // indirect
15
15
  github.com/dustin/go-humanize v1.0.1 // indirect
16
- github.com/fatih/color v1.18.0 // indirect
16
+ github.com/fatih/color v1.19.0 // indirect
17
17
  github.com/gabriel-vasile/mimetype v1.4.13 // indirect
18
18
  github.com/ganigeorgiev/fexpr v0.5.0 // indirect
19
19
  github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
@@ -29,7 +29,7 @@ require (
29
29
  github.com/spf13/cobra v1.10.2 // indirect
30
30
  github.com/spf13/pflag v1.0.10 // indirect
31
31
  golang.org/x/crypto v0.49.0 // indirect
32
- golang.org/x/image v0.37.0 // indirect
32
+ golang.org/x/image v0.38.0 // indirect
33
33
  golang.org/x/net v0.52.0 // indirect
34
34
  golang.org/x/oauth2 v0.36.0 // indirect
35
35
  golang.org/x/sync v0.20.0 // indirect
@@ -38,5 +38,5 @@ require (
38
38
  modernc.org/libc v1.70.0 // indirect
39
39
  modernc.org/mathutil v1.7.1 // indirect
40
40
  modernc.org/memory v1.11.0 // indirect
41
- modernc.org/sqlite v1.46.2 // indirect
41
+ modernc.org/sqlite v1.48.0 // indirect
42
42
  )
@@ -12,6 +12,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
12
12
  github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
13
13
  github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
14
14
  github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
15
+ github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
16
+ github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
15
17
  github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
16
18
  github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
17
19
  github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
@@ -53,6 +55,8 @@ github.com/pocketbase/dbx v1.12.0 h1:/oLErM+A0b4xI0PWTGPqSDVjzix48PqI/bng2l0PzoA
53
55
  github.com/pocketbase/dbx v1.12.0/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
54
56
  github.com/pocketbase/pocketbase v0.36.7 h1:MrViB7BptPYrf2Nt25pJEYBqUdFjuhRKu1p5GTrkvPA=
55
57
  github.com/pocketbase/pocketbase v0.36.7/go.mod h1:qX4HuVjoKXtEg41fSJVM0JLfGWXbBmHxVv/FaE446r4=
58
+ github.com/pocketbase/pocketbase v0.36.8 h1:gCNqoesZ44saYOD3J7edhi5nDwUWKyQG7boM/kVwz2c=
59
+ github.com/pocketbase/pocketbase v0.36.8/go.mod h1:OY4WaXbP0WnF/EXoBbboWJK+ZSZ1A85tiA0sjrTKxTA=
56
60
  github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
57
61
  github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
58
62
  github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
@@ -75,6 +79,8 @@ golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtC
75
79
  golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
76
80
  golang.org/x/image v0.37.0 h1:ZiRjArKI8GwxZOoEtUfhrBtaCN+4b/7709dlT6SSnQA=
77
81
  golang.org/x/image v0.37.0/go.mod h1:/3f6vaXC+6CEanU4KJxbcUZyEePbyKbaLoDOe4ehFYY=
82
+ golang.org/x/image v0.38.0 h1:5l+q+Y9JDC7mBOMjo4/aPhMDcxEptsX+Tt3GgRQRPuE=
83
+ golang.org/x/image v0.38.0/go.mod h1:/3f6vaXC+6CEanU4KJxbcUZyEePbyKbaLoDOe4ehFYY=
78
84
  golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
79
85
  golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
80
86
  golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
@@ -124,6 +130,8 @@ modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
124
130
  modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
125
131
  modernc.org/sqlite v1.46.2 h1:gkXQ6R0+AjxFC/fTDaeIVLbNLNrRoOK7YYVz5BKhTcE=
126
132
  modernc.org/sqlite v1.46.2/go.mod h1:hWjRO6Tj/5Ik8ieqxQybiEOUXy0NJFNp2tpvVpKlvig=
133
+ modernc.org/sqlite v1.48.0 h1:ElZyLop3Q2mHYk5IFPPXADejZrlHu7APbpB0sF78bq4=
134
+ modernc.org/sqlite v1.48.0/go.mod h1:hWjRO6Tj/5Ik8ieqxQybiEOUXy0NJFNp2tpvVpKlvig=
127
135
  modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
128
136
  modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
129
137
  modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
@@ -1,4 +1,4 @@
1
- .PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
1
+ .PHONY: all backend-build backend-update backend-dev backend-run backend-setup backend-superuser \
2
2
  frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
3
3
  help setup build install
4
4
 
@@ -26,6 +26,10 @@ backend-dev: backend-update
26
26
  backend-run: backend-build
27
27
  @echo "Running backend..."
28
28
  cd backend && ./backend serve
29
+
30
+ backend-superuser: backend-update
31
+ @echo "Adding superuser..."
32
+ cd backend && go run . superuser create $(email) $(password)
29
33
 
30
34
  # Frontend targets
31
35
  frontend-setup:
@@ -64,6 +68,7 @@ help:
64
68
  @echo " make backend-dev - Run the backend development only"
65
69
  @echo " make backend-run - Run the backend only"
66
70
  @echo " make backend-update - Update backend dependencies"
71
+ @echo " make backend-superuser email=test@test.com password=123 - Add a new superuser"
67
72
  @echo " make frontend-setup - Create a symbolic link for frontend"
68
73
  @echo " make frontend-install - Install frontend dependencies"
69
74
  @echo " make frontend-dev - Start frontend development server"
@@ -1,4 +1,4 @@
1
- .PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
1
+ .PHONY: all backend-build backend-update backend-dev backend-run backend-setup backend-superuser \
2
2
  frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
3
3
  help setup build install
4
4
 
@@ -27,6 +27,9 @@ backend-run: backend-build
27
27
  @echo "Running backend..."
28
28
  cd backend && ./backend serve
29
29
 
30
+ backend-superuser: backend-update
31
+ @echo "Adding superuser..."
32
+ cd backend && go run . superuser create $(email) $(password)
30
33
  # Frontend targets
31
34
  frontend-setup:
32
35
  @echo "Preparing frontend..."
@@ -64,6 +67,7 @@ help:
64
67
  @echo " make backend-dev - Run the backend development only"
65
68
  @echo " make backend-run - Run the backend only"
66
69
  @echo " make backend-update - Update backend dependencies"
70
+ @echo " make backend-superuser email=test@test.com password=123 - Add a new superuser"
67
71
  @echo " make frontend-setup - Create a symbolic link for frontend"
68
72
  @echo " make frontend-install - Install frontend dependencies"
69
73
  @echo " make frontend-dev - Start frontend development server"
@@ -1,4 +1,4 @@
1
- .PHONY: all backend-build backend-update backend-dev backend-run backend-setup \
1
+ .PHONY: all backend-build backend-update backend-dev backend-run backend-setup backend-superuser \
2
2
  frontend-install frontend-dev frontend-build frontend-preview frontend-setup\
3
3
  help setup build install
4
4
 
@@ -27,6 +27,10 @@ backend-run: backend-build
27
27
  @echo "Running backend..."
28
28
  cd backend && ./backend serve
29
29
 
30
+ backend-superuser: backend-update
31
+ @echo "Adding superuser..."
32
+ cd backend && go run . superuser create $(email) $(password)
33
+
30
34
  # Frontend targets
31
35
  frontend-setup:
32
36
  @echo "Preparing frontend..."
@@ -64,6 +68,7 @@ help:
64
68
  @echo " make backend-dev - Run the backend development only"
65
69
  @echo " make backend-run - Run the backend only"
66
70
  @echo " make backend-update - Update backend dependencies"
71
+ @echo " make backend-superuser email=test@test.com password=123 - Add a new superuser"
67
72
  @echo " make frontend-setup - Create a symbolic link for frontend"
68
73
  @echo " make frontend-install - Install frontend dependencies"
69
74
  @echo " make frontend-dev - Start frontend development server"
@@ -0,0 +1,33 @@
1
+ import Database from "better-sqlite3";
2
+
3
+ export class SQLiteManager {
4
+ constructor(filePath) {
5
+ this.db = new Database(filePath);
6
+ }
7
+
8
+ create(name, params) {
9
+ return new Promise(async (resolve, reject) => {
10
+ try {
11
+ this.db.exec(
12
+ `CREATE TABLE IF NOT EXIST ${name} (${params.toString()})`,
13
+ );
14
+ resolve();
15
+ } catch (error) {
16
+ reject(error);
17
+ }
18
+ });
19
+ }
20
+
21
+ insert(name, values) {
22
+ return new Promise(async (resolve, reject) => {
23
+ try {
24
+ this.db.exec(
25
+ `INSERT INTO ${name} (${Object.keys(values).toString()}) VALUES (${Object.values(values).toString()})`,
26
+ );
27
+ resolve();
28
+ } catch (error) {
29
+ reject(error);
30
+ }
31
+ });
32
+ }
33
+ }
@@ -0,0 +1,86 @@
1
+ import { default as prompts } from "prompts";
2
+ import { writeEnvFile } from "../../utils/file.js";
3
+ import { spawnPromise } from "../../utils/cmd.js";
4
+ import { SQLiteManager } from "../../utils/sqlite.js";
5
+ import { default as bcrypt } from "bcrypt";
6
+
7
+ const questions = [
8
+ {
9
+ type: "text",
10
+ name: "admin",
11
+ message: "Email address to assign to the Pocketbase superuser",
12
+ },
13
+ {
14
+ type: "text",
15
+ style: "password",
16
+ name: "adminpassword",
17
+ message: "Password for superuser",
18
+ validate: (password) =>
19
+ password.length > 7 ? true : `8 characters needed or more`,
20
+ },
21
+ {
22
+ type: "text",
23
+ name: "user",
24
+ message: "Email for the API user",
25
+ },
26
+ {
27
+ type: "text",
28
+ style: "password",
29
+ name: "userpassword",
30
+ message: "Password for API user",
31
+ validate: (userpassword) =>
32
+ userpassword.length > 7 ? true : `8 characters needed or more`,
33
+ },
34
+ ];
35
+
36
+ export function setup(paths) {
37
+ return new Promise(async (resolve, reject) => {
38
+ try {
39
+ console.log(`\n Pocketbase selected \n`);
40
+ const responsePocketbase = await prompts(questions);
41
+
42
+ if (
43
+ Object.keys(questions).length !== Object.keys(responsePocketbase).length
44
+ ) {
45
+ reject(new Error("Questions not completed"));
46
+ }
47
+
48
+ await writeEnvFile(paths.destination.env, {
49
+ NUXT_POCKETBASE_USER: responsePocketbase.user,
50
+ NUXT_POCKETBASE_PASSWORD: responsePocketbase.userpassword,
51
+ NUXT_JWT_SECRET: Buffer.from(
52
+ crypto.getRandomValues(new Uint8Array(32)),
53
+ ).toString("hex"),
54
+ });
55
+
56
+ await spawnPromise("make", [
57
+ "-s",
58
+ "backend-superuser",
59
+ `email=${responsePocketbase.admin}`,
60
+ `password=${responsePocketbase.adminpassword}`,
61
+ ]);
62
+
63
+ const hash = bcrypt.hashSync(responsePocketbase.userpassword, 12);
64
+ const db = new SQLiteManager(
65
+ paths.destination.base + "/backend/pb_data/data.db",
66
+ );
67
+ const date = new Date().toISOString().replace("T", " ");
68
+
69
+ await db.insert("users", {
70
+ created: `'${date}'`,
71
+ email: `'${responsePocketbase.user}'`,
72
+ emailVisibility: false,
73
+ password: `'${hash}'`,
74
+ updated: `'${date}'`,
75
+ verified: false,
76
+ });
77
+
78
+ console.log(`\nUser API created\n`);
79
+
80
+ //TODO: POSTS TABLE
81
+ resolve();
82
+ } catch (error) {
83
+ reject(error);
84
+ }
85
+ });
86
+ }