-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove index.js * mv /lib/schedulePlugin.js as index.js * fix export * add use strict * modify linting * add fastifySchedulePlugin as named export
- Loading branch information
Showing
3 changed files
with
26 additions
and
36 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 |
---|---|---|
@@ -1,15 +1,28 @@ | ||
const { fastifySchedulePlugin } = require("./lib/schedulePlugin"); | ||
"use strict"; | ||
|
||
const { ToadScheduler } = require("toad-scheduler"); | ||
const fp = require("fastify-plugin"); | ||
|
||
function plugin(fastify, opts, next) { | ||
const scheduler = new ToadScheduler(); | ||
fastify.decorate("scheduler", scheduler); | ||
|
||
fastify.addHook("onClose", (fastify, done) => { | ||
scheduler.stop(); | ||
done(); | ||
}); | ||
|
||
next(); | ||
} | ||
|
||
const fastifySchedulePlugin = fp(plugin, { | ||
fastify: "4.x", | ||
name: "@fastify/schedule", | ||
}); | ||
|
||
module.exports = fastifySchedulePlugin; | ||
|
||
/** | ||
* These export configurations enable JS and TS developers | ||
* to consume fastify-schedule in whatever way best suits their needs. | ||
* Some examples of supported import syntax includes: | ||
* - `const fastifySchedulePlugin = require('fastify-schedule')` | ||
* - `const { fastifySchedulePlugin } = require('fastify-schedule')` | ||
* - `import * as fastifySchedulePlugin from 'fastify-schedule'` | ||
* - `import { fastifySchedulePlugin } from 'fastify-schedule'` | ||
* - `import fastifySchedulePlugin from 'fastify-schedule'` | ||
* TODO: Should be removed in the next major release | ||
*/ | ||
fastifySchedulePlugin.fastifySchedulePlugin = fastifySchedulePlugin; | ||
fastifySchedulePlugin.default = fastifySchedulePlugin; | ||
module.exports = fastifySchedulePlugin; | ||
module.exports.fastifySchedulePlugin = fastifySchedulePlugin; |
This file was deleted.
Oops, something went wrong.
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