mirror of
https://github.com/JonasunderscoreJones/api-worker.git
synced 2025-10-23 10:29:19 +02:00
Initial commit (by create-cloudflare CLI)
This commit is contained in:
commit
58a42872a0
1745 changed files with 741893 additions and 0 deletions
37
node_modules/exit-hook/index.d.ts
generated
vendored
Normal file
37
node_modules/exit-hook/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
Run some code when the process exits.
|
||||
|
||||
The `process.on('exit')` event doesn't catch all the ways a process can exit.
|
||||
|
||||
This package is useful for cleaning up before exiting.
|
||||
|
||||
@param callback - The callback to execute when the process exits.
|
||||
@returns A function that removes the hook when called.
|
||||
|
||||
@example
|
||||
```
|
||||
import exitHook = require('exit-hook');
|
||||
|
||||
exitHook(() => {
|
||||
console.log('Exiting');
|
||||
});
|
||||
|
||||
// You can add multiple hooks, even across files
|
||||
exitHook(() => {
|
||||
console.log('Exiting 2');
|
||||
});
|
||||
|
||||
throw new Error('🦄');
|
||||
|
||||
//=> 'Exiting'
|
||||
//=> 'Exiting 2'
|
||||
|
||||
// Removing an exit hook:
|
||||
const unsubscribe = exitHook(() => {});
|
||||
|
||||
unsubscribe();
|
||||
```
|
||||
*/
|
||||
declare function exitHook(callback: () => void): () => void;
|
||||
|
||||
export = exitHook;
|
46
node_modules/exit-hook/index.js
generated
vendored
Normal file
46
node_modules/exit-hook/index.js
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
'use strict';
|
||||
|
||||
const callbacks = new Set();
|
||||
let isCalled = false;
|
||||
let isRegistered = false;
|
||||
|
||||
function exit(exit, signal) {
|
||||
if (isCalled) {
|
||||
return;
|
||||
}
|
||||
|
||||
isCalled = true;
|
||||
|
||||
for (const callback of callbacks) {
|
||||
callback();
|
||||
}
|
||||
|
||||
if (exit === true) {
|
||||
process.exit(128 + signal); // eslint-disable-line unicorn/no-process-exit
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = callback => {
|
||||
callbacks.add(callback);
|
||||
|
||||
if (!isRegistered) {
|
||||
isRegistered = true;
|
||||
|
||||
process.once('exit', exit);
|
||||
process.once('SIGINT', exit.bind(null, true, 2));
|
||||
process.once('SIGTERM', exit.bind(null, true, 15));
|
||||
|
||||
// PM2 Cluster shutdown message. Caught to support async handlers with pm2, needed because
|
||||
// explicitly calling process.exit() doesn't trigger the beforeExit event, and the exit
|
||||
// event cannot support async handlers, since the event loop is never called after it.
|
||||
process.on('message', message => {
|
||||
if (message === 'shutdown') {
|
||||
exit(true, -128);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return () => {
|
||||
callbacks.delete(callback);
|
||||
};
|
||||
};
|
9
node_modules/exit-hook/license
generated
vendored
Normal file
9
node_modules/exit-hook/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
45
node_modules/exit-hook/package.json
generated
vendored
Normal file
45
node_modules/exit-hook/package.json
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "exit-hook",
|
||||
"version": "2.2.1",
|
||||
"description": "Run some code when the process exits",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/exit-hook",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"exit",
|
||||
"quit",
|
||||
"process",
|
||||
"hook",
|
||||
"graceful",
|
||||
"handler",
|
||||
"shutdown",
|
||||
"sigterm",
|
||||
"sigint",
|
||||
"terminate",
|
||||
"kill",
|
||||
"stop",
|
||||
"event",
|
||||
"signal"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"execa": "^1.0.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
67
node_modules/exit-hook/readme.md
generated
vendored
Normal file
67
node_modules/exit-hook/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
# exit-hook
|
||||
|
||||
> Run some code when the process exits
|
||||
|
||||
The `process.on('exit')` event doesn't catch all the ways a process can exit.
|
||||
|
||||
This package is useful for cleaning up before exiting.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install exit-hook
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const exitHook = require('exit-hook');
|
||||
|
||||
exitHook(() => {
|
||||
console.log('Exiting');
|
||||
});
|
||||
|
||||
// You can add multiple hooks, even across files
|
||||
exitHook(() => {
|
||||
console.log('Exiting 2');
|
||||
});
|
||||
|
||||
throw new Error('🦄');
|
||||
|
||||
//=> 'Exiting'
|
||||
//=> 'Exiting 2'
|
||||
```
|
||||
|
||||
Removing an exit hook:
|
||||
|
||||
```js
|
||||
const exitHook = require('exit-hook');
|
||||
|
||||
const unsubscribe = exitHook(() => {});
|
||||
|
||||
unsubscribe();
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### exitHook(callback)
|
||||
|
||||
Returns a function that removes the hook when called.
|
||||
|
||||
#### callback
|
||||
|
||||
Type: `Function`
|
||||
|
||||
The callback to execute when the process exits.
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-exit-hook?utm_source=npm-exit-hook&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue