This file contains 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
PORT=3000 | |
MONGO_USER=mongoadmin | |
MONGO_PASS=mongoadmin | |
MONGO_URI=mongodb://127.0.0.1:27017/bull_mongo | |
#Redis config | |
REDIS_HOST=127.0.0.1 | |
REDIS_PORT=6379 |
This file contains 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
import Queue from 'bull'; | |
import models from '../mongoose'; | |
import opts from '../lib/redisConnection'; | |
const hitApiQueue = new Queue('last-login', opts); | |
hitApiQueue.process(async (job) => { | |
try { | |
const { apiUrl } = job.data; |
This file contains 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
import Redis from 'ioredis'; | |
const PORT = process.env.REDIS_PORT; | |
const HOST = process.env.REDIS_HOST; | |
const client = new Redis(PORT, HOST); | |
const subscriber = new Redis(PORT, HOST); | |
const opts = { | |
createClient(type) { | |
switch (type) { |
This file contains 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
import mongoose from 'mongoose'; | |
import HitApi from './models/hitApi.model'; | |
mongoose.Promise = Promise; | |
// Exit application on error | |
mongoose.connection.on('error', (err) => { | |
console.error(`MongoDB connection error: ${err}`); | |
process.exit(-1); | |
}); |
This file contains 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
import mongoose from 'mongoose'; | |
/** | |
* HitApi Schema | |
* @private | |
*/ | |
const hitApiSchema = new mongoose.Schema({ | |
api: { | |
type: String, | |
}, |
This file contains 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
import express from 'express'; | |
const app = express(); | |
// respond with "hello world" when a GET request is made to the homepage | |
app.get('/', (req, res) => { | |
res.send('hello world'); | |
}); | |
app.get('/api-1', (req, res) => { |
This file contains 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
version: "2" | |
services: | |
mongodb: | |
image: mongo | |
volumes: | |
- ./volumes/mongodata:/data/db | |
environment: | |
- MONGO_INITDB_ROOT_USERNAME=mongoadmin | |
- MONGO_INITDB_ROOT_PASSWORD=mongoadmin | |
ports: |
This file contains 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
sudo mongorestore --username "YourUserName" --password "YourPassword" --authenticationDatabase "admin" --db yourdbname --drop /path/to/archive/folder/ |