Skip to content

Commit 0eb9fbb

Browse files
committed
🧹 chore: bump version
1 parent ff19a5c commit 0eb9fbb

File tree

6 files changed

+139
-99
lines changed

6 files changed

+139
-99
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11

2+
# 1.0.2 - 18 Mar 2024
3+
Change:
4+
- Add support for Elysia 1.0
5+
6+
7+
# 1.0.0 - 16 Mar 2024
8+
Change:
9+
- Add support for Elysia 1.0
10+
11+
12+
# 1.0.0-rc.0 - 1 Mar 2024
13+
Change:
14+
- Add support for Elysia 1.0
15+
16+
17+
# 1.0.0-beta.1 - 17 Feb 2024
18+
Change:
19+
- Add support for Elysia 1.0
20+
21+
22+
# 1.0.0-beta.0 - 6 Feb 2024
23+
Change:
24+
- Add support for Elysia 1.0
25+
26+
27+
# 0.8.0 - 23 Dec 2023
28+
Change:
29+
- Add support for Elysia 0.8
30+
31+
232
# 0.8.0-rc.0 - 15 Dec 2023
333
Change:
434
- Add support for Elysia 0.8

bun.lockb

1.89 KB
Binary file not shown.

package.json

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
{
2-
"name": "@elysiajs/cron",
3-
"version": "0.8.0",
4-
"description": "Plugin for Elysia that add support for running cronjob",
5-
"author": {
6-
"name": "saltyAom",
7-
"url": "https://github.com/SaltyAom",
8-
"email": "[email protected]"
9-
},
10-
"main": "./src/index.ts",
11-
"exports": {
12-
"bun": "./dist/index.js",
13-
"node": "./dist/cjs/index.js",
14-
"require": "./dist/cjs/index.js",
15-
"import": "./dist/index.js",
16-
"default": "./dist/index.js"
17-
},
18-
"types": "./src/index.ts",
19-
"keywords": [
20-
"elysia",
21-
"cron"
22-
],
23-
"homepage": "https://github.com/elysiajs/elysia-cron",
24-
"repository": {
25-
"type": "git",
26-
"url": "https://github.com/elysiajs/elysia-cron"
27-
},
28-
"bugs": "https://github.com/elysiajs/elysia-cron/issues",
29-
"license": "MIT",
30-
"scripts": {
31-
"dev": "bun run --hot example/index.ts",
32-
"test": "bun test && npm run test:node",
33-
"test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
34-
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
35-
"release": "npm run build && npm run test && npm publish --access public"
36-
},
37-
"peerDependencies": {
38-
"elysia": ">= 0.8.0"
39-
},
40-
"devDependencies": {
41-
"@types/node": "^20.1.4",
42-
"@typescript-eslint/eslint-plugin": "^5.59.5",
43-
"@typescript-eslint/parser": "^5.59.5",
44-
"bun-types": "^0.5.8",
45-
"elysia": "0.8.0",
46-
"eslint": "^8.40.0",
47-
"rimraf": "4.3",
48-
"typescript": "^5.0.4"
49-
},
50-
"dependencies": {
51-
"croner": "^6.0.3"
52-
},
53-
"peerDependenciesMeta": {
54-
"croner": {
55-
"optional": true
56-
}
2+
"name": "@elysiajs/cron",
3+
"version": "1.0.2",
4+
"description": "Plugin for Elysia that add support for running cronjob",
5+
"author": {
6+
"name": "saltyAom",
7+
"url": "https://github.com/SaltyAom",
8+
"email": "[email protected]"
9+
},
10+
"main": "./src/index.ts",
11+
"exports": {
12+
"bun": "./dist/index.js",
13+
"node": "./dist/cjs/index.js",
14+
"require": "./dist/cjs/index.js",
15+
"import": "./dist/index.js",
16+
"default": "./dist/index.js"
17+
},
18+
"types": "./src/index.ts",
19+
"keywords": [
20+
"elysia",
21+
"cron"
22+
],
23+
"homepage": "https://github.com/elysiajs/elysia-cron",
24+
"repository": {
25+
"type": "git",
26+
"url": "https://github.com/elysiajs/elysia-cron"
27+
},
28+
"bugs": "https://github.com/elysiajs/elysia-cron/issues",
29+
"license": "MIT",
30+
"scripts": {
31+
"dev": "bun run --hot example/index.ts",
32+
"test": "bun test && npm run test:node",
33+
"test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
34+
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
35+
"release": "npm run build && npm run test && npm publish --access public"
36+
},
37+
"peerDependencies": {
38+
"elysia": ">= 1.0.2"
39+
},
40+
"devDependencies": {
41+
"@types/bun": "^1.0.4",
42+
"@types/node": "^20.1.4",
43+
"@typescript-eslint/eslint-plugin": "^5.59.5",
44+
"@typescript-eslint/parser": "^5.59.5",
45+
"elysia": "1.0.2",
46+
"eslint": "^8.40.0",
47+
"rimraf": "4.3",
48+
"typescript": "^5.0.4"
49+
},
50+
"dependencies": {
51+
"croner": "^6.0.3"
52+
},
53+
"peerDependenciesMeta": {
54+
"croner": {
55+
"optional": true
5756
}
57+
}
5858
}

src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ export const cron =
3939
if (!pattern) throw new Error('pattern is required')
4040
if (!name) throw new Error('name is required')
4141

42-
return app.state(store => {
43-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
44-
// @ts-ignore
45-
const prevCron = app.store?.cron ?? {}
42+
return app.state((store) => {
43+
// @ts-expect-error private property
44+
const prevCron = app.singleton.store?.cron ?? {}
4645
return {
4746
...store,
4847
cron: {
4948
...prevCron,
50-
[name]: new Cron(pattern, options, () => run(app.store as any)),
49+
[name]: new Cron(pattern, options, () =>
50+
// @ts-expect-error private property
51+
run(app.singleton.store as any)
52+
)
5153
} as Record<Name, Cron>
5254
}
5355
})

test/index.test.ts

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
12
import { Elysia } from 'elysia'
23
import { cron } from '../src'
34

@@ -35,7 +36,8 @@ describe('Cron', () => {
3536
})
3637
)
3738

38-
expect(Object.keys(app.store.cron)[0]).toBe('job')
39+
// @ts-expect-error
40+
expect(Object.keys(app.singleton.store.cron)[0]).toBe('job')
3941
})
4042

4143
it('stop cronjob', async () => {
@@ -68,23 +70,25 @@ describe('Mutli Cron', () => {
6870
let done1 = false
6971
let done2 = false
7072

71-
new Elysia().use(
72-
cron({
73-
pattern: '*/1 * * * * *',
74-
name: 'job1',
75-
run() {
76-
done1 = true
77-
}
78-
})
79-
).use(
80-
cron({
81-
pattern: '*/1 * * * * *',
82-
name: 'job2',
83-
run() {
84-
done2 = true
85-
}
86-
})
87-
)
73+
new Elysia()
74+
.use(
75+
cron({
76+
pattern: '*/1 * * * * *',
77+
name: 'job1',
78+
run() {
79+
done1 = true
80+
}
81+
})
82+
)
83+
.use(
84+
cron({
85+
pattern: '*/1 * * * * *',
86+
name: 'job2',
87+
run() {
88+
done2 = true
89+
}
90+
})
91+
)
8892

8993
await new Promise((resolve) => setTimeout(resolve, 1100))
9094

@@ -93,26 +97,30 @@ describe('Mutli Cron', () => {
9397
})
9498

9599
it('add cronjobs to store', async () => {
96-
const app = new Elysia().use(
97-
cron({
98-
pattern: '*/1 * * * * *',
99-
name: 'job1',
100-
run() {
101-
// Not empty
102-
}
103-
})
104-
).use(
105-
cron({
106-
pattern: '*/1 * * * * *',
107-
name: 'job2',
108-
run() {
109-
// Not empty
110-
}
111-
})
112-
)
100+
const app = new Elysia()
101+
.use(
102+
cron({
103+
pattern: '*/1 * * * * *',
104+
name: 'job1',
105+
run() {
106+
// Not empty
107+
}
108+
})
109+
)
110+
.use(
111+
cron({
112+
pattern: '*/1 * * * * *',
113+
name: 'job2',
114+
run() {
115+
// Not empty
116+
}
117+
})
118+
)
113119

114-
expect(Object.keys(app.store.cron)[0]).toBe('job1')
115-
expect(Object.keys(app.store.cron)[1]).toBe('job2')
120+
// @ts-expect-error
121+
expect(Object.keys(app.singleton.store.cron)[0]).toBe('job1')
122+
// @ts-expect-error
123+
expect(Object.keys(app.singleton.store.cron)[1]).toBe('job2')
116124
})
117125

118126
it('stop cronjobs', async () => {
@@ -128,7 +136,8 @@ describe('Mutli Cron', () => {
128136
done1 = true
129137
}
130138
})
131-
).use(
139+
)
140+
.use(
132141
cron({
133142
pattern: '*/1 * * * * *',
134143
name: 'job2',

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
3333
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
3434
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35-
"types": ["bun-types"], /* Specify type package names to be included without being referenced in a source file. */
3635
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
3736
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
3837
// "resolveJsonModule": true, /* Enable importing .json files. */

0 commit comments

Comments
 (0)