postbase 0.1.0

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.
Files changed (126) hide show
  1. package/.github/workflows/test.yml +74 -0
  2. package/CLA.md +60 -0
  3. package/CONTRIBUTORS.md +35 -0
  4. package/LICENSE +661 -0
  5. package/README.md +211 -0
  6. package/admin/404.html +33 -0
  7. package/admin/README.md +21 -0
  8. package/admin/index.html +15 -0
  9. package/admin/jsconfig.json +20 -0
  10. package/admin/lib/postbase.js +222 -0
  11. package/admin/package-lock.json +3746 -0
  12. package/admin/package.json +27 -0
  13. package/admin/public/assets/img/admin-ui.png +0 -0
  14. package/admin/public/assets/img/blank-profile-picture-960_720.webp +0 -0
  15. package/admin/public/assets/img/chart-active-users.png +0 -0
  16. package/admin/public/assets/img/icon-transparent.png +0 -0
  17. package/admin/src/App.jsx +48 -0
  18. package/admin/src/auth.js +11 -0
  19. package/admin/src/common/formatDateTime.js +18 -0
  20. package/admin/src/components/AuthPanel.jsx +88 -0
  21. package/admin/src/components/Header.jsx +67 -0
  22. package/admin/src/main.jsx +6 -0
  23. package/admin/src/pages/Dashboard.jsx +24 -0
  24. package/admin/src/pages/Home.jsx +52 -0
  25. package/admin/src/pages/Login.jsx +10 -0
  26. package/admin/src/pages/authentication/Users.jsx +199 -0
  27. package/admin/src/pages/firestore/Database.jsx +29 -0
  28. package/admin/src/pages/storage/files.jsx +29 -0
  29. package/admin/src/postbase.js +15 -0
  30. package/admin/src/styles.css +3 -0
  31. package/admin/tailwind.config.cjs +11 -0
  32. package/admin/template.env +2 -0
  33. package/admin/vite.config.js +21 -0
  34. package/assets/img/HomePageScreenshot.png +0 -0
  35. package/assets/img/better-auth-logo-dark.136b122f.png +0 -0
  36. package/assets/img/better-auth-logo-light.4b03f444.png +0 -0
  37. package/assets/img/expresjs.png +0 -0
  38. package/assets/img/icon-transparent.png +0 -0
  39. package/assets/img/icon.png +0 -0
  40. package/assets/img/letsencrypt-logo-horizontal.png +0 -0
  41. package/assets/img/logo.png +0 -0
  42. package/assets/img/node.js_logo.png +0 -0
  43. package/assets/img/nodejsLight.svg +39 -0
  44. package/assets/img/postgres.png +0 -0
  45. package/backend/README.md +49 -0
  46. package/backend/admin/auth.js +9 -0
  47. package/backend/app.js +68 -0
  48. package/backend/auth.js +92 -0
  49. package/backend/env.js +12 -0
  50. package/backend/lib/postbase/adminClient.js +520 -0
  51. package/backend/lib/postbase/compat/admin.js +44 -0
  52. package/backend/lib/postbase/db.js +17 -0
  53. package/backend/lib/postbase/genericRouter.js +603 -0
  54. package/backend/lib/postbase/local-storage.js +56 -0
  55. package/backend/lib/postbase/metadataCache.js +32 -0
  56. package/backend/lib/postbase/middlewares/auth.js +57 -0
  57. package/backend/lib/postbase/migrations/1765239687559_rtdb-nodes.js +93 -0
  58. package/backend/lib/postbase/package-lock.json +5873 -0
  59. package/backend/lib/postbase/package.json +19 -0
  60. package/backend/lib/postbase/rtdb/router.js +190 -0
  61. package/backend/lib/postbase/rtdb/rulesEngine.js +63 -0
  62. package/backend/lib/postbase/rtdb/ws.js +84 -0
  63. package/backend/lib/postbase/rulesEngine.js +62 -0
  64. package/backend/lib/postbase/storage.js +130 -0
  65. package/backend/lib/postbase/tests/README.md +22 -0
  66. package/backend/lib/postbase/tests/db.js +9 -0
  67. package/backend/lib/postbase/tests/rtdb.rest.test.js +46 -0
  68. package/backend/lib/postbase/tests/rtdb.ws.test.js +113 -0
  69. package/backend/lib/postbase/tests/rules.js +26 -0
  70. package/backend/lib/postbase/tests/testServer.js +46 -0
  71. package/backend/lib/postbase/websocket.js +131 -0
  72. package/backend/local.js +6 -0
  73. package/backend/main.js +20 -0
  74. package/backend/middlewares/auth_middleware.js +10 -0
  75. package/backend/migrations/1762137399366-init.sql +98 -0
  76. package/backend/migrations/1762137399367_init_jsonb_schema.js +68 -0
  77. package/backend/migrations/1762149999999_enable_realtime_changes.js +48 -0
  78. package/backend/migrations/1765224247654_rtdb-nodes.js +93 -0
  79. package/backend/package-lock.json +2374 -0
  80. package/backend/package.json +27 -0
  81. package/backend/postbase_db_rules.js +128 -0
  82. package/backend/postbase_rtdb_rules.js +27 -0
  83. package/backend/postbase_storage_rules.js +45 -0
  84. package/backend/template.env +10 -0
  85. package/backend-systemd/README.md +39 -0
  86. package/backend-systemd/your_website.com.service +12 -0
  87. package/frontend/404.html +33 -0
  88. package/frontend/README.md +25 -0
  89. package/frontend/index.html +15 -0
  90. package/frontend/jsconfig.json +20 -0
  91. package/frontend/lib/postbase/auth.js +132 -0
  92. package/frontend/lib/postbase/compat/firebase/app.js +3 -0
  93. package/frontend/lib/postbase/compat/firebase/auth.js +115 -0
  94. package/frontend/lib/postbase/compat/firebase/database.js +11 -0
  95. package/frontend/lib/postbase/compat/firebase/firestore/lite.js +61 -0
  96. package/frontend/lib/postbase/compat/firebase/storage.js +10 -0
  97. package/frontend/lib/postbase/db.js +657 -0
  98. package/frontend/lib/postbase/package-lock.json +6284 -0
  99. package/frontend/lib/postbase/package.json +17 -0
  100. package/frontend/lib/postbase/rtdb.js +108 -0
  101. package/frontend/lib/postbase/storage.js +293 -0
  102. package/frontend/lib/postbase/tests/rtdb.client.test.js +88 -0
  103. package/frontend/lib/postbase/tests/waitFor.js +13 -0
  104. package/frontend/lib/postbase/utils.js +1 -0
  105. package/frontend/package-lock.json +2977 -0
  106. package/frontend/package.json +24 -0
  107. package/frontend/src/App.jsx +38 -0
  108. package/frontend/src/auth.js +52 -0
  109. package/frontend/src/components/AuthPanel.jsx +85 -0
  110. package/frontend/src/components/Header.jsx +54 -0
  111. package/frontend/src/main.jsx +5 -0
  112. package/frontend/src/pages/Dashboard.jsx +24 -0
  113. package/frontend/src/pages/Home.jsx +178 -0
  114. package/frontend/src/pages/Login.jsx +10 -0
  115. package/frontend/src/postbase.js +14 -0
  116. package/frontend/src/styles.css +1 -0
  117. package/frontend/tailwind.config.cjs +11 -0
  118. package/frontend/template.env +2 -0
  119. package/frontend/vite.config.js +18 -0
  120. package/git/hooks/README.md +31 -0
  121. package/git/hooks/post-receive +26 -0
  122. package/nginx/README.md +84 -0
  123. package/nginx/apt/www.your_website.com.conf +80 -0
  124. package/nginx/homebrew/www.your_website.com.conf +80 -0
  125. package/nginx/letsencrypt/README +14 -0
  126. package/package.json +8 -0
@@ -0,0 +1,74 @@
1
+ name: Jest Supertest CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - develop
8
+ pull_request:
9
+ branches:
10
+ - main
11
+ - develop
12
+
13
+ jobs:
14
+ test:
15
+ name: Run Jest Supertest Tests
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ matrix:
19
+ node-version: [24]
20
+
21
+ services:
22
+ postgres:
23
+ image: postgres
24
+ env:
25
+ POSTGRES_USER: testuser
26
+ POSTGRES_PASSWORD: testpassword
27
+ POSTGRES_DB: postgres
28
+ ports:
29
+ - 5432:5432
30
+ options: >-
31
+ --health-cmd pg_isready
32
+ --health-interval 10s
33
+ --health-timeout 5s
34
+ --health-retries 5
35
+
36
+ steps:
37
+ - name: Checkout repository
38
+ run: |
39
+ git clone "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git" .
40
+ git checkout ${{ github.sha }}
41
+
42
+ # -------------------------------------------------------
43
+ # backend/lib/postbase
44
+ # -------------------------------------------------------
45
+ - name: "[backend] Install dependencies"
46
+ run: cd backend/lib/postbase && npm ci
47
+ env:
48
+ NODE_OPTIONS: --experimental-vm-modules
49
+
50
+ - name: "[backend] Create test database"
51
+ run: psql -h localhost -U testuser -d postgres -c "CREATE DATABASE postbase_testdb;"
52
+ env:
53
+ PGPASSWORD: testpassword
54
+
55
+ - name: "[backend] Run migrations"
56
+ run: cd backend/lib/postbase && npx node-pg-migrate up
57
+ env:
58
+ DATABASE_URL: postgresql://testuser:testpassword@localhost:5432/postbase_testdb
59
+ TEST_DB_URL: postgresql://testuser:testpassword@localhost:5432/postbase_testdb
60
+
61
+ - name: "[backend] Run Jest tests"
62
+ run: cd backend/lib/postbase && npm test -- --coverage
63
+ env:
64
+ NODE_ENV: test
65
+ NODE_OPTIONS: --experimental-vm-modules
66
+ DATABASE_URL: postgresql://testuser:testpassword@localhost:5432/postbase_testdb
67
+ TEST_DB_URL: postgresql://testuser:testpassword@localhost:5432/postbase_testdb
68
+ PGDATABASE: postbase_testdb
69
+
70
+ - name: "[backend] Save coverage report"
71
+ run: |
72
+ mkdir -p /tmp/coverage-backend
73
+ cp -r backend/lib/postbase/coverage/. /tmp/coverage-backend/
74
+ echo "Coverage saved to runner at /tmp/coverage-backend"
package/CLA.md ADDED
@@ -0,0 +1,60 @@
1
+ # Contributor License Agreement (CLA)
2
+
3
+ Thank you for your interest in contributing to postbase (the "Project").
4
+
5
+ To clarify the intellectual property rights in contributions to the Project, we require all contributors to sign this Contributor License Agreement ("CLA").
6
+
7
+ ## Agreement
8
+
9
+ By signing this CLA, you agree to the following terms:
10
+
11
+ ### 1. Definitions
12
+
13
+ - **"You"** means the individual or legal entity making this agreement.
14
+ - **"Contribution"** means any original work of authorship, including any modifications or additions to existing work, that you submit to the Project.
15
+ - **"Submit"** means any form of communication sent to the Project, including but not limited to code, documentation, or other materials submitted via pull request, email, or issue tracker.
16
+
17
+ ### 2. Grant of Copyright License
18
+
19
+ You hereby grant to Umair Ashraf and to recipients of software distributed by the Project a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevovable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute your Contributions and such derivative works.
20
+
21
+ ### 3. Grant of Patent License
22
+
23
+ You hereby grant to Umair Ashraf and to recipients of software distributed by the Project a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the work, where such license applies only to those patent claims licensable by you that are necessarily infringed by your Contribution(s) alone or by combination of your Contribution(s) with the work to which such Contribution(s) was submitted.
24
+
25
+ ### 4. Representations
26
+
27
+ You represent that:
28
+
29
+ - You are legally entitled to grant the above licenses.
30
+ - Each of your Contributions is your original creation (or you have rights to submit it under this CLA).
31
+ - Your Contribution submissions include complete details of any third-party license or other restriction of which you are aware.
32
+ - If your employer has rights to intellectual property that you create, you represent that you have received permission to make the Contributions on behalf of that employer, or that your employer has waived such rights.
33
+
34
+ ### 5. Support
35
+
36
+ You are not expected to provide support for your Contributions, except to the extent you desire to provide support. You may provide support for free, for a fee, or not at all.
37
+
38
+ ### 6. Disclaimer
39
+
40
+ UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, YOU PROVIDE YOUR CONTRIBUTIONS ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
41
+
42
+ ---
43
+
44
+ ## How to Sign
45
+
46
+ Please add your name to the [CONTRIBUTORS.md](CONTRIBUTORS.md) file by submitting a pull request with the following information:
47
+
48
+ - [Your Full Name], [Email], [Date in YYYY-MM-DD format]
49
+ - GitHub: @yourusername
50
+ - Statement: "I agree to the CLA as outlined in CLA.md"
51
+
52
+ By adding your name to CONTRIBUTORS.md, you certify that you have read and agree to the terms of this CLA.
53
+
54
+ ---
55
+
56
+ **Note for Corporate Contributors**: If you are contributing on behalf of your employer, your employer must also agree to this CLA. Please have an authorized representative of your employer add the company name and their signature to CONTRIBUTORS.md.
57
+
58
+ ---
59
+
60
+ **Questions?** Contact umair@ashraf.riamumail.com if you have questions about this CLA.
@@ -0,0 +1,35 @@
1
+ # Contributors
2
+
3
+ This file lists all contributors who have signed the Contributor License Agreement (CLA) as outlined in [CLA.md](CLA.md).
4
+
5
+ By adding your name below, you certify that you have read and agree to the terms of the CLA.
6
+
7
+ ---
8
+
9
+ ## Individual Contributors
10
+
11
+ - [Your Name], [your.email@example.com], 2024-05-10
12
+ - GitHub: @yourusername
13
+ - Statement: "I agree to the CLA as outlined in CLA.md"
14
+
15
+ <!-- Add your entry above this line in alphabetical order by last name -->
16
+
17
+ ---
18
+
19
+ ## Corporate Contributors
20
+
21
+ Corporate contributors whose employees have contributed to this project:
22
+
23
+ - **Company Name**, Authorized by: [Representative Name], [Date]
24
+ - Contact: [email@company.com]
25
+ - Statement: "On behalf of Company Name, I agree to the CLA as outlined in CLA.md for all contributions made by our employees"
26
+
27
+ <!-- Add corporate entries above this line in alphabetical order by company name -->
28
+
29
+ ---
30
+
31
+ ## Notes
32
+
33
+ - Date format: YYYY-MM-DD
34
+ - Please keep entries in alphabetical order by last name (individuals) or company name (corporate)
35
+ - For corporate contributors, all employee contributions fall under the corporate CLA