salix/back/tests-helper.js

36 lines
871 B
JavaScript
Raw Normal View History

/* eslint-disable no-console */
const app = require('vn-loopback/server/server');
let dataSources = require('../loopback/server/datasources.json');
async function init() {
console.log('Initializing backend.');
dataSources = JSON.parse(JSON.stringify(dataSources));
Object.assign(dataSources.vn, {
host: process.env.DB_HOST,
port: process.env.DB_PORT
});
const bootOptions = {dataSources};
await new Promise((resolve, reject) => {
app.boot(bootOptions,
err => err ? reject(err) : resolve());
});
// FIXME: Workaround to wait for loopback to be ready
2024-05-17 09:29:16 +00:00
app.emit('started');
await app.models.Application.status();
}
async function deinit() {
console.log('Stopping backend.');
await app.disconnect();
}
2024-04-01 08:57:53 +00:00
module.exports = {
init,
deinit
};
if (require.main === module)
init();
2024-03-29 21:19:23 +00:00