eser 3.0.4 → 4.0.2

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,25 +1,12 @@
1
1
  {
2
2
  "name": "eser",
3
- "version": "3.0.4",
4
- "description": "",
3
+ "version": "4.0.2",
5
4
  "type": "module",
6
- "author": "Eser Ozvataf",
7
- "license": "Apache-2.0",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/mod.js",
11
- "require": "./dist/mod.js"
12
- },
13
- "./hizli-api": {
14
- "import": "./dist/hizli-api.js",
15
- "require": "./dist/hizli-api.js",
16
- "types": "./dist/hizli-api.d.ts"
17
- }
5
+ "bin": {
6
+ "eser": "./eser.js"
18
7
  },
19
- "dependencies": {
20
- "hono": "^3.10.1"
21
- },
22
- "devDependencies": {
23
- "@deno/shim-deno": "^0.17.0"
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/eser/stack"
24
11
  }
25
12
  }
package/deno.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "imports": {
3
- "hono": "npm:hono@3.10.1"
4
- },
5
- "tasks": {
6
- "dev": "deno run --unstable-kv --allow-net --watch main.js",
7
- "start": "deno run --unstable-kv --allow-net main.js"
8
- }
9
- }
@@ -1,37 +0,0 @@
1
- export interface Options {
2
- isim?: string;
3
- mesajlar?: {
4
- hosgeldin?: string;
5
- basarili?: string;
6
- basarisiz?: string;
7
- };
8
- nesneler?: string[];
9
- }
10
- export interface Config {
11
- options: {
12
- name: string;
13
- messages: {
14
- welcome: string;
15
- success: string;
16
- fail: string;
17
- };
18
- items: string[];
19
- };
20
- }
21
- export declare function routeHome(config: Config, ctx: any): any;
22
- export declare function routeItem(item: any, ctx: any): Promise<any>;
23
- export declare function routeItemsAdd(item: any, ctx: any): Promise<any>;
24
- export declare function routeItemsClear(item: any, ctx: any): Promise<any>;
25
- export declare function validateConfig(options: Options): {
26
- options: {
27
- name: string;
28
- messages: {
29
- welcome: string;
30
- success: string;
31
- fail: string;
32
- };
33
- items: string[];
34
- };
35
- };
36
- export declare function hizliApi(options: Options): void;
37
- export { hizliApi as default };
package/dist/hizli-api.js DELETED
@@ -1,67 +0,0 @@
1
- import { Hono } from "hono";
2
- import { cors } from "hono/cors";
3
- const kv = await Deno.openKv();
4
- export function routeHome(config, ctx) {
5
- return ctx.json({
6
- system: config.options.name,
7
- motd: config.options.messages.welcome,
8
- items: config.options.items,
9
- commands: [
10
- "add",
11
- "clear",
12
- ],
13
- });
14
- }
15
- export async function routeItem(item, ctx) {
16
- var _a;
17
- const itemKey = ["items", item];
18
- const getResult = await kv.get(itemKey);
19
- const records = (_a = getResult === null || getResult === void 0 ? void 0 : getResult.value) !== null && _a !== void 0 ? _a : [];
20
- return ctx.json(records);
21
- }
22
- export async function routeItemsAdd(item, ctx) {
23
- var _a;
24
- const itemKey = ["items", item];
25
- const getResult = await kv.get(itemKey);
26
- const records = (_a = getResult === null || getResult === void 0 ? void 0 : getResult.value) !== null && _a !== void 0 ? _a : [];
27
- const value = ctx.req.param("value");
28
- records.push(value);
29
- await kv.set(itemKey, records);
30
- return ctx.redirect(`/${item}`);
31
- }
32
- export async function routeItemsClear(item, ctx) {
33
- const itemKey = ["items", item];
34
- await kv.set(itemKey, []);
35
- return ctx.redirect(`/${item}`);
36
- }
37
- export function validateConfig(options) {
38
- var _a, _b, _c, _d, _e, _f, _g, _h;
39
- return {
40
- options: {
41
- name: (_a = options === null || options === void 0 ? void 0 : options.isim) !== null && _a !== void 0 ? _a : "hizli-api",
42
- messages: {
43
- welcome: (_c = (_b = options === null || options === void 0 ? void 0 : options.mesajlar) === null || _b === void 0 ? void 0 : _b.hosgeldin) !== null && _c !== void 0 ? _c : "Hoş geldin!",
44
- success: (_e = (_d = options === null || options === void 0 ? void 0 : options.mesajlar) === null || _d === void 0 ? void 0 : _d.basarili) !== null && _e !== void 0 ? _e : "Başarılı",
45
- fail: (_g = (_f = options === null || options === void 0 ? void 0 : options.mesajlar) === null || _f === void 0 ? void 0 : _f.basarisiz) !== null && _g !== void 0 ? _g : "Başarısız",
46
- },
47
- items: (_h = options === null || options === void 0 ? void 0 : options.nesneler) !== null && _h !== void 0 ? _h : [],
48
- },
49
- };
50
- }
51
- export function hizliApi(options) {
52
- const config = validateConfig(options);
53
- const app = new Hono();
54
- app.use("*", cors({
55
- origin: "*",
56
- allowMethods: ["GET", "OPTIONS"],
57
- allowHeaders: ["Content-Type"],
58
- }));
59
- app.get("/", (ctx) => routeHome(config, ctx));
60
- for (const item of config.options.items) {
61
- app.get(`/${item}`, (ctx) => routeItem(item, ctx));
62
- app.get(`/${item}/add/:value`, (ctx) => routeItemsAdd(item, ctx));
63
- app.get(`/${item}/clear`, (ctx) => routeItemsClear(item, ctx));
64
- }
65
- Deno.serve(app.fetch);
66
- }
67
- export { hizliApi as default };
package/src/hizli-api.ts DELETED
@@ -1,113 +0,0 @@
1
- import { Hono } from "hono";
2
- import { cors } from "hono/cors";
3
-
4
- export interface Options {
5
- isim?: string;
6
- mesajlar?: {
7
- hosgeldin?: string;
8
- basarili?: string;
9
- basarisiz?: string;
10
- };
11
- nesneler?: string[];
12
- }
13
-
14
- export interface Config {
15
- options: {
16
- name: string;
17
- messages: {
18
- welcome: string;
19
- success: string;
20
- fail: string;
21
- };
22
- items: string[];
23
- };
24
- }
25
-
26
- // @ts-ignore Deno namespace
27
- const kv = await Deno.openKv();
28
-
29
- // deno-lint-ignore no-explicit-any
30
- export function routeHome(config: Config, ctx: any) {
31
- return ctx.json({
32
- system: config.options.name,
33
- motd: config.options.messages.welcome,
34
- items: config.options.items,
35
- commands: [
36
- "add",
37
- "clear",
38
- ],
39
- });
40
- }
41
-
42
- // deno-lint-ignore no-explicit-any
43
- export async function routeItem(item: any, ctx: any) {
44
- const itemKey = ["items", item];
45
-
46
- const getResult = await kv.get(itemKey);
47
- const records = getResult?.value ?? [];
48
-
49
- return ctx.json(records);
50
- }
51
-
52
- // deno-lint-ignore no-explicit-any
53
- export async function routeItemsAdd(item: any, ctx: any) {
54
- const itemKey = ["items", item];
55
-
56
- const getResult = await kv.get(itemKey);
57
- // deno-lint-ignore no-explicit-any
58
- const records: any = getResult?.value ?? [];
59
-
60
- const value = ctx.req.param("value");
61
- records.push(value);
62
-
63
- await kv.set(itemKey, records);
64
-
65
- return ctx.redirect(`/${item}`);
66
- }
67
-
68
- // deno-lint-ignore no-explicit-any
69
- export async function routeItemsClear(item: any, ctx: any) {
70
- const itemKey = ["items", item];
71
-
72
- await kv.set(itemKey, []);
73
-
74
- return ctx.redirect(`/${item}`);
75
- }
76
-
77
- export function validateConfig(options: Options) {
78
- return {
79
- options: {
80
- name: options?.isim ?? "hizli-api",
81
- messages: {
82
- welcome: options?.mesajlar?.hosgeldin ?? "Hoş geldin!",
83
- success: options?.mesajlar?.basarili ?? "Başarılı",
84
- fail: options?.mesajlar?.basarisiz ?? "Başarısız",
85
- },
86
-
87
- items: options?.nesneler ?? [],
88
- },
89
- };
90
- }
91
-
92
- export function hizliApi(options: Options) {
93
- const config = validateConfig(options);
94
-
95
- const app = new Hono();
96
- app.use("*", cors({
97
- origin: "*",
98
- allowMethods: ["GET", "OPTIONS"],
99
- allowHeaders: ["Content-Type"],
100
- }));
101
-
102
- app.get("/", (ctx) => routeHome(config, ctx));
103
- for (const item of config.options.items) {
104
- app.get(`/${item}`, (ctx) => routeItem(item, ctx));
105
- app.get(`/${item}/add/:value`, (ctx) => routeItemsAdd(item, ctx));
106
- app.get(`/${item}/clear`, (ctx) => routeItemsClear(item, ctx));
107
- }
108
-
109
- // @ts-ignore Deno namespace
110
- Deno.serve(app.fetch);
111
- }
112
-
113
- export { hizliApi as default };
package/src/mod.js DELETED
File without changes
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "./dist/",
4
- "declaration": true,
5
- "esModuleInterop": true,
6
- "module": "ES2022",
7
- "target": "ES2017",
8
- "moduleResolution": "bundler",
9
- "removeComments": true
10
- },
11
- "include": ["./src/**/*"],
12
- "exclude": ["./node_modules", "./**/*.test.ts"]
13
- }