oc-template-preact-compiler 0.7.5 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-template-preact-compiler",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "Compiler for the Preact OC template",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/react": "^14.0.0",
35
35
  "@testing-library/user-event": "^14.4.3",
36
36
  "jsdom": "^21.1.1",
37
- "oc-server": "^1.1.1",
37
+ "oc-server": "^1.1.3",
38
38
  "oc-template-preact-compiler": "^0.7.5",
39
39
  "preact": "^10.13.2",
40
40
  "typescript": "5.0.2",
@@ -19,29 +19,31 @@ async function getFunFact(year: number) {
19
19
  return yearsFunFactDatabase[year];
20
20
  }
21
21
 
22
- export const server = new Server(async (params: { userId: number }) => {
23
- const { userId } = params;
24
- const user = await getUser(userId);
25
- const [firstName, lastName] = user.name.split(/\s+/);
26
-
27
- if (firstName === 'Invalid') {
28
- return;
29
- }
30
-
31
- return {
32
- firstName,
33
- lastName,
34
- born: user.born,
35
- hobbies: user.hobbies,
36
- };
37
- }).action('funFact', async (params: { year: number }) => {
38
- const { year } = params;
39
- const funFact = await getFunFact(year);
40
-
41
- return {
42
- funFact,
43
- };
44
- });
22
+ export const server = new Server()
23
+ .handler(async (params: { userId: number }) => {
24
+ const { userId } = params;
25
+ const user = await getUser(userId);
26
+ const [firstName, lastName] = user.name.split(/\s+/);
27
+
28
+ if (firstName === 'Invalid') {
29
+ return;
30
+ }
31
+
32
+ return {
33
+ firstName,
34
+ lastName,
35
+ born: user.born,
36
+ hobbies: user.hobbies,
37
+ };
38
+ })
39
+ .action('funFact', async (params: { year: number }) => {
40
+ const { year } = params;
41
+ const funFact = await getFunFact(year);
42
+
43
+ return {
44
+ funFact,
45
+ };
46
+ });
45
47
 
46
48
  declare module 'oc-server' {
47
49
  interface Register {