Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('@codetanzania/ewea-common');
const { error, debug } = require('@lykmapipo/logger');
const { start, listen } = require('@lykmapipo/postman');
const { connect } = require('./database');
debug('Start Launching Worker');
// connect to database
connect(err => {
// throw if error
if (err) {
error('Fail Launching Worker', err);
throw err;
}
// TODO: worker job events
// start kue worker
start();
// start kue http & ui
listen();
connect(err => {
// throw if error
if (err) {
error('Fail Launching Worker', err);
throw err;
}
// TODO: worker job events
// start kue worker
start();
// start kue http & ui
listen();
debug('Finish Launching Worker');
});
require('@codetanzania/ewea-common');
const { error, debug } = require('@lykmapipo/logger');
const { start } = require('./http');
debug('Start Launching Http Server');
// start http server
start((err, { PORT }) => {
// throw if error
if (err) {
error('Fail Launching Http Server', err);
throw err;
}
debug(`Http Server Running At http://0.0.0.0:${PORT}`);
debug('Finish Launchin Http Server');
});
start((err, { PORT }) => {
// throw if error
if (err) {
error('Fail Launching Http Server', err);
throw err;
}
debug(`Http Server Running At http://0.0.0.0:${PORT}`);
debug('Finish Launchin Http Server');
});
syncIndexes((error, results) => {
if (error) {
warn('Fail Syncing Indexes', error);
} else {
debug('Finish Syncing Indexes', results);
}
process.exit(0);
});
require('@codetanzania/ewea-common');
const { warn, debug } = require('@lykmapipo/logger');
const { syncIndexes } = require('../src/database');
debug('Start Syncing Indexes');
syncIndexes((error, results) => {
if (error) {
warn('Fail Syncing Indexes', error);
} else {
debug('Finish Syncing Indexes', results);
}
process.exit(0);
});
waterfall(tasks, error => {
if (error) {
warn('Fail Seeding Data', error);
} else {
debug('Finish Seeding Data');
}
process.exit(0);
});
const { apiVersion } = require('@lykmapipo/env');
const { jsonSchema } = require('@lykmapipo/mongoose-common');
const { predefineRouter } = require('@lykmapipo/predefine');
const { permissionRouter } = require('@lykmapipo/permission');
const {
authenticationRouter,
partyRouter,
} = require('@codetanzania/emis-stakeholder');
const {
eventRouter,
eventChangeLogRouter,
} = require('@codetanzania/ewea-event');
const { connect } = require('./database');
debug('Start Mounting Http Routers');
get(`/${apiVersion()}/schemas`, (request, response) => {
const schema = jsonSchema();
response.status(200);
response.json(schema);
});
mount(
authenticationRouter,
predefineRouter,
permissionRouter,
partyRouter,
eventRouter,
eventChangeLogRouter
);
debug('Finish Mounting Http Routers');
const start = done => {
syncIndexes,
Predefine,
Permission,
Party,
Event,
EventChangeLog,
} = require('../src/database');
const {
seedRegions,
seedDistricts,
seedWards,
seedSubWards,
seedHospitals,
} = require('./seedGeo');
debug('Start Seeding Data');
const seedEvents = done => {
return waterfall(
[next => Event.seed(next), (events, next) => EventChangeLog.seed(next)],
done
);
};
const seed = next => {
const seeds = {
allPermissions: then => Permission.seed(then),
predefinePermissions: then => Permission.seed(listPermissions(), then),
predefines: then => Predefine.seed(then),
regions: then => seedRegions(then),
districts: then => seedDistricts(then),
wards: then => seedWards(then),
debug('Start Mounting Http Routers');
get(`/${apiVersion()}/schemas`, (request, response) => {
const schema = jsonSchema();
response.status(200);
response.json(schema);
});
mount(
authenticationRouter,
predefineRouter,
permissionRouter,
partyRouter,
eventRouter,
eventChangeLogRouter
);
debug('Finish Mounting Http Routers');
const start = done => {
return waterfall([next => connect(next), next => startHttp(next)], done);
};
module.exports = { app, start, connect };