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.
- package/.github/workflows/test.yml +74 -0
- package/CLA.md +60 -0
- package/CONTRIBUTORS.md +35 -0
- package/LICENSE +661 -0
- package/README.md +211 -0
- package/admin/404.html +33 -0
- package/admin/README.md +21 -0
- package/admin/index.html +15 -0
- package/admin/jsconfig.json +20 -0
- package/admin/lib/postbase.js +222 -0
- package/admin/package-lock.json +3746 -0
- package/admin/package.json +27 -0
- package/admin/public/assets/img/admin-ui.png +0 -0
- package/admin/public/assets/img/blank-profile-picture-960_720.webp +0 -0
- package/admin/public/assets/img/chart-active-users.png +0 -0
- package/admin/public/assets/img/icon-transparent.png +0 -0
- package/admin/src/App.jsx +48 -0
- package/admin/src/auth.js +11 -0
- package/admin/src/common/formatDateTime.js +18 -0
- package/admin/src/components/AuthPanel.jsx +88 -0
- package/admin/src/components/Header.jsx +67 -0
- package/admin/src/main.jsx +6 -0
- package/admin/src/pages/Dashboard.jsx +24 -0
- package/admin/src/pages/Home.jsx +52 -0
- package/admin/src/pages/Login.jsx +10 -0
- package/admin/src/pages/authentication/Users.jsx +199 -0
- package/admin/src/pages/firestore/Database.jsx +29 -0
- package/admin/src/pages/storage/files.jsx +29 -0
- package/admin/src/postbase.js +15 -0
- package/admin/src/styles.css +3 -0
- package/admin/tailwind.config.cjs +11 -0
- package/admin/template.env +2 -0
- package/admin/vite.config.js +21 -0
- package/assets/img/HomePageScreenshot.png +0 -0
- package/assets/img/better-auth-logo-dark.136b122f.png +0 -0
- package/assets/img/better-auth-logo-light.4b03f444.png +0 -0
- package/assets/img/expresjs.png +0 -0
- package/assets/img/icon-transparent.png +0 -0
- package/assets/img/icon.png +0 -0
- package/assets/img/letsencrypt-logo-horizontal.png +0 -0
- package/assets/img/logo.png +0 -0
- package/assets/img/node.js_logo.png +0 -0
- package/assets/img/nodejsLight.svg +39 -0
- package/assets/img/postgres.png +0 -0
- package/backend/README.md +49 -0
- package/backend/admin/auth.js +9 -0
- package/backend/app.js +68 -0
- package/backend/auth.js +92 -0
- package/backend/env.js +12 -0
- package/backend/lib/postbase/adminClient.js +520 -0
- package/backend/lib/postbase/compat/admin.js +44 -0
- package/backend/lib/postbase/db.js +17 -0
- package/backend/lib/postbase/genericRouter.js +603 -0
- package/backend/lib/postbase/local-storage.js +56 -0
- package/backend/lib/postbase/metadataCache.js +32 -0
- package/backend/lib/postbase/middlewares/auth.js +57 -0
- package/backend/lib/postbase/migrations/1765239687559_rtdb-nodes.js +93 -0
- package/backend/lib/postbase/package-lock.json +5873 -0
- package/backend/lib/postbase/package.json +19 -0
- package/backend/lib/postbase/rtdb/router.js +190 -0
- package/backend/lib/postbase/rtdb/rulesEngine.js +63 -0
- package/backend/lib/postbase/rtdb/ws.js +84 -0
- package/backend/lib/postbase/rulesEngine.js +62 -0
- package/backend/lib/postbase/storage.js +130 -0
- package/backend/lib/postbase/tests/README.md +22 -0
- package/backend/lib/postbase/tests/db.js +9 -0
- package/backend/lib/postbase/tests/rtdb.rest.test.js +46 -0
- package/backend/lib/postbase/tests/rtdb.ws.test.js +113 -0
- package/backend/lib/postbase/tests/rules.js +26 -0
- package/backend/lib/postbase/tests/testServer.js +46 -0
- package/backend/lib/postbase/websocket.js +131 -0
- package/backend/local.js +6 -0
- package/backend/main.js +20 -0
- package/backend/middlewares/auth_middleware.js +10 -0
- package/backend/migrations/1762137399366-init.sql +98 -0
- package/backend/migrations/1762137399367_init_jsonb_schema.js +68 -0
- package/backend/migrations/1762149999999_enable_realtime_changes.js +48 -0
- package/backend/migrations/1765224247654_rtdb-nodes.js +93 -0
- package/backend/package-lock.json +2374 -0
- package/backend/package.json +27 -0
- package/backend/postbase_db_rules.js +128 -0
- package/backend/postbase_rtdb_rules.js +27 -0
- package/backend/postbase_storage_rules.js +45 -0
- package/backend/template.env +10 -0
- package/backend-systemd/README.md +39 -0
- package/backend-systemd/your_website.com.service +12 -0
- package/frontend/404.html +33 -0
- package/frontend/README.md +25 -0
- package/frontend/index.html +15 -0
- package/frontend/jsconfig.json +20 -0
- package/frontend/lib/postbase/auth.js +132 -0
- package/frontend/lib/postbase/compat/firebase/app.js +3 -0
- package/frontend/lib/postbase/compat/firebase/auth.js +115 -0
- package/frontend/lib/postbase/compat/firebase/database.js +11 -0
- package/frontend/lib/postbase/compat/firebase/firestore/lite.js +61 -0
- package/frontend/lib/postbase/compat/firebase/storage.js +10 -0
- package/frontend/lib/postbase/db.js +657 -0
- package/frontend/lib/postbase/package-lock.json +6284 -0
- package/frontend/lib/postbase/package.json +17 -0
- package/frontend/lib/postbase/rtdb.js +108 -0
- package/frontend/lib/postbase/storage.js +293 -0
- package/frontend/lib/postbase/tests/rtdb.client.test.js +88 -0
- package/frontend/lib/postbase/tests/waitFor.js +13 -0
- package/frontend/lib/postbase/utils.js +1 -0
- package/frontend/package-lock.json +2977 -0
- package/frontend/package.json +24 -0
- package/frontend/src/App.jsx +38 -0
- package/frontend/src/auth.js +52 -0
- package/frontend/src/components/AuthPanel.jsx +85 -0
- package/frontend/src/components/Header.jsx +54 -0
- package/frontend/src/main.jsx +5 -0
- package/frontend/src/pages/Dashboard.jsx +24 -0
- package/frontend/src/pages/Home.jsx +178 -0
- package/frontend/src/pages/Login.jsx +10 -0
- package/frontend/src/postbase.js +14 -0
- package/frontend/src/styles.css +1 -0
- package/frontend/tailwind.config.cjs +11 -0
- package/frontend/template.env +2 -0
- package/frontend/vite.config.js +18 -0
- package/git/hooks/README.md +31 -0
- package/git/hooks/post-receive +26 -0
- package/nginx/README.md +84 -0
- package/nginx/apt/www.your_website.com.conf +80 -0
- package/nginx/homebrew/www.your_website.com.conf +80 -0
- package/nginx/letsencrypt/README +14 -0
- package/package.json +8 -0
package/nginx/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Nginx (Web Server)
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
### Homebrew (Mac)
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
brew install nginx
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## apt (Linux)
|
|
12
|
+
|
|
13
|
+
Installation instructions https://nginx.org/en/linux_packages.html#Ubuntu
|
|
14
|
+
|
|
15
|
+
## Map hosts to localhost
|
|
16
|
+
|
|
17
|
+
This is needed so locally when you visit your website, it will use your nginx.
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
sudo echo "127.0.0.1 your_website.com" >> /etc/hosts
|
|
21
|
+
sudo echo "127.0.0.1 www.your_website.com" >> /etc/hosts
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Let's Encrypt for HTTPS
|
|
25
|
+
|
|
26
|
+
### Homebrew (Mac)
|
|
27
|
+
|
|
28
|
+
Installation instructions https://certbot.eff.org/instructions?ws=other&os=osx
|
|
29
|
+
|
|
30
|
+
### apt (Linux)
|
|
31
|
+
|
|
32
|
+
Installation instructions https://certbot.eff.org/instructions?ws=other&os=pip
|
|
33
|
+
|
|
34
|
+
After installing the certbot, generate the certificates and private keys.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
cd nginx && rm -rf letsencrypt
|
|
38
|
+
sudo certbot certonly --manual --preferred-challenges dns-01 -d your_website.com -d www.your_website.com
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Enable Nginx
|
|
42
|
+
|
|
43
|
+
Configuring nginx varies based on whether you are using apt (Linux) or homebrew (Mac) package manager.
|
|
44
|
+
|
|
45
|
+
### Homebrew (Mac)
|
|
46
|
+
|
|
47
|
+
First, you must edit this file /Users/your_username/your_website/nginx/www.your_website.com.conf and fix names, paths, etc
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
cp /Users/your_username/your_website/nginx/www.your_website.com.conf /opt/homebrew/etc/nginx/services/
|
|
51
|
+
|
|
52
|
+
brew services restart nginx
|
|
53
|
+
brew services info nginx
|
|
54
|
+
|
|
55
|
+
tail /opt/homebrew/var/log/nginx/error.log
|
|
56
|
+
tail /opt/homebrew/var/log/nginx/access.log
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## apt (Linux)
|
|
60
|
+
|
|
61
|
+
This is different because when nginx is installed using apt, it runs with sudo.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
sudo mkdir /etc/ssl/certs/your_website
|
|
65
|
+
sudo cp nginx/letsencrypt/fullchain.pem /etc/ssl/certs/your_website
|
|
66
|
+
|
|
67
|
+
sudo mkdir /etc/ssl/private/your_website
|
|
68
|
+
sudo cp nginx/letsencrypt/privkey.pem /etc/ssl/private/your_website
|
|
69
|
+
|
|
70
|
+
mkdir /var/www/html/your_website
|
|
71
|
+
sudo cp -a frontend/dist/. /var/www/html/your_website
|
|
72
|
+
|
|
73
|
+
sudo cp nginx/apt/www.your_website.com.conf /etc/nginx/sites-available/
|
|
74
|
+
sudo ln -s /etc/nginx/sites-available/www.your_website.com.conf /etc/nginx/sites-enabled
|
|
75
|
+
|
|
76
|
+
nginx -t
|
|
77
|
+
|
|
78
|
+
sudo systemctl restart nginx
|
|
79
|
+
|
|
80
|
+
tail /var/log/nginx/error.log
|
|
81
|
+
tail /var/log/nginx/access.log
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Note you can skip running frontend server if you are using nginx.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Redirect all requests from http to https
|
|
2
|
+
server {
|
|
3
|
+
listen 80;
|
|
4
|
+
server_name your_website.com www.your_website.com;
|
|
5
|
+
return 301 https://www.your_website.com$request_uri;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
server {
|
|
9
|
+
listen 443 ssl;
|
|
10
|
+
server_name admin.your_website.com;
|
|
11
|
+
|
|
12
|
+
ssl_certificate /etc/ssl/certs/your_website/fullchain.pem;
|
|
13
|
+
ssl_certificate_key /etc/ssl/private/your_website/privkey.pem;
|
|
14
|
+
|
|
15
|
+
# Other SSL configurations (e.g., ciphers, protocols)
|
|
16
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
17
|
+
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
18
|
+
ssl_prefer_server_ciphers on;
|
|
19
|
+
|
|
20
|
+
root /var/www/html/your_website/admin;
|
|
21
|
+
index index.html;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Redirect https domain without www to https with www
|
|
25
|
+
server {
|
|
26
|
+
listen 443;
|
|
27
|
+
server_name your_website.com;
|
|
28
|
+
|
|
29
|
+
ssl_certificate /etc/ssl/certs/your_website/fullchain.pem;
|
|
30
|
+
ssl_certificate_key /etc/ssl/private/your_website/privkey.pem;
|
|
31
|
+
|
|
32
|
+
# Other SSL configurations (e.g., ciphers, protocols)
|
|
33
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
34
|
+
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
35
|
+
ssl_prefer_server_ciphers on;
|
|
36
|
+
|
|
37
|
+
return 301 https://www.your_website.com$request_uri;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Serve only https requests
|
|
41
|
+
server {
|
|
42
|
+
listen 443 ssl;
|
|
43
|
+
server_name www.your_website.com;
|
|
44
|
+
|
|
45
|
+
ssl_certificate /etc/ssl/certs/your_website/fullchain.pem;
|
|
46
|
+
ssl_certificate_key /etc/ssl/private/your_website/privkey.pem;
|
|
47
|
+
|
|
48
|
+
# Other SSL configurations (e.g., ciphers, protocols)
|
|
49
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
50
|
+
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
51
|
+
ssl_prefer_server_ciphers on;
|
|
52
|
+
|
|
53
|
+
root /var/www/html/your_website;
|
|
54
|
+
index index.html;
|
|
55
|
+
|
|
56
|
+
# Only enable if you want to serve an API from another process running on different port
|
|
57
|
+
# location /api/ {
|
|
58
|
+
# proxy_pass https://127.0.0.1:4431;
|
|
59
|
+
# proxy_set_header Host $host;
|
|
60
|
+
# proxy_set_header X-Real-IP $remote_addr;
|
|
61
|
+
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
62
|
+
# proxy_set_header X-Forwarded-Proto $scheme;
|
|
63
|
+
# proxy_read_timeout 900s;
|
|
64
|
+
#
|
|
65
|
+
# # Needed for websockets
|
|
66
|
+
# proxy_http_version 1.1;
|
|
67
|
+
# proxy_set_header Upgrade $http_upgrade;
|
|
68
|
+
# proxy_set_header Connection "Upgrade";
|
|
69
|
+
# }
|
|
70
|
+
|
|
71
|
+
location /uploads/ {
|
|
72
|
+
alias /var/www/html/your_website/uploads/;
|
|
73
|
+
expires 90d;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
location / {
|
|
77
|
+
# Redirect all requests to index.html
|
|
78
|
+
#try_files $uri $uri/ /index.html;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Redirect all requests from http to https
|
|
2
|
+
server {
|
|
3
|
+
listen 80;
|
|
4
|
+
server_name your_website.com www.your_website.com;
|
|
5
|
+
return 301 https://www.your_website.com$request_uri;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
server {
|
|
9
|
+
listen 443;
|
|
10
|
+
server_name admin.your_website.com;
|
|
11
|
+
|
|
12
|
+
ssl_certificate /Users/your_username/your_website/nginx/letsencrypt/fullchain.pem;
|
|
13
|
+
ssl_certificate_key /Users/your_username/your_website/nginx/letsencrypt/privkey.pem;
|
|
14
|
+
|
|
15
|
+
# Other SSL configurations (e.g., ciphers, protocols)
|
|
16
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
17
|
+
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
18
|
+
ssl_prefer_server_ciphers on;
|
|
19
|
+
|
|
20
|
+
root /Users/your_username/your_website/admin;
|
|
21
|
+
index index.html;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Redirect https domain without www to https with www
|
|
25
|
+
server {
|
|
26
|
+
listen 443;
|
|
27
|
+
server_name your_website.com;
|
|
28
|
+
|
|
29
|
+
ssl_certificate /Users/your_username/your_website/nginx/letsencrypt/fullchain.pem;
|
|
30
|
+
ssl_certificate_key /Users/your_username/your_website/nginx/letsencrypt/privkey.pem;
|
|
31
|
+
|
|
32
|
+
# Other SSL configurations (e.g., ciphers, protocols)
|
|
33
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
34
|
+
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
35
|
+
ssl_prefer_server_ciphers on;
|
|
36
|
+
|
|
37
|
+
return 301 https://www.your_website.com$request_uri;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Serve only https requests
|
|
41
|
+
server {
|
|
42
|
+
listen 443 ssl;
|
|
43
|
+
server_name www.your_website.com;
|
|
44
|
+
|
|
45
|
+
ssl_certificate /Users/your_username/your_website/nginx/letsencrypt/fullchain.pem;
|
|
46
|
+
ssl_certificate_key /Users/your_username/your_website/nginx/letsencrypt/privkey.pem;
|
|
47
|
+
|
|
48
|
+
# Other SSL configurations (e.g., ciphers, protocols)
|
|
49
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
50
|
+
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
51
|
+
ssl_prefer_server_ciphers on;
|
|
52
|
+
|
|
53
|
+
root /Users/your_username/your_website/dist;
|
|
54
|
+
index index.html;
|
|
55
|
+
|
|
56
|
+
# Only enable if you want to serve an API from another process running on different port
|
|
57
|
+
# location /api/ {
|
|
58
|
+
# proxy_pass https://127.0.0.1:4431;
|
|
59
|
+
# proxy_set_header Host $host;
|
|
60
|
+
# proxy_set_header X-Real-IP $remote_addr;
|
|
61
|
+
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
62
|
+
# proxy_set_header X-Forwarded-Proto $scheme;
|
|
63
|
+
# proxy_read_timeout 900s;
|
|
64
|
+
#
|
|
65
|
+
# # Needed for websockets
|
|
66
|
+
# proxy_http_version 1.1;
|
|
67
|
+
# proxy_set_header Upgrade $http_upgrade;
|
|
68
|
+
# proxy_set_header Connection "Upgrade";
|
|
69
|
+
# }
|
|
70
|
+
|
|
71
|
+
location /uploads/ {
|
|
72
|
+
alias /Users/your_username/your_website/public/uploads/;
|
|
73
|
+
expires 90d;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
location / {
|
|
77
|
+
# Redirect all requests to index.html
|
|
78
|
+
#try_files $uri $uri/ /index.html;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
This directory contains your keys and certificates.
|
|
2
|
+
|
|
3
|
+
`privkey.pem` : the private key for your certificate.
|
|
4
|
+
`fullchain.pem`: the certificate file used in most server software.
|
|
5
|
+
`chain.pem` : used for OCSP stapling in Nginx >=1.3.7.
|
|
6
|
+
`cert.pem` : will break many server configurations, and should not be used
|
|
7
|
+
without reading further documentation (see link below).
|
|
8
|
+
|
|
9
|
+
WARNING: DO NOT MOVE OR RENAME THESE FILES!
|
|
10
|
+
Certbot expects these files to remain in this location in order
|
|
11
|
+
to function properly!
|
|
12
|
+
|
|
13
|
+
We recommend not moving these files. For more information, see the Certbot
|
|
14
|
+
User Guide at https://certbot.eff.org/docs/using.html#where-are-my-certificates.
|