Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const express = require('express');
const mariadb = require('mariadb');
const mustacheExpress = require('mustache-express');
const app = express();
app.engine('html', mustacheExpress());
app.set('view engine', 'html');
app.set('views', __dirname + '/public');
app.use(express.static('public'));
const pool = mariadb.createPool({
// host: 'localhost',
host: 'dashboard-db',
user:'dashboard',
password: 'dashboard123',
database: 'MyDashboard'
});
app.listen(3000, host='0.0.0.0', ()=>{
console.log("Dashboard App started...");
console.log("Listening at port 3000...");
})
app.get("/dashboard", async (req,res)=>{
res.render("dashboard");
})
constructor() {
this.jwtOptions.jwtFromRequest = this.ExtractJwt.fromAuthHeaderAsBearerToken();
this.jwtOptions.secretOrKey = process.env.SECRET;
this.connectionString = {
host: process.env.HOSTNAMEMARIADB,
user: process.env.UIDMARIADB,
password: process.env.PASSWORDMARIADB,
database: process.env.DATABASEMARIADB,
connectionLimit: 5,
port: process.env.PORTMARIADB
};
this.pool = mariadb.createPool(this.connectionString);
console.log(this.connectionString);
this.express = express();
epimetheus.instrument(this.express);
this.middleware();
this.routes();
}
private ensureToken(req, res, next) {
const { createPool } = require('mariadb');
const config = require('../config');
const lib = require('../lib');
const pool = createPool(config.mysql);
const allColumns = `
aki.IndexID,
aki.HeaderID,
aki.ShabadID,
v.VerseID,
v.Gurmukhi,
v.Visraam,
v.GurmukhiUni,
v.Translations,
v.PageNo AS PageNo,
v.LineNo,
v.SourceID,
v.Transliterations,
v.WriterID,
w.WriterEnglish,
const { createPool } = require('mariadb');
const config = require('../config');
const lib = require('../lib');
const pool = createPool(config.mysql);
exports.all = async (req, res) => {
let conn;
try {
conn = await pool.getConnection();
const q = 'SELECT id as rehatID, maryada_name as rehatName, alphabet FROM maryadas';
const maryadas = await conn.query(q, []);
res.json({
count: maryadas.length,
maryadas,
});
} catch (err) {
lib.error(err, res, 500);
} finally {
if (conn) conn.end();
export default function withMariadb(config: Omit & { mariadb: PoolConfig }): ServerConfig {
const { mariadb: mariaConfig } = config;
const database = mariaConfig.database || process.env.MARIADATABASE || 'buildtracker';
const pool = createPool({
user: process.env.MARIAUSER,
host: process.env.MARIAHOST,
password: process.env.MARIAPASSWORD,
port: process.env.MARIAPORT ? parseInt(process.env.MARIAPORT, 10) : 3306,
...mariaConfig,
database
});
const queries = new Queries(pool);
return {
...config,
setup: setup(pool),
queries: {
build: {
byRevision: queries.getByRevision,
exports.db = async (req, res) => {
let conn;
try {
const pool = createPool({ ...config.mysql, connectTimeout: 3000 });
conn = await pool.getConnection();
const q = `SELECT 1 as ok FROM Verse WHERE ID=1 LIMIT 1`;
const rows = await conn.query(q);
rows[0].ok = rows[0].ok === 1;
res.json(rows[0]);
} catch (err) {
lib.error(err, res, 500, false);
} finally {
if (conn) {
conn.end();
}
}
};
const { createPool } = require('mariadb');
const config = require('../config');
const lib = require('../lib');
const lengthExistsMap = {
s: 'existsSGPC',
m: 'existsMedium',
t: 'existsTaksal',
b: 'existsBuddhaDal',
};
const pool = createPool(config.mysql);
const allColumns = `
b.Gurmukhi AS NameGurmukhi,
b.GurmukhiUni AS NameGurmukhiUni,
b.Transliterations AS NameTransliterations,
v.ID,
v.Gurmukhi,
v.Visraam,
v.GurmukhiUni,
v.Translations,
v.PageNo AS PageNo,
v.LineNo,
v.SourceID,
v.Transliterations,
v.WriterID,
w.WriterEnglish,
const { createPool } = require('mariadb');
const banidb = require('@sttm/banidb');
const anvaad = require('anvaad-js');
const config = require('../config');
const lib = require('../lib');
const sources = banidb.SOURCES;
const searchTypes = banidb.TYPES;
const pool = createPool(config.mysql);
const allColumns = `v.ID, v.Gurmukhi, v.GurmukhiUni, v.Translations, v.PageNo AS PageNo, v.LineNo,
v.SourceID as SourceID, s.ShabadID, v.FirstLetterStr, v.MainLetters, v.Visraam,
v.FirstLetterEng, v.Transliterations, v.WriterID, w.WriterEnglish,
w.WriterGurmukhi, w.WriterUnicode, v.RaagID, r.RaagGurmukhi,
r.RaagUnicode, r.RaagEnglish, r.RaagWithPage, r.StartID, r.EndID,
src.SourceGurmukhi, src.SourceUnicode, src.SourceEnglish,
GREATEST(s.Updated, v.Updated) AS Updated`;
const liveColumns = `v.ID, v.Gurmukhi, v.GurmukhiUni, v.Translations, s.ShabadID`;
const allFrom = `FROM Verse v
LEFT JOIN Shabad s ON s.VerseID = v.ID
LEFT JOIN Writer w USING(WriterID)
LEFT JOIN Raag r USING(RaagID)
LEFT JOIN Source src USING(SourceID)`;