all repos — litestore @ e1c9c16ae28a6ba485b17642a5cf612316c519f0

A minimalist nosql document store.

Minor updates.
h3rald h3rald@h3rald.com
Sun, 05 Apr 2020 14:04:15 +0200
commit

e1c9c16ae28a6ba485b17642a5cf612316c519f0

parent

0bc5af7f7137762d1dbd9946e0db0877159e38e9

M src/litestore.nimsrc/litestore.nim

@@ -74,6 +74,7 @@ # }

# } # } proc initStores*() = + LOG.debug("Initializing stores...") if LS.config.kind == JObject and LS.config.hasKey("stores"): for k, v in LS.config["stores"].pairs: if not v.hasKey("file"):

@@ -83,7 +84,7 @@ var config = newJNull()

if v.hasKey("config"): config = v["config"] LSDICT[k] = LS.addStore(k, file, config) - LOG.info("Initializing master store") + LOG.debug("Initializing master store") LS.setup(true) LS.initStore() LSDICT["master"] = LS
M src/litestorepkg/lib/api_v7.nimsrc/litestorepkg/lib/api_v7.nim

@@ -1206,7 +1206,6 @@ for m in mw:

result.add m.getStr proc execute*(req: var LSRequest, LS: LiteStore, resource, id: string): LSResponse = - echo LS.file let middleware = getMiddlewareSeq(LS, resource, id, $req.reqMethod) LOG.debug("Middleware: " & middleware.join(" -> ")); if middleware.len == 0:
M src/litestorepkg/lib/core.nimsrc/litestorepkg/lib/core.nim

@@ -503,7 +503,7 @@ var d_searchable = 1

if d_ct.isBinary: d_binary = 1 d_searchable = 0 - d_contents = d_contents.encode(d_contents.len*2) # Encode in Base64. + d_contents = d_contents.encode # Encode in Base64. let singleOp = not LS_TRANSACTION store.begin() try:

@@ -639,6 +639,7 @@ fail(103, "Invalid log level '$1'" % val)

proc processAuthConfig(configuration: JsonNode, auth: var JsonNode) = if auth == newJNull() and configuration != newJNull() and configuration.hasKey("signature"): + LOG.debug("Authentication: Signature found, processing authentication rules in configuration.") auth = newJObject(); auth["access"] = newJObject(); auth["signature"] = configuration["signature"]

@@ -709,6 +710,7 @@ if LS.config != newJNull():

# Process config settings LS.processConfigSettings() # Process auth from config settings + LOG.debug("Authentication: Checking configuration for auth rules - Store file: " & LS.file) processAuthConfig(LS.config, LS.auth) if LS.auth == newJNull():

@@ -753,7 +755,7 @@ result.file = file

result.middleware = newStringTable() if config != newJNull(): result.config = config - LOG.info("Initializing store '$1'" % id) + LOG.debug("Initializing store '$1'" % id) result.setup(true) result.initStore() if not LS.config.hasKey("stores"):
M src/litestorepkg/lib/server.nimsrc/litestorepkg/lib/server.nim

@@ -51,7 +51,7 @@ echo ""

LOG.info("Exiting...") quit() -template auth(uri: string, jwt: JWT): void = +template auth(uri: string, jwt: JWT, LS: LiteStore): void = let cfg = access[uri] if cfg.hasKey(reqMethod): LOG.debug("Authenticating: " & reqMethod & " " & uri)

@@ -122,12 +122,12 @@ let access = LS.auth["access"]

while true: # Match exact url if access.hasKey(uri): - auth(uri, jwt) + auth(uri, jwt, LS) break # Match exact url adding /* (e.g. /docs would match also /docs/* in auth.json) elif uri[^1] != '*' and uri[^1] != '/': if access.hasKey(uri & "/*"): - auth(uri & "/*", jwt) + auth(uri & "/*", jwt, LS) break var parts = uri.split("/") if parts[^1] == "*":

@@ -140,7 +140,7 @@ else:

# If at the end of the URL, check generic URL uri = "/*" if access.hasKey(uri): - auth(uri, jwt) + auth(uri, jwt, LS) break if info.version == "v7": if info.resource.match(peg"^docs / info / tags / indexes / stores$"):