Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit 0495c43

Browse files
committed
prepared v1.4.0 release, change log and README
1 parent ae53aac commit 0495c43

File tree

6 files changed

+62
-12
lines changed

6 files changed

+62
-12
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog for StaticBackend
22

3+
### Sep 04, 2022 v1.4.0
4+
5+
Features:
6+
7+
* Dev cache impl now handle pub/sub (thanks @rostikts)
8+
* New server-side runtime function allowing to make HTTP requests (thanks @ksankeerth)
9+
* Magic link to login without entering password
10+
* Clean up log output via zerolog (thanks @VladPetriv)
11+
* Ability to update multiple documents from a query. (thanks @rostikts)
12+
* UI list uploaded files. (thanks @VladPetriv)
13+
* Added `/me` endpoint that returns current user with their role.
14+
* Creation of the `config` package to holw all configuration variables
15+
* In memory datastore and cache (for local dev / CLI)
16+
17+
Bug fixes:
18+
19+
* Fixed bug when calling List/Query when collection did not exists (thanks @rostikts)
20+
* Fixed a bug with PostgreSQL read/write permission
21+
* Fixed issue when serving local store files.
22+
* Fixed UI displaying internal SB collections
23+
* Fixed Go version in DockerFile (thanks @MyWay)
24+
* Fixed issue with PostgreSQL schema name not starting with a letter
25+
26+
327
### Mar 16, 2022 v1.3.0
428

529
* Feature: resize image when uploading

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010

1111
</p>
1212

13+
p.s. If you'd like to contribute to an active Go project, you've found a nice
14+
one in my biased opinion.
15+
1316
# StaticBackend - simple backend for your apps
1417

15-
[StaticBackend](https://staticbackend.com) is a simple backend that handles
18+
[StaticBackend](https://staticbackend.com) is a simple backend API that handles
1619
user management, database, file storage, forms, real-time experiences via
1720
channel/topic-based communication, and server-side functions for web and mobile
1821
applications.
@@ -42,6 +45,8 @@ a good fit.
4245

4346
I'm personally using it to build SaaS:
4447

48+
[En Pyjama - an online course platform for kids](https://enpyjama.com)
49+
4550
Abandoned projects:
4651

4752
* [Vivid - Automatic video clips for podcasts](https://vivid.fm)
@@ -74,7 +79,7 @@ const bkn = new Backend("your_public-key", "dev");
7479
let token = "";
7580

7681
login = async () => {
77-
const res = await bkn.login("email@test.com", "password");
82+
const res = await bkn.register("email@test.com", "password");
7883
if (!res.ok) {
7984
console.error(res.content);
8085
return;
@@ -210,8 +215,7 @@ Please help us improve if you have any feedback.
210215

211216
We [provide a CLI](https://staticbackend.com/getting-started/) for local
212217
development if you want to get things started without any infrastructure and
213-
for prototyping / testing. Please note the dev server has a very limited
214-
functionalities compares to the full self-hosted version.
218+
for prototyping / testing.
215219

216220
You can use the CLI to manage your database, form submissions, and deploy
217221
server-side-functions. We have an alpha Web UI as well to manage your resources.
@@ -262,4 +266,4 @@ If you're looking to help the project, here are some ways:
262266
* Use it and share your experiences.
263267
* Sponsor the development via GitHub sponsors.
264268
* Spread the words, a tweet, a blog post, any mention is helpful.
265-
* Join the Discord server.
269+
* Join the [Discord](https://discord.gg/vgh2PTp9ZB) server.

account.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,20 @@ Admin user:
231231
Password: %s
232232
233233
234-
Root token: %s
234+
Dev root token: safe-to-use-in-dev-root-token
235+
Real root token: %s
235236
236237
237238
Refer to the documentation at https://staticbackend.com/docs\n
238239
239240
`,
240241
bc.ID, email, pw, rootToken,
241242
)
243+
244+
// cache the root token so caller can always use
245+
// "safe-to-use-in-dev-root-token" as root token instead of
246+
// the changing one across CLI start/stop
247+
volatile.Set("dev-root-token", rootToken)
242248
} else {
243249
err = emailer.Send(ed)
244250
if err != nil {

db_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func dbReq(t *testing.T, hf func(http.ResponseWriter, *http.Request), method, pa
6969
if params[0] {
7070
stdAuth = []middleware.Middleware{
7171
middleware.WithDB(datastore, volatile, getStripePortalURL),
72-
middleware.RequireRoot(datastore),
72+
middleware.RequireRoot(datastore, volatile),
7373
}
7474
}
7575
h := middleware.Chain(http.HandlerFunc(hf), stdAuth...)
@@ -154,7 +154,7 @@ func TestDBListCollections(t *testing.T) {
154154

155155
stdRoot := []middleware.Middleware{
156156
middleware.WithDB(datastore, volatile, getStripePortalURL),
157-
middleware.RequireRoot(datastore),
157+
middleware.RequireRoot(datastore, volatile),
158158
}
159159
h := middleware.Chain(http.HandlerFunc(database.listCollections), stdRoot...)
160160

@@ -189,7 +189,7 @@ func TestListDocumentsInvalidDB(t *testing.T) {
189189

190190
stdRoot := []middleware.Middleware{
191191
middleware.WithDB(datastore, volatile, getStripePortalURL),
192-
middleware.RequireRoot(datastore),
192+
middleware.RequireRoot(datastore, volatile),
193193
}
194194
h := middleware.Chain(http.HandlerFunc(database.list), stdRoot...)
195195

@@ -312,7 +312,7 @@ func TestDBCreateIndex(t *testing.T) {
312312

313313
stdRoot := []middleware.Middleware{
314314
middleware.WithDB(datastore, volatile, getStripePortalURL),
315-
middleware.RequireRoot(datastore),
315+
middleware.RequireRoot(datastore, volatile),
316316
}
317317
h := middleware.Chain(http.HandlerFunc(database.index), stdRoot...)
318318

middleware/auth.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func ValidateAuthKey(datastore internal.Persister, volatile internal.PubSuber, c
120120
return a, nil
121121
}
122122

123-
func RequireRoot(datastore internal.Persister) Middleware {
123+
func RequireRoot(datastore internal.Persister, volatile internal.PubSuber) Middleware {
124124
return func(next http.Handler) http.Handler {
125125
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
126126
key := r.Header.Get("Authorization")
@@ -146,6 +146,22 @@ func RequireRoot(datastore internal.Persister) Middleware {
146146

147147
key = strings.Replace(key, "Bearer ", "", -1)
148148

149+
// in dev mode the cache will have a key called:
150+
// dev-root-token which hold the dynamically changing root token
151+
// which changes each stop/start of the CLI. Using
152+
// "safe-to-use-in-dev-root-token" as root token will
153+
// get the real root token removing the need to update the root token
154+
// in dev mode
155+
if key == "safe-to-use-in-dev-root-token" {
156+
rt, err := volatile.Get("dev-root-token")
157+
if err != nil {
158+
http.Error(w, "not in dev mode", http.StatusUnauthorized)
159+
return
160+
}
161+
162+
key = rt
163+
}
164+
149165
ctx := r.Context()
150166
conf, ok := ctx.Value(ContextBase).(internal.BaseConfig)
151167
if !ok {

server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func Start(c config.AppConfig, log *logger.Logger) {
138138

139139
stdRoot := []middleware.Middleware{
140140
middleware.WithDB(datastore, volatile, getStripePortalURL),
141-
middleware.RequireRoot(datastore),
141+
middleware.RequireRoot(datastore, volatile),
142142
}
143143

144144
m := &membership{log: log}

0 commit comments

Comments
 (0)