-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from mikevalstar/feat/fix-extensions
feat: allow resiliency with accepted extensions
- Loading branch information
Showing
9 changed files
with
118 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ coverage | |
locales/ | ||
package-lock.json | ||
yarn.lock | ||
examples/**/dist | ||
|
||
Thumbs.db | ||
tmp/ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import process from 'node:process'; | ||
import * as path from 'node:path'; | ||
import Bree from 'bree'; | ||
|
||
const bree = new Bree({ | ||
/** | ||
* Always set the root option when doing any type of | ||
* compiling with bree. This just makes it clearer where | ||
* bree should resolve the jobs folder from. By default it | ||
* resolves to the jobs folder relative to where the program | ||
* is executed. | ||
*/ | ||
root: path.join(__dirname, 'jobs'), | ||
/** | ||
* We only need the default extension to be "ts" | ||
* when we are running the app with ts-node - otherwise | ||
* the compiled-to-js code still needs to use JS | ||
*/ | ||
defaultExtension: process.env.TS_NODE ? 'ts' : 'js', | ||
acceptedExtensions: ['.ts', '.js'], | ||
jobs: [ | ||
{ cron: '* * * * *', name: 'job' }, | ||
{ cron: '* * * * *', name: 'defaults' } | ||
] | ||
}); | ||
|
||
(async () => { | ||
await bree.start(); | ||
})(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { parentPort } from 'node:worker_threads'; | ||
import process from 'node:process'; | ||
|
||
console.log('Hello TypeScript Defaults!'); | ||
|
||
// signal to parent that the job is done | ||
if (parentPort) parentPort.postMessage('done'); | ||
// eslint-disable-next-line unicorn/no-process-exit | ||
else process.exit(0); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { parentPort } from 'node:worker_threads'; | ||
import process from 'node:process'; | ||
|
||
console.log('Hello TypeScript!'); | ||
|
||
// signal to parent that the job is done | ||
if (parentPort) parentPort.postMessage('done'); | ||
// eslint-disable-next-line unicorn/no-process-exit | ||
else process.exit(0); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "bree-js-example-jobserver", | ||
"version": "1.0.0", | ||
"description": "basic bree typescript jobserver example", | ||
"main": "index.ts", | ||
"author": "Mike Valstar <[email protected]> (https://valstar.dev/)", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@tsconfig/node20": "^20.1.2", | ||
"@types/node": "^20.8.0", | ||
"ts-node": "^10.9.1", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.2" | ||
}, | ||
"scripts": { | ||
"dev": "TS_NODE=true NODE_OPTIONS=\"-r ts-node/register\" node index.ts", | ||
"start": "rm -rf dist && tsc && node dist/index.js" | ||
}, | ||
"dependencies": { | ||
"bree": "latest" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "@tsconfig/node20/tsconfig.json", | ||
"include": ["**/*.ts", "jobs/index.js"], | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"moduleResolution": "NodeNext", | ||
"esModuleInterop": true | ||
} | ||
} |
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
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
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