Skip to content

Commit

Permalink
fix(ci): update token secret
Browse files Browse the repository at this point in the history
  • Loading branch information
gweill-guigops committed Apr 22, 2024
1 parent db3ccc4 commit 00bd3db
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .kontinuous/env/prod/templates/token.sealed.secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ metadata:
namespace: vao
spec:
encryptedData:
TOKEN_SECRET: AgBN1DXIQyjlQ+FV3NdnN6Y67drtCTDfcNNYsWdbu/pF91qENfVtSw+6HMsB3g1fRY3WMvsM/8irjC1eXR1M4LfEe346mDZZFBFXcDkcA/SCuBo5L6GXvEzfYA0QTZueeXUX5lowZ4aLhsl/TofG0uyZsxO4wk53K8MAcf2+5GjoSyXOQEa5P46ElUCeiZov9ByCDTmr+xgqVian7IxMWHTxZoQsA9+WeXwFYGe5Wn24cF5rxQ9jezo0N3juhMVLwZ3XWshLT4bNEdQ8Uej3mm4cvNHhEBii0IUY0LXK8h0FP51DaIF/1Xt6yfUrb6nlpJb0oSsXqz8wmHhB/0LxL1fT0ie2ojjbF4I/tEagwLq5ZMgYITP55ZNo2h7l0D1DFI3CqiUCpDntSLTelGpLW2CMWzbrPIPcJFO7rPgZXb0H6lJQPHIcp0DXpf5bk07h6jkp3oXC/+AhRaW3jJh8RZUKYV76VaNKo88uUNlr9KS/EQg31O5deJ9tf03lh9nhTmATbOrX1DgTBfpiIOnAoXyG9b5mobfAsWkfCWeqV0oPvfFvr2zzTodpReOOpo7Qax+X0WOXnMR0dNWoiPw4m+/BcwOCoXBaRuDbgR8ypHSwYF198pfNcomG4LffxXAZ+a++HNxMoNMW7w8ehtbr5TIhVuibDkMzIY4TFhvKvQC49keDwzuyWSSeHKvQs7J5CXN4oYtUP9CCuS19aV5+2jhV8qLu/YMhrGjzrWr8SoXnl4HBw1ZI+lz9c3QdisuH4vMGCc8YESS9rhILvG9iRwOT/WGJdh4380fQ6jW0gjbo53sHq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0rDjf2ZEkOc1m94NeNKQbPM0e9xyRfo74BD1v+0b/HwvdBmdjhXV6lIqFFIvOJRUKHjkZ5NYWzetvEvbgfItEgjJ1bmWcKU7z2wxBiHKHY9ENxiKZyvp53QI5Y9YXqUCr+r9lpGKn5EiigYiGWoKrS5EZWiBVuk08Bt1oz9PzEkA5gwYmkjh2T30vI+oAXjXqPxULd5OLpDuC5ZQ9LId8sm4t1WmnaLSN7DkhhdjyNX0Le+VeYjyGuuf4a/3goxsgu0zMjFJmTqnLcwOh+aySTeh0kjlEHeKA13I7c/8XzNmUpgssDFXRt+bFJpWWXdtjZetZr1MBM8u+H+Xi47xIDjBIjojKs+N1zvKCJeLp5UfaOhbAiQxF9TSzvXu2POWmyjIhXj5lU5BfraICiB0bJGrMTw4RY4HMqyQ97lt5D7r2oHjN/rETvC1X+oV6e7y0744UWYNGNLEplUm7RYIl3xVkhGQXwRE4fFNMMVhkdtX+All1ntJC/NJo4LBVx
template:
metadata:
annotations:
sealedsecrets.bitnami.com/namespace-wide: 'true'
name: token
type: Opaque
type: Opaque
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fileignoreconfig:
- filename: .kontinuous/env/prod/templates/smtp.sealed.secret.yaml
checksum: 161db1ab1b716057d75b52c054e6ccdf8af90cd15b401dd5fe57dde64ef12297
- filename: .kontinuous/env/prod/templates/token.sealed.secret.yaml
checksum: fdc939804202f43c691dcfa7481ac2088825500e4b1278318465c4744b4558f8
checksum: 930f9289c37f13b2424b8c6ee0e7895689e922539f1c6fba8b2dd4c0ad45ba1e
- filename: .kontinuous/preprod/templates/apientreprise.sealed.secret.yaml
checksum: 6e1a0def42dc791767f353c6676e385b21eb2c9c9637a2b3cae3e7a33505c76a
- filename: .kontinuous/preprod/templates/pg.sealed.secret.yaml
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ services:
env_file:
- ./.env
environment:
DEBUG: "*info*"
DEBUG: "*debug*"
SENTRY_DSN: ${BACKEND_SENTRY_DSN}
SENTRY_ENVIRONMENT: local
SENTRY_ENABLED: ${BACKEND_SENTRY_ENABLED}
Expand Down
13 changes: 8 additions & 5 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"main": "src/index.js",
"scripts": {
"lint": "eslint ./src",
"dev": "nodemon --inspect=0.0.0.0:9229 src/index.js"
"dev": "nodemon --inspect=0.0.0.0:9229 src/index.js | pino-pretty"
},
"dependencies": {
"@sentry/node": "~7.109.0",
"@sentry/node": "~7.109.0",
"axios": "^1.6.8",
"body-parser": "~1.20.2",
"cookie-parser": "^1.4.6",
Expand All @@ -18,14 +18,16 @@
"db-migrate-pg": "~1.5.2",
"debug": "~4.3.4",
"express": "~4.19.2",
"helmet": "~7.1.0",
"helmet": "~7.1.0",
"jsonwebtoken": "^9.0.2",
"multer": "^1.4.5-lts.1",
"pg": "~8.11.3",
"pg-format": "~1.0.4",
"yup": "~1.4.0",
"nodemailer": "^6.9.13",
"pdfmake": "^0.2.10"
"pdfmake": "^0.2.10",
"pino-debug": "~2.0.0",
"pino": "~8.20.0"
},
"devDependencies": {
"@socialgouv/eslint-config-recommended": "^1.131.0",
Expand All @@ -34,9 +36,10 @@
"jest": "29.7.0",
"lint-staged": "^15.2.2",
"nodemon": "^3.1.0",
"pino-pretty": "~11.0.0",
"prettier": "^3.2.5"
},
"lint-staged": {
"src/**/*.{js,ts}": "npx eslint --cache --fix"
}
}
}
114 changes: 92 additions & 22 deletions packages/backend/src/utils/logger.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,113 @@
const pinoDebug = require("pino-debug");
const pino = require("pino");
const util = require("util");

const logger = pino({
formatters: {
level: (label) => {
return {
level: label,
};
},
},
level: "debug",
});

const map = {
"*": "debug",
};

const config = {
auto: false,
map,
};

pinoDebug(logger, config);

const path = require("path");
const $debug = require("debug");

function byPrecision(a, b) {
var aix = a.indexOf("*");
var bix = b.indexOf("*");
if (aix === -1 && bix === -1) return 0;
if (~aix && ~bix) {
if (aix > bix) return -1;
if (aix < bix) return 1;
return a.length < b.length ? 1 : a.length === b.length ? 0 : -1;
}
return ~bix ? -1 : 1;
}

const root = `${path.dirname(
(require.main && require.main.filename) || process.filename,
)}/`;

function logger(caller) {
let name = caller.replace(root, "").split(".");
module.exports = function logger(caller) {
let name = caller.replace(root, "").replace("/", ":").split(".");
if (name.length > 1) {
name.pop();
}
name = name.join();
const debug = $debug(`debug:vao-backend/${name}`);
const info = $debug(`info:vao-backend/${name}`);
const warn = $debug(`warn:vao-backend/${name}`);

const debugNS = `debug:vao-backend:${name}`;
const infoNS = `info:vao-backend:${name}`;
const warnNS = `warn:vao-backend:${name}`;

if (!config.auto) {
map[debugNS] = "debug";
map[infoNS] = "info";
map[warnNS] = "warn";

$debug.map = Object.keys(map)
.sort(byPrecision)
.reduce(function (m, k) {
m.set(
RegExp(
"^" +
k.replace(/[\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*?") +
"$",
),
map[k],
);
return m;
}, new Map());
}

const debug = $debug(debugNS);
const info = $debug(infoNS);
const warn = $debug(warnNS);

console.info(debug);

if (debug.enabled && !info.enabled) {
info.enabled = true;
}

if (info.enabled && !warn.enabled) {
warn.enabled = true;
}

return {
d(message, ...args) {
if (debug.enabled) {
debug("[DEBUG]", message, ...args);
}
debug(util.format(message, ...args));
},
i(message, ...args) {
console.info(
"INFO",
util.format(message, ...args),
info,
map[info.namespace],
);
if (debug.enabled) {
debug("[INFO]", message, ...args);
} else if (info.enabled) {
info("[INFO]", message);
info(util.format(message, ...args));
} else {
info(message);
}
},
w(...args) {
if (debug.enabled) {
debug("[WARN]", ...args);
} else if (info.enabled) {
info("[WARN]", ...args);
} else if (warn.enabled) {
warn("[WARN]", ...args);
}
// Raven.captureException(e)
console.info("WARN", util.format(...args), warn, map[warn.namespace]);
warn(util.format(...args));
},
};
}

module.exports = logger;
};
Loading

0 comments on commit 00bd3db

Please sign in to comment.