Every language's AuthGuard client/service used "no URL at construction" to mean "auth disabled forever" - a live SetBaseUrl/setBaseUrl push from ProjectConfigurator could only ever retarget an *already-enabled* client, never turn one on for the first time. That made AUTHGUARD_URL a de-facto required env var everywhere, even though ProjectConfigurator can push it live after startup. - Go: shared/backend/auth's New/NewWithStore now default to a "pending" Service (still enabled, fails closed until a URL arrives) instead of disabled when authGuardURL is empty; add an explicit Disabled() option for the genuine standalone/local-dev opt-out. - Python/Node/Java: add setBaseUrl/set_base_url to each AuthClient so a client built with an empty base URL can be retargeted in place once a URL is pushed, the same as the Go client already supported. - Python/Node: add a coreconfig module (Info/Store), the framework-agnostic equivalent of shared/backend/coreconfig (Go), for services in those languages to receive ProjectConfigurator's core-services push at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gabriel20xx/node-backend
Shared Node.js backend infrastructure for services that use PostgreSQL:
- validated
DATABASE_URLand pool settings; - one pool owner with startup retry, transient query retry, transactions, and shutdown;
- PBKDF2 password hashing and secure session-token helpers;
- short-lived, one-time admin reset codes printed to the server console;
- common account/session persistence;
- transaction-locked ordered migrations.
The package does not depend on Express. Each service keeps its own routes,
cookies, roles, validation policy, and domain repositories. Existing
MediaShared code can be migrated into this package incrementally; keep the
legacy package as a compatibility layer until every consumer has moved.
Pass a service-specific tableName to runMigrations when multiple services
share one PostgreSQL database, so their migration histories cannot collide.
Run npm test from this package or npm run test --workspace=@gabriel20xx/node-backend from shared.
authclient/coreconfig: adopting AuthGuard instead of local auth
AuthClient (src/authclient.js) trades a service's own local user table for
HTTP calls to a centralized AuthGuard instance, mirroring the Go/Python/Java
clients. client.setBaseUrl(url) retargets an existing client's AuthGuard
URL in place, so a client can be constructed with new AuthClient('')
(usable right away, failing closed until a real URL arrives) and be handed a
URL later, rather than needing one known up front.
coreconfig (src/coreconfig.js, the Node equivalent of
shared/backend/coreconfig and shared_backend.coreconfig) is a small
Store that holds AuthGuard's/CarrierNode's current base URL(s) and updates
live whenever ProjectConfigurator pushes a fresh
PUT /api/core-services/internal - wire store.onUpdate to
authClient.setBaseUrl so a project never needs to hardcode AUTHGUARD_URL:
import { AuthClient, CoreConfigStore } from '@gabriel20xx/node-backend';
const authClient = new AuthClient('');
const coreConfig = new CoreConfigStore({ authGuardUrl: '' });
coreConfig.onUpdate((info) => authClient.setBaseUrl(info.authGuardUrl));
// in your own route for PUT /api/core-services/internal:
app.put('/api/core-services/internal', (req, res) => {
if (req.get('X-Internal-Auth') !== process.env.INTERNAL_SERVICE_SECRET) {
return res.status(401).json({ error: 'internal service authentication required' });
}
const info = coreConfig.set(req.body);
res.json({ ok: true, info: info.toJSON() });
});