eser 3.0.0 → 3.0.1

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.
@@ -1,4 +1,4 @@
1
- import hizliApi from "./hizli-api.js";
1
+ import hizliApi from "./hizli-api.ts";
2
2
 
3
3
  hizliApi({
4
4
  isim: "defterdar",
@@ -1,8 +1,31 @@
1
1
  import { Hono } from "hono";
2
2
 
3
+ export interface Options {
4
+ isim?: string;
5
+ mesajlar?: {
6
+ hosgeldin?: string;
7
+ basarili?: string;
8
+ basarisiz?: string;
9
+ };
10
+ nesneler?: string[];
11
+ }
12
+
13
+ export interface Config {
14
+ options: {
15
+ name: string;
16
+ messages: {
17
+ welcome: string;
18
+ success: string;
19
+ fail: string;
20
+ };
21
+ items: string[];
22
+ };
23
+ }
24
+
3
25
  const kv = await Deno.openKv();
4
26
 
5
- export function routeHome(config, ctx) {
27
+ // deno-lint-ignore no-explicit-any
28
+ export function routeHome(config: Config, ctx: any) {
6
29
  return ctx.json({
7
30
  system: config.options.name,
8
31
  motd: config.options.messages.welcome,
@@ -14,7 +37,8 @@ export function routeHome(config, ctx) {
14
37
  });
15
38
  }
16
39
 
17
- export async function routeItem(item, config, ctx) {
40
+ // deno-lint-ignore no-explicit-any
41
+ export async function routeItem(item: any, ctx: any) {
18
42
  const itemKey = ["items", item];
19
43
 
20
44
  const getResult = await kv.get(itemKey);
@@ -23,11 +47,13 @@ export async function routeItem(item, config, ctx) {
23
47
  return ctx.json(records);
24
48
  }
25
49
 
26
- export async function routeItemsAdd(item, config, ctx) {
50
+ // deno-lint-ignore no-explicit-any
51
+ export async function routeItemsAdd(item: any, ctx: any) {
27
52
  const itemKey = ["items", item];
28
53
 
29
54
  const getResult = await kv.get(itemKey);
30
- const records = getResult?.value ?? [];
55
+ // deno-lint-ignore no-explicit-any
56
+ const records: any = getResult?.value ?? [];
31
57
 
32
58
  const value = ctx.req.param("value");
33
59
  records.push(value);
@@ -37,7 +63,8 @@ export async function routeItemsAdd(item, config, ctx) {
37
63
  return ctx.redirect(`/${item}`);
38
64
  }
39
65
 
40
- export async function routeItemsClear(item, config, ctx) {
66
+ // deno-lint-ignore no-explicit-any
67
+ export async function routeItemsClear(item: any, ctx: any) {
41
68
  const itemKey = ["items", item];
42
69
 
43
70
  await kv.set(itemKey, []);
@@ -45,7 +72,7 @@ export async function routeItemsClear(item, config, ctx) {
45
72
  return ctx.redirect(`/${item}`);
46
73
  }
47
74
 
48
- export function validateConfig(options) {
75
+ export function validateConfig(options: Options) {
49
76
  return {
50
77
  options: {
51
78
  name: options?.isim ?? "hizli-api",
@@ -60,16 +87,16 @@ export function validateConfig(options) {
60
87
  };
61
88
  }
62
89
 
63
- export function hizliApi(options) {
90
+ export function hizliApi(options: Options) {
64
91
  const config = validateConfig(options);
65
92
 
66
93
  const app = new Hono();
67
94
 
68
95
  app.get("/", (ctx) => routeHome(config, ctx));
69
96
  for (const item of config.options.items) {
70
- app.get(`/${item}`, (ctx) => routeItem(item, config, ctx));
71
- app.get(`/${item}/add/:value`, (ctx) => routeItemsAdd(item, config, ctx));
72
- app.get(`/${item}/clear`, (ctx) => routeItemsClear(item, config, ctx));
97
+ app.get(`/${item}`, (ctx) => routeItem(item, ctx));
98
+ app.get(`/${item}/add/:value`, (ctx) => routeItemsAdd(item, ctx));
99
+ app.get(`/${item}/clear`, (ctx) => routeItemsClear(item, ctx));
73
100
  }
74
101
 
75
102
  Deno.serve(app.fetch);
package/mod.js CHANGED
@@ -1,3 +0,0 @@
1
- export function add(a, b) {
2
- return a + b;
3
- }
package/package.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
2
  "name": "eser",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "",
5
5
  "type": "module",
6
- "main": "main.js",
7
- "module": "mod.js",
8
6
  "scripts": {
9
7
  "start": "node main.js"
10
8
  },
@@ -12,7 +10,7 @@
12
10
  "license": "Apache-2.0",
13
11
  "exports": {
14
12
  ".": "./mod.js",
15
- "./hizli-api": "./hizli-api.js"
13
+ "./hizli-api": "./hizli-api.ts"
16
14
  },
17
15
  "dependencies": {
18
16
  "hono": "3.10.1"
package/main.js DELETED
@@ -1,5 +0,0 @@
1
- import { add } from "./mod.js";
2
-
3
- if (import.meta.main === undefined || import.meta.main) {
4
- console.log("Add 2 + 3 =", add(2, 3));
5
- }
package/mod_test.js DELETED
@@ -1,5 +0,0 @@
1
- import { add } from "./mod.js";
2
-
3
- Deno.test(function addTest() {
4
- assertEquals(add(2, 3), 5);
5
- });