Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const makeModelsController = (
radiksCollection: Collection,
config: Config,
emitter: EventEmitter
) => {
const ModelsController = addAsync(express.Router());
ModelsController.use(bodyParser.json());
ModelsController.postAsync('/crawl', async (req, res) => {
const { gaiaURL } = req.body;
const attrs = await request({
uri: gaiaURL,
json: true,
});
const validator = new Validator(radiksCollection, attrs);
try {
await validator.validate();
await radiksCollection.save(attrs);
emitter.emit(constants.STREAM_CRAWL_EVENT, [attrs]);
res.json({
success: true,