diesel-core 0.0.21 → 0.0.22

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/example/tester.js CHANGED
@@ -1,88 +1,88 @@
1
- import Diesel from "../dist/main";
2
- import jwt from "jsonwebtoken";
3
-
4
- const app = new Diesel();
5
- const secret = "secret";
6
-
7
- // app.filter().permitAll().require()
8
-
9
- app.get("/r", (xl) => {
10
- return xl.html(`${import.meta.dir}/index.html`);
11
- });
12
-
13
- // app.use((xl) => {
14
- // const cok = xl.getCookie('accessToken');
15
-
16
- // if (cok) {
17
- // try {
18
- // const vcok = jwt.verify(cok, secret);
19
- // xl.setAuth(true);
20
- // xl.set('user',vcok)
21
- // } catch (error) {
22
- // // console.log('Token verification failed:', error);
23
- // xl.setAuth(false);
24
- // }
25
- // } else {
26
- // xl.setAuth(false);
27
- // }
28
-
29
- // return null;
30
- // });
31
-
32
- // app.use(h)
33
- // Main route handler for "/"
34
-
35
- // app.addHooks('onRequest',(xl)=>{
36
- // console.log('on req hooks');
37
- // })
38
-
39
- // app.filter()
40
-
41
- app.get("/", async (xl) => {
42
- return xl.status(200).text("hello d")
43
- })
44
-
45
- app.post("/", async (xl) => {
46
- const body = await xl.body();
47
- return new Response(JSON.stringify(body)); // This will log the parsed body content
48
- });
49
-
50
- app.get("/c", async(xl) => {
51
- const user = {
52
- name: "pk",
53
- age: 22,
54
- };
55
-
56
- const accessToken = jwt.sign(user, secret, { expiresIn: "1d" });
57
- const refreshToken = jwt.sign(user, secret, { expiresIn: "10d" });
58
- const options = {
59
- httpOnly: true, // Makes cookie accessible only by the web server (not JS)
60
- secure: true, // Ensures the cookie is sent over HTTPS
61
- maxAge: 24 * 60 * 60 * 1000, // 1 day in milliseconds
62
- sameSite: "Strict", // Prevents CSRF (strict origin policy)
63
- path: "/", // Cookie available for all routes
64
- };
65
- await xl.cookie("accessToken", accessToken, options)
66
- await xl.cookie("refreshToken", refreshToken, options)
67
- // xl.cookie("refreshToken", refreshToken, options);
68
- await xl.getCookie()
69
- return xl.json({msg:"setting cookies"})
70
- });
71
-
72
- // For "/test", middlewares h, s will run before the handler
73
- app.get("/test/:id", async (xl) => {
74
- const q = xl.getQuery();
75
- const params = xl.getParams('id');
76
- return new Response(JSON.stringify({ msg: "hello world", q, params }));
77
- });
78
-
79
- // For "/ok", only middleware h will run before the handler
80
- app.get("/redirect", (xl) => {
81
- return xl.redirect("/");
82
- });
83
-
84
- import userRoute from "./route.js";
85
-
86
- app.register("/api/user", userRoute);
87
-
88
- app.listen(3000);
1
+ import Diesel from "../dist/main";
2
+ import jwt from "jsonwebtoken";
3
+
4
+ const app = new Diesel();
5
+ const secret = "secret";
6
+
7
+ // app.filter().permitAll().require()
8
+
9
+ app.get("/r", (xl) => {
10
+ return xl.file(`${import.meta.dir}/index.html`);
11
+ });
12
+
13
+ // app.use((xl) => {
14
+ // const cok = xl.getCookie('accessToken');
15
+
16
+ // if (cok) {
17
+ // try {
18
+ // const vcok = jwt.verify(cok, secret);
19
+ // xl.setAuth(true);
20
+ // xl.set('user',vcok)
21
+ // } catch (error) {
22
+ // // console.log('Token verification failed:', error);
23
+ // xl.setAuth(false);
24
+ // }
25
+ // } else {
26
+ // xl.setAuth(false);
27
+ // }
28
+
29
+ // return null;
30
+ // });
31
+
32
+ // app.use(h)
33
+ // Main route handler for "/"
34
+
35
+ // app.addHooks('onRequest',(xl)=>{
36
+ // console.log('on req hooks');
37
+ // })
38
+
39
+ // app.filter()
40
+
41
+ app.get("/", async (xl) => {
42
+ return xl.text("hello d")
43
+ })
44
+
45
+ app.post("/", async (xl) => {
46
+ const body = await xl.body();
47
+ return new Response(JSON.stringify(body)); // This will log the parsed body content
48
+ });
49
+
50
+ app.get("/c", async(xl) => {
51
+ const user = {
52
+ name: "pk",
53
+ age: 22,
54
+ };
55
+
56
+ const accessToken = jwt.sign(user, secret, { expiresIn: "1d" });
57
+ const refreshToken = jwt.sign(user, secret, { expiresIn: "10d" });
58
+ const options = {
59
+ httpOnly: true, // Makes cookie accessible only by the web server (not JS)
60
+ secure: true, // Ensures the cookie is sent over HTTPS
61
+ maxAge: 24 * 60 * 60 * 1000, // 1 day in milliseconds
62
+ sameSite: "Strict", // Prevents CSRF (strict origin policy)
63
+ path: "/", // Cookie available for all routes
64
+ };
65
+ await xl.cookie("accessToken", accessToken, options)
66
+ await xl.cookie("refreshToken", refreshToken, options)
67
+ // xl.cookie("refreshToken", refreshToken, options);
68
+ await xl.getCookie()
69
+ return xl.json({msg:"setting cookies"})
70
+ });
71
+
72
+ // For "/test", middlewares h, s will run before the handler
73
+ app.get("/test/:id", async (xl) => {
74
+ const q = xl.getQuery();
75
+ const params = xl.getParams('id');
76
+ return new Response(JSON.stringify({ msg: "hello world", q, params }));
77
+ });
78
+
79
+ // For "/ok", only middleware h will run before the handler
80
+ app.get("/redirect", (xl) => {
81
+ return xl.redirect("/");
82
+ });
83
+
84
+ import userRoute from "./route.js";
85
+
86
+ app.register("/api/user", userRoute);
87
+
88
+ app.listen(3000);
@@ -1,16 +1,16 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES6", // Specify ECMAScript target version
4
- "module": "commonjs", // Specify module code generation
5
- "outDir": "./dist", // Redirect output structure to the 'dist' directory
6
- "rootDir": ".",
7
- "declaration": true,
8
- // "emitDeclarationOnly": true, // Specify the root directory of input files
9
- "strict": true, // Enable all strict type-checking options
10
- "esModuleInterop": true, // Enables emit interoperability between CommonJS and ES Modules
11
- "skipLibCheck": true, // Skip type checking of declaration files
12
- "forceConsistentCasingInFileNames": true // Disallow inconsistently-cased references to the same file
13
- },
14
- "include": ["./*.ts"], // Specify the files to include
15
- "exclude": ["node_modules"] // Exclude the 'node_modules' directory
16
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6", // Specify ECMAScript target version
4
+ "module": "commonjs", // Specify module code generation
5
+ "outDir": "./dist", // Redirect output structure to the 'dist' directory
6
+ "rootDir": ".",
7
+ "declaration": true,
8
+ // "emitDeclarationOnly": true, // Specify the root directory of input files
9
+ "strict": true, // Enable all strict type-checking options
10
+ "esModuleInterop": true, // Enables emit interoperability between CommonJS and ES Modules
11
+ "skipLibCheck": true, // Skip type checking of declaration files
12
+ "forceConsistentCasingInFileNames": true // Disallow inconsistently-cased references to the same file
13
+ },
14
+ "include": ["./*.ts"], // Specify the files to include
15
+ "exclude": ["node_modules"] // Exclude the 'node_modules' directory
16
+ }
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './dist/types';
2
-
3
- export { default as Diesel } from './dist/main';
4
- export { default as Router } from './dist/route';
5
- export { default as rateLimit } from './dist/utils';
1
+ export * from './dist/types';
2
+
3
+ export { default as Diesel } from './dist/main';
4
+ export { default as Router } from './dist/route';
5
+ export { default as rateLimit } from './dist/utils';
package/index.js CHANGED
@@ -1,10 +1,9 @@
1
- import Diesel from './src/main'
2
- import Router from './src/route'
3
- import rateLimit from './src/utils'
4
-
5
-
6
- export {
7
- Diesel,
8
- Router,
9
- rateLimit
1
+ import Diesel from './dist/main'
2
+ // import Router from './src/route'
3
+ import rateLimit from './dist/utils'
4
+
5
+
6
+ export {
7
+ Diesel,
8
+ rateLimit
10
9
  }
package/jsconfig.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "compilerOptions": {
3
- // Enable latest features
4
- "lib": ["ESNext", "DOM"],
5
- "target": "ESNext",
6
- "module": "ESNext",
7
- "moduleDetection": "force",
8
- "jsx": "react-jsx",
9
- "allowJs": true,
10
- "outDir":"dist",
11
-
12
- // Bundler mode
13
- "moduleResolution": "bundler",
14
- "allowImportingTsExtensions": true,
15
- "verbatimModuleSyntax": true,
16
- "noEmit": true,
17
-
18
- // Best practices
19
- "strict": true,
20
- "skipLibCheck": true,
21
- "noFallthroughCasesInSwitch": true,
22
-
23
- // Some stricter flags (disabled by default)
24
- "noUnusedLocals": false,
25
- "noUnusedParameters": false,
26
- "noPropertyAccessFromIndexSignature": false
27
- }
28
- }
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+ "outDir":"dist",
11
+
12
+ // Bundler mode
13
+ "moduleResolution": "bundler",
14
+ "allowImportingTsExtensions": true,
15
+ "verbatimModuleSyntax": true,
16
+ "noEmit": true,
17
+
18
+ // Best practices
19
+ "strict": true,
20
+ "skipLibCheck": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+
23
+ // Some stricter flags (disabled by default)
24
+ "noUnusedLocals": false,
25
+ "noUnusedParameters": false,
26
+ "noPropertyAccessFromIndexSignature": false
27
+ }
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diesel-core",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "scripts": {