Skip to content

Commit

Permalink
feat(queue): add BullMQ adapter #6
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Jan 26, 2024
1 parent a3a86c2 commit 9b42f93
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 15 deletions.
1 change: 1 addition & 0 deletions app/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export { default as mongodb } from 'https://raw.githubusercontent.com/hyper63/hy
export { default as redis } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-redis/v3.2.2/mod.js';
export { default as elasticsearch } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-elasticsearch/v2.0.3/mod.js';
export { default as minio } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-minio/v1.0.2/mod.js';
export { default as bullmq } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-bullmq/v1.0.1/mod.ts';
export { default as hooks } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-hooks/v1.0.6/mod.js';
44 changes: 29 additions & 15 deletions app/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, elasticsearch, type express, hyper, minio, mongodb, redis } from './deps.ts';
import { app, bullmq, elasticsearch, type express, hyper, minio, mongodb, redis } from './deps.ts';
import { env, verifyAuthorizationHeader } from './utils.ts';

/**
Expand Down Expand Up @@ -35,38 +35,52 @@ const authMiddleware =
return app;
};

const MONGO_URL = `mongodb://${env('MONGO_USERNAME')}:${env('MONGO_PASSWORD')}@${
env('MONGO_HOST')
}`;
const REDIS_URL = `http://${env('REDIS_HOST')}:${env('REDIS_PORT')}`;
const ELASTICSEARCH_URL = `http://${env('ELASTICSEARCH_HOST')}`;
// Use the public url, so presigned url signatures match
const MINIO_URL = `https://${env('MINIO_USERNAME')}:${env('MINIO_PASSWORD')}@${
env('MINIO_HOST')
}.onrender.com`;

export default hyper({
app,
adapters: [
{
port: 'data',
plugins: [
mongodb({
url: `mongodb://${env('MONGO_USERNAME')}:${env('MONGO_PASSWORD')}@${env('MONGO_HOST')}`,
}),
],
plugins: [mongodb({ url: MONGO_URL })],
},
{
port: 'cache',
plugins: [
// @ts-ignore incorrect types in the adapter, so safe to ignore for now
redis({ hostname: env('REDIS_HOST'), port: env('REDIS_PORT') }),
],
plugins: [redis({ url: REDIS_URL })],
},
{
port: 'search',
plugins: [elasticsearch({ url: ELASTICSEARCH_URL })],
},
{ port: 'search', plugins: [elasticsearch({ url: `http://${env('ELASTICSEARCH_HOST')}` })] },
// Use the public url, so presigned url signatures match
{
port: 'storage',
plugins: [
minio({
url: `https://${env('MINIO_USERNAME')}:${env('MINIO_PASSWORD')}@${
env('MINIO_HOST')
}.onrender.com`,
url: MINIO_URL,
bucketPrefix: 'hyper',
useNamespacedBucket: false,
}),
],
},
{
port: 'queue',
plugins: [
bullmq({
url: REDIS_URL,
options: {
keyPrefix: 'hyper',
},
}),
],
},
],
middleware: [authMiddleware({ sub: env('SUB'), secret: env('SECRET') })],
});
Loading

0 comments on commit 9b42f93

Please sign in to comment.