ci: expand CI checks and make consumer sync opt-in
- Add Go, npm, Python, and Java validation to CI - Run Go tests against PostgreSQL - Record performance fixes in the report
This commit is contained in:
1 parent
199a5efaef
commit
22887fef03
100 files changed
+9740
-429
No files matched your search
@@ -3,8 +3,8 @@
|
||||
Shared Node.js backend infrastructure for services that use PostgreSQL:
|
||||
|
||||
- validated `DATABASE_URL` and pool settings;
|
||||
- one pool owner with startup retry, transient query retry, transactions, and shutdown;
|
||||
- PBKDF2 password hashing and secure session-token helpers;
|
||||
- one pool owner with startup retry, transient retry for read-only queries, transactions, and shutdown;
|
||||
- PBKDF2 password hashing (`verifyAndUpgradePasswordAsync` returns a current-scheme hash for a login to store) 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.
|
||||
@@ -20,7 +20,9 @@ share one PostgreSQL database, so their migration histories cannot collide.
|
||||
Database startup uses `DB_INIT_RETRY_INTERVAL_MS` (default `5000`, minimum
|
||||
`250`) and `DB_INIT_RETRY_MAX_ATTEMPTS` (default `0`, retry indefinitely).
|
||||
|
||||
Run `npm test` from this package or `npm run test --workspace=@gabriel20xx/node-backend` from `shared`.
|
||||
Run `npm test` from this package or `npm run test --workspace=@gabriel20xx/node-backend` from `shared`; `npm run lint` runs ESLint with the repository's config.
|
||||
|
||||
`AuthClient`'s `register`, `login`, `totpVerify`, `totpDisable`, `requestPasswordReset` and `confirmPasswordReset` take an optional trailing `{ clientIp }`, sent to AuthGuard as `X-Forwarded-For` so its per-address limits see the end user. Pass an address you have verified (for example the socket peer, or `X-Forwarded-For` only from a proxy you trust), never a raw request header. `AuthStore` refuses an empty password hash and a username containing `@`, refuses `setTotpSecret` while TOTP is enabled (error code `AUTH_TOTP_ALREADY_ENABLED`), and makes usernames unique ignoring case when no clashing pair already exists.
|
||||
|
||||
## `authclient`/`coreconfig`: adopting AuthGuard instead of local auth
|
||||
|
||||
@@ -39,7 +41,7 @@ live whenever ProjectConfigurator pushes a fresh
|
||||
`authClient.setBaseUrl` so a project never needs to hardcode `AUTHGUARD_URL`:
|
||||
|
||||
```js
|
||||
import { AuthClient, CoreConfigStore } from '@gabriel20xx/node-backend';
|
||||
import { AuthClient, CoreConfigStore, internalSecretMatches } from '@gabriel20xx/node-backend';
|
||||
|
||||
const authClient = new AuthClient('');
|
||||
const coreConfig = new CoreConfigStore({ authGuardUrl: '' });
|
||||
@@ -47,10 +49,15 @@ 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.SECRET) {
|
||||
if (!internalSecretMatches(req.get('X-Internal-Auth'), process.env.SECRET)) {
|
||||
return res.status(401).json({ error: 'internal service authentication required' });
|
||||
}
|
||||
const info = coreConfig.set(req.body);
|
||||
let info;
|
||||
try {
|
||||
info = coreConfig.set(req.body);
|
||||
} catch (error) {
|
||||
return res.status(400).json({ error: error.message });
|
||||
}
|
||||
res.json({ ok: true, info: info.toJSON() });
|
||||
});
|
||||
```
|
||||
Reference in new issue
Block a user