This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const { createCoreController } = require('@strapi/strapi').factories; | |
const { find, findOne, insertOne } = require('../../../helper/mongo'); | |
module.exports = createCoreController('api::reports.reports', ({ strapi }) => ({ | |
async create(ctx) { | |
const data = ctx.request.body.data; | |
// create reports collection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const { connect } = require('./helper/mongo'); | |
module.exports = { | |
/** | |
* An asynchronous register function that runs before | |
* your application is initialized. | |
* | |
* This gives you an opportunity to extend code. | |
*/ | |
// eslint-disable-next-line @typescript-eslint/no-empty-function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is a helper utility class to help with mongodb queries and operations | |
// function to connect to mongodb and disconnect | |
const MongoClient = require('mongodb').MongoClient; | |
// change connect close to as required | |
// connect to mongodb on every call and connection details from env variables | |
const connect = async () => { | |
const client = await MongoClient.connect(process.env.MONGO_URL, { | |
useNewUrlParser: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const { psInit, psSubscribe, psPublish } = require('./helper/pubsub'); | |
module.exports = { | |
/** | |
* An asynchronous register function that runs before | |
* your application is initialized. | |
* | |
* This gives you an opportunity to extend code. | |
*/ | |
// eslint-disable-next-line @typescript-eslint/no-empty-function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { PubSub } = require('@google-cloud/pubsub'); | |
function psInit() { | |
const projectId = process.env['GCP_PROJECT']; | |
// Instantiates a client | |
const pubsub = new PubSub({ projectId }); | |
return pubsub; | |
} | |
async function psPublish(pubsub, topic, data) { | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File: aws/controllers/aws.js | |
const { S3Client, CreateMultipartUploadCommand, UploadPartCommand, ListPartsCommand, | |
CompleteMultipartUploadCommand } = require("@aws-sdk/client-s3"); | |
const path = require("path"); | |
const fs = require('fs'); | |
const s3Client = new S3Client({ region: process.env.AWS_REGION }); | |
module.exports = { |