Skip to content

Commit

Permalink
289th Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Mar 16, 2024
1 parent 9902716 commit f83ab62
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 34 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,19 @@ This seed repository provides the following features:

### Tiny examples

- [x] [Hello World](./src/routes/hello-world/+handler.ts)
- [x] [CRUD Operations](./src/routes/todos)
- [x] [JWT Authentication](./src/routes/auth/+handler.ts)
- [x] [One-time Password](./src/routes/auth/otp/+handler.ts)
- [x] [File Uploads](./src/routes/file-uploads/+handler.ts)
- [x] [Real-time Data](./src/routes/echo/+handler.ts)
- [x] [Real-time Updates](./src/routes/sse/+handler.ts)
- [x] [Sending Emails](./src/routes/email/+handler.ts)
- [x] [Internationalization](./src/routes/hello-i18n)
- [x] [Caching](./src/routes/hello-world/caching-memory/+handler.ts) (Or use [Redis Store](./src/routes/hello-world/caching-redis/+handler.ts))
- [x] [Cache Deduplication](./src/routes/hello-world/caching-dedupe/[id]-memory/+handler.ts) (Or use [Redis Store](./src/routes/hello-world/caching-dedupe/[id]-redis/+handler.ts))
- [ ] Background Workers (Or use [Redis Store](./src/routes/queues/+handler.ts))
- [ ] Cron Jobs (Or use [Redis Store](./src/routes/queues/cron/+handler.ts))
- [x] [Hello World](./app/src/routes/hello-world/+handler.ts)
- [x] [CRUD Operations](./app/src/routes/todos)
- [x] [JWT Authentication](./app/src/routes/auth/+handler.ts)
- [x] [One-time Password](./app/src/routes/auth/otp/+handler.ts)
- [x] [File Uploads](./app/src/routes/file-uploads/+handler.ts)
- [x] [Real-time Data](./app/src/routes/echo/+handler.ts)
- [x] [Real-time Updates](./app/src/routes/sse/+handler.ts)
- [x] [Sending Emails](./app/src/routes/email/+handler.ts)
- [x] [Internationalization](./app/src/routes/hello-i18n)
- [x] [Caching](./app/src/routes/hello-world/caching-memory/+handler.ts) (Or use [Redis Store](./app/src/routes/hello-world/caching-redis/+handler.ts))
- [x] [Cache Deduplication](./app/src/routes/hello-world/caching-dedupe/[id]-memory/+handler.ts) (Or use [Redis Store](./app/src/routes/hello-world/caching-dedupe/[id]-redis/+handler.ts))
- [x] [Background Workers](./app/src/jobs) (Or use [Redis Store](./app/src/routes/queues/+handler.ts))
- [x] [Cron Jobs](./app/src/jobs) (Or use [Redis Store](./app/src/routes/queues/cron/+handler.ts))

## Configuration

Expand Down
4 changes: 3 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"preview": "vite preview",
"check": "tsc --noEmit",
"test": "vitest --dir src --coverage --run",
"dev:worker": "vite-node -w src/worker.ts"
"worker:dev": "vite-node -w src/worker.ts",
"worker:start": "node dist/worker.js"
},
"dependencies": {
"@fastify/cors": "^9.0.1",
Expand Down Expand Up @@ -56,6 +57,7 @@
"vite-node": "^1.3.1",
"vite-plugin-fastify": "^1.2.5",
"vite-plugin-fastify-routes": "^1.1.1",
"vite-plugin-static-copy": "^1.0.1",
"vitest": "^1.3.1"
}
}
10 changes: 10 additions & 0 deletions app/src/jobs/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import process from 'node:process';
import { parentPort } from 'node:worker_threads';

console.log('Hello, Bree!');

if (parentPort) {
parentPort.postMessage('done');
} else {
process.exit(0);
}
21 changes: 21 additions & 0 deletions app/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* Bull
*/

import useWorker from '~/composables/useWorker';

useWorker(
Expand All @@ -13,3 +17,20 @@ useWorker(
removeOnFail: { count: 0 },
},
);

/**
* Bree
*/

import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import Bree from 'bree';

(async () => {
const bree = new Bree({
root: join(dirname(fileURLToPath(import.meta.url)), 'jobs'),
jobs: [{ name: 'hello' }],
});

await bree.start();
})();
9 changes: 9 additions & 0 deletions app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import envify from 'process-envify';
import { defineConfig } from 'vite';
import fastify from 'vite-plugin-fastify';
import fastifyRoutes from 'vite-plugin-fastify-routes';
import { viteStaticCopy as staticCopy } from 'vite-plugin-static-copy';

const { user, pass } = await nodemailer.createTestAccount();

Expand All @@ -29,6 +30,14 @@ export default defineConfig({
devMode: false,
}),
fastifyRoutes(),
staticCopy({
targets: [
{
src: resolve(__dirname, './src/jobs'),
dest: './',
},
],
}),
],
resolve: {
alias: {
Expand Down
Loading

0 comments on commit f83ab62

Please sign in to comment.