tinny-backend 1.0.0 → 1.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.
Files changed (87) hide show
  1. package/dist/core/Request.d.ts +0 -1
  2. package/dist/core/Request.js +0 -1
  3. package/dist/core/Response.d.ts +0 -1
  4. package/dist/core/Response.js +0 -1
  5. package/dist/core/Server.d.ts +6 -3
  6. package/dist/core/Server.js +22 -270
  7. package/dist/core/types.d.ts +0 -1
  8. package/dist/core/types.js +0 -1
  9. package/dist/index.d.ts +7 -2
  10. package/dist/index.js +6 -10
  11. package/dist/utils/constants.d.ts +0 -1
  12. package/dist/utils/constants.js +0 -1
  13. package/dist/utils/version.d.ts +1 -0
  14. package/dist/utils/version.js +1 -0
  15. package/package.json +20 -38
  16. package/dist/admin/auth.d.ts +0 -2
  17. package/dist/admin/auth.d.ts.map +0 -1
  18. package/dist/admin/auth.js +0 -2
  19. package/dist/admin/auth.js.map +0 -1
  20. package/dist/admin/monitor.d.ts +0 -2
  21. package/dist/admin/monitor.d.ts.map +0 -1
  22. package/dist/admin/monitor.js +0 -2
  23. package/dist/admin/monitor.js.map +0 -1
  24. package/dist/admin/routes.d.ts +0 -2
  25. package/dist/admin/routes.d.ts.map +0 -1
  26. package/dist/admin/routes.js +0 -2
  27. package/dist/admin/routes.js.map +0 -1
  28. package/dist/app/index.d.ts +0 -2
  29. package/dist/app/index.d.ts.map +0 -1
  30. package/dist/app/index.js +0 -19
  31. package/dist/app/index.js.map +0 -1
  32. package/dist/core/Request.d.ts.map +0 -1
  33. package/dist/core/Request.js.map +0 -1
  34. package/dist/core/Response.d.ts.map +0 -1
  35. package/dist/core/Response.js.map +0 -1
  36. package/dist/core/Server.d.ts.map +0 -1
  37. package/dist/core/Server.js.map +0 -1
  38. package/dist/core/types.d.ts.map +0 -1
  39. package/dist/core/types.js.map +0 -1
  40. package/dist/examples/example.d.ts +0 -2
  41. package/dist/examples/example.d.ts.map +0 -1
  42. package/dist/examples/example.js +0 -11
  43. package/dist/examples/example.js.map +0 -1
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/index.js.map +0 -1
  46. package/dist/server.d.ts +0 -127
  47. package/dist/server.d.ts.map +0 -1
  48. package/dist/server.js +0 -625
  49. package/dist/server.js.map +0 -1
  50. package/dist/src/admin/auth.d.ts +0 -13
  51. package/dist/src/admin/auth.d.ts.map +0 -1
  52. package/dist/src/admin/auth.js +0 -60
  53. package/dist/src/admin/auth.js.map +0 -1
  54. package/dist/src/admin/monitor.d.ts +0 -3
  55. package/dist/src/admin/monitor.d.ts.map +0 -1
  56. package/dist/src/admin/monitor.js +0 -83
  57. package/dist/src/admin/monitor.js.map +0 -1
  58. package/dist/src/admin/routes.d.ts +0 -14
  59. package/dist/src/admin/routes.d.ts.map +0 -1
  60. package/dist/src/admin/routes.js +0 -150
  61. package/dist/src/admin/routes.js.map +0 -1
  62. package/dist/src/core/Request.d.ts +0 -4
  63. package/dist/src/core/Request.d.ts.map +0 -1
  64. package/dist/src/core/Request.js +0 -24
  65. package/dist/src/core/Request.js.map +0 -1
  66. package/dist/src/core/Response.d.ts +0 -4
  67. package/dist/src/core/Response.d.ts.map +0 -1
  68. package/dist/src/core/Response.js +0 -78
  69. package/dist/src/core/Response.js.map +0 -1
  70. package/dist/src/core/Server.d.ts +0 -34
  71. package/dist/src/core/Server.d.ts.map +0 -1
  72. package/dist/src/core/Server.js +0 -290
  73. package/dist/src/core/Server.js.map +0 -1
  74. package/dist/src/core/types.d.ts +0 -89
  75. package/dist/src/core/types.d.ts.map +0 -1
  76. package/dist/src/core/types.js +0 -3
  77. package/dist/src/core/types.js.map +0 -1
  78. package/dist/src/index.d.ts +0 -16
  79. package/dist/src/index.d.ts.map +0 -1
  80. package/dist/src/index.js +0 -17
  81. package/dist/src/index.js.map +0 -1
  82. package/dist/src/utils/constants.d.ts +0 -12
  83. package/dist/src/utils/constants.d.ts.map +0 -1
  84. package/dist/src/utils/constants.js +0 -12
  85. package/dist/src/utils/constants.js.map +0 -1
  86. package/dist/utils/constants.d.ts.map +0 -1
  87. package/dist/utils/constants.js.map +0 -1
@@ -1,4 +1,3 @@
1
1
  import Server from "./Server.js";
2
2
  import type { ServerReq } from "./types.js";
3
3
  export default function RequestParser(req: ServerReq, server: Server): ServerReq;
4
- //# sourceMappingURL=Request.d.ts.map
@@ -21,4 +21,3 @@ export default function RequestParser(req, server) {
21
21
  });
22
22
  return req;
23
23
  }
24
- //# sourceMappingURL=Request.js.map
@@ -1,4 +1,3 @@
1
1
  import Server from "./Server.js";
2
2
  import type { ServerRes, ServerReq } from "./types.js";
3
3
  export default function ResponseParser(res: ServerRes, req: ServerReq, server: Server): ServerRes;
4
- //# sourceMappingURL=Response.d.ts.map
@@ -75,4 +75,3 @@ export default function ResponseParser(res, req, server) {
75
75
  };
76
76
  return res;
77
77
  }
78
- //# sourceMappingURL=Response.js.map
@@ -1,4 +1,4 @@
1
- import type { ServerOptions, ServerRes, AddOption, HandlerFun, Decorator, DirFiles } from "./types.js";
1
+ import type { ServerOptions, ServerRes, Handlers, AddOption, HandlerFun, Decorator, Logs, DirFiles } from "./types.js";
2
2
  export default class Server {
3
3
  private PORT;
4
4
  private hostname;
@@ -11,6 +11,11 @@ export default class Server {
11
11
  private logs;
12
12
  private ServerName;
13
13
  private defaultHandler;
14
+ getMethodHandlers(): Handlers[];
15
+ getDecorators(): Decorator[];
16
+ getUpTime(): number;
17
+ getReqCount(): number;
18
+ getLogs(): Logs[];
14
19
  private generateKey;
15
20
  private generateSession;
16
21
  private getSession;
@@ -24,7 +29,5 @@ export default class Server {
24
29
  SendFile(res: ServerRes, FILE: string, status: number): Promise<void>;
25
30
  log(message: string, type?: "error" | "message"): void;
26
31
  constructor(args: ServerOptions);
27
- monitor(server: Server): void;
28
32
  listen(enableMon?: boolean, callback?: () => void): void;
29
33
  }
30
- //# sourceMappingURL=Server.d.ts.map
@@ -6,9 +6,6 @@ import * as http from "http";
6
6
  import * as net from "net";
7
7
  import { fileURLToPath } from 'url';
8
8
  import { readdir } from 'node:fs/promises';
9
- import * as os from "node:os";
10
- import * as JWT from "jsonwebtoken";
11
- import * as DOTENV from "dotenv";
12
9
  import RequestParser from "./Request.js";
13
10
  import ResponseParser from "./Response.js";
14
11
  export default class Server {
@@ -23,6 +20,21 @@ export default class Server {
23
20
  logs;
24
21
  ServerName;
25
22
  defaultHandler;
23
+ getMethodHandlers() {
24
+ return this.methodHandler;
25
+ }
26
+ getDecorators() {
27
+ return this.decorators;
28
+ }
29
+ getUpTime() {
30
+ return this.uptime;
31
+ }
32
+ getReqCount() {
33
+ return this.reqCount;
34
+ }
35
+ getLogs() {
36
+ return this.logs;
37
+ }
26
38
  generateKey() {
27
39
  return randomBytes(16).toString('hex');
28
40
  }
@@ -152,8 +164,7 @@ export default class Server {
152
164
  const __filename = fileURLToPath(import.meta.url);
153
165
  const projectRoot = path.resolve(__filename, '..', '..');
154
166
  const __dirname = projectRoot;
155
- const filePath = path.join(__dirname, FILE);
156
- const extName = String(path.extname(filePath)).toLowerCase();
167
+ const extName = String(path.extname(FILE)).toLowerCase();
157
168
  const mimeTypes = {
158
169
  '.txt': 'text/plain',
159
170
  '.html': 'text/html',
@@ -169,14 +180,14 @@ export default class Server {
169
180
  };
170
181
  const contentType = mimeTypes[extName] || 'application/octet-stream';
171
182
  try {
172
- await fs.promises.access(filePath, fs.constants.F_OK);
183
+ await fs.promises.access(`./${FILE}`, fs.constants.F_OK);
173
184
  res.server.log(`sending file ${FILE} to ${res.ip}`, (status == 404 || status == 401) ? "error" : "message");
174
- return res.sendFile(status, contentType, { PATH: filePath });
185
+ return res.sendFile(status, contentType, { PATH: `./${FILE}` });
175
186
  }
176
- catch {
177
- const errorPagePath = path.join(__dirname, 'public', 'stauts/404.html');
187
+ catch (err) {
188
+ console.log(err);
178
189
  res.server.log(`cannot find ${FILE} to send to ${res.ip}`, "error");
179
- return res.sendFile(404, 'text/html', { PATH: errorPagePath });
190
+ return res.send(404, { status: "Page not found" });
180
191
  }
181
192
  }
182
193
  log(message, type) {
@@ -204,7 +215,7 @@ export default class Server {
204
215
  this.ServerName = args.ServerName ?? "Server";
205
216
  this.defaultHandler = args.DefaultHandler ?? (async (req, res) => {
206
217
  this.log(`Sending defualt of this route ${req.ReqUrl?.pathname}`);
207
- await this.SendFile(res, "public/status/404.html", 404);
218
+ return res.send(404, { status: "Page not found" });
208
219
  });
209
220
  this.server = http.createServer((req, res) => {
210
221
  let body = "";
@@ -266,268 +277,9 @@ export default class Server {
266
277
  this.log(err.message, "error");
267
278
  });
268
279
  }
269
- monitor(server) {
270
- DOTENV.config();
271
- let username = process.env.ADMIN_USERNAME || "";
272
- let password = process.env.ADMIN_PASSWORD || "";
273
- const key = process.env.ADMIN_KEY || "";
274
- const sessions = [];
275
- if (key === "" || username === "" || password === "") {
276
- server.log(`cannot set ${key === "" ? "ADMIN_KEY" : username === "" ? "ADMIN_USERnAME" : password === "" ? "ADMIN_PASSWORD" : ""} as empty in .env, read tinny-backend doc`, "error");
277
- return;
278
- }
279
- const isAuthed = (res) => {
280
- const TOKEN = res.getCookie("token");
281
- if (!TOKEN)
282
- return false;
283
- try {
284
- const decoded = JWT.default.verify(TOKEN.value, key);
285
- if (typeof decoded.id === undefined)
286
- throw new Error("None valid token");
287
- for (let i = 0; i < sessions.length; i++) {
288
- if (sessions[i]?.id === decoded.id) {
289
- if (!sessions[i]?.isValid)
290
- throw new Error("None valid token");
291
- sessions[i].request += 1;
292
- res.currentID = decoded.id;
293
- return true;
294
- }
295
- }
296
- throw new Error("None valid UUID");
297
- }
298
- catch {
299
- server.log("a user try to login to admin panel using none valid token", "error");
300
- return false;
301
- }
302
- return true;
303
- };
304
- const Login = async (req, res) => {
305
- let token;
306
- try {
307
- if (!req.body.username || req.body.username !== username || !req.body.password || req.body.password !== password)
308
- throw new Error("User has entred a none valid cridentials");
309
- const SESSION_ID = crypto.randomUUID();
310
- token = JWT.default.sign({ id: SESSION_ID }, key, { expiresIn: "1h" });
311
- res.addCookie("token", token);
312
- sessions.push({
313
- id: SESSION_ID,
314
- isValid: true,
315
- creation: Date.now(),
316
- userAgent: req.headers["user-agent"] ?? "DEVICE",
317
- ip: req.ip ?? "UNKNOWN",
318
- request: 0
319
- });
320
- res.send(200, "./public/admin/index.html", { "set-cookie": `token=${token}; Path=/; SameSite=Lax; HttpOnly` });
321
- }
322
- catch (err) {
323
- server.log(err.message, "error");
324
- server.log("A user entred a none valid cridentionl", "error");
325
- res.send(403, { "Error": "Access Denied" });
326
- }
327
- };
328
- const Logout = async (req, res) => {
329
- let payloud;
330
- const TOKEN = res.getCookie("token");
331
- if (!TOKEN)
332
- return server.SendFile(res, "public/login/index.html", 401);
333
- try {
334
- payloud = JWT.default.verify(TOKEN.value, key);
335
- if (typeof payloud.id === "undefined")
336
- throw new Error("an Error is happens");
337
- for (let i = 0; i < sessions.length; i++) {
338
- if (sessions[i]?.id === payloud.id) {
339
- if (!sessions[i]?.isValid)
340
- throw new Error("None valid token");
341
- sessions[i].request += 1;
342
- sessions[i].isValid = false;
343
- break;
344
- }
345
- }
346
- return await server.SendFile(res, "public/login/index.html", 200);
347
- }
348
- catch (err) {
349
- server.log(err.message, "error");
350
- res.send(403, { "Error": "Access Denied" });
351
- }
352
- };
353
- const Auth = async (req, res) => {
354
- if (!isAuthed(res)) {
355
- if (req.ReqUrl?.pathname == "/")
356
- return await server.SendFile(res, "public/login/index.html", 401);
357
- return await server.SendFile(res, "public/status/401.html", 401);
358
- }
359
- if (req.ReqUrl?.pathname == "/")
360
- return await server.SendFile(res, "public/admin/index.html", 200);
361
- };
362
- server.add({
363
- method: "POST",
364
- handler: Login,
365
- path: "/api/login"
366
- });
367
- server.add({
368
- method: "GET",
369
- middelWares: [Auth],
370
- handler: async (req, res) => {
371
- return await server.SendFile(res, "public/login/index.html", 200);
372
- },
373
- path: "/"
374
- });
375
- server.add({
376
- method: "GET",
377
- middelWares: [Auth],
378
- handler: Logout,
379
- path: "/api/logout"
380
- });
381
- server.add({
382
- method: "GET",
383
- middelWares: [Auth],
384
- path: "/admin/status",
385
- handler: async (req, res) => {
386
- const now = Date.now();
387
- res.send(200, {
388
- "Machin uptime": `${Math.floor(os.uptime() / 86400)}d ${Math.floor((os.uptime() % 86400) / 3600)}h ${Math.floor((os.uptime() % 3600) / 60)}m`,
389
- "Server uptime": `${Math.floor((now - this.uptime) / (1000 * 60 * 60 * 24)) % 60}D ${Math.floor((now - this.uptime) / (1000 * 60 * 60)) % 60}H ${Math.floor((now - this.uptime) / (1000 * 60)) % 60}M ${Math.floor((now - this.uptime) / 1000) % 60}S`,
390
- "Arch": os.arch(),
391
- "Platform": os.platform(),
392
- "Memory": `${(os.totalmem() / (1024 ** 3)).toFixed(2)} GB`,
393
- "Used Memory": `${((os.totalmem() - os.freemem()) / (1024 ** 3)).toFixed(2)} GB`,
394
- "Free Memory": `${(os.freemem() / (1024 ** 3)).toFixed(2)} GB`,
395
- "Cpu": os.cpus()[0],
396
- "Connected clients": this.sessions.length,
397
- "Total requests": this.reqCount,
398
- "Currnet-session": res.currentID,
399
- "sessions": sessions,
400
- "routes": this.methodHandler,
401
- "logs": this.logs
402
- });
403
- }
404
- });
405
- server.add({
406
- method: "GET",
407
- middelWares: [Auth],
408
- path: "/messages",
409
- handler: async (req, res) => {
410
- res.send(200, {
411
- "logs": this.logs
412
- });
413
- }
414
- });
415
- server.add({
416
- method: "GET",
417
- path: "/passwd",
418
- handler: async (req, res) => {
419
- return await this.SendFile(res, "./public/login/new-password.html", 200);
420
- }
421
- });
422
- server.add({
423
- method: "GET",
424
- path: "/api/passwd/:username",
425
- handler: async (req, res) => {
426
- let userName = req.params.username;
427
- if (typeof username === undefined)
428
- return res.send(404, { "user": userName, status: "not found" });
429
- if (userName === username)
430
- return res.send(200, { "user": userName, status: "found" });
431
- return res.send(404, { "user": userName, status: "not found" });
432
- }
433
- });
434
- server.add({
435
- method: "POST",
436
- path: "/api/passwd/change",
437
- handler: async (req, res) => {
438
- try {
439
- const { userName, oldpwd, newpwd } = req.body;
440
- console.log(req.body);
441
- if (!userName || !oldpwd || !newpwd)
442
- return res.send(400, { "user": userName || 'unknown', status: 'missing fields', message: 'Username, old password, and new password are required' });
443
- if (userName !== username)
444
- return res.send(404, { "user": userName, status: 'this username not found', message: `${userName} not found` });
445
- if (oldpwd !== password)
446
- return res.send(401, { "user": userName, status: 'password not corect', message: `Password not corect for ${userName}` });
447
- if (newpwd.length < 8)
448
- return res.send(400, { "user": userName, status: 'password must be 8 char +' });
449
- if (oldpwd === newpwd || newpwd === password)
450
- return res.send(400, { "user": userName, status: 'new password must be different', message: 'New password must be different from current password' });
451
- password = newpwd;
452
- return res.send(200, { "user": userName, status: 'password changed', message: 'Password updated successfully' });
453
- }
454
- catch (error) {
455
- server.log(`Password change error: ${error}`, "error");
456
- return res.send(500, { "user": req.body?.username || 'unknown', status: 'error', message: 'Internal server error' });
457
- }
458
- }
459
- });
460
- server.add({
461
- method: "POST",
462
- middelWares: [Auth],
463
- path: "/api/logout/:SessionId",
464
- handler: async (req, res) => {
465
- let SessionID = req.params.SessionId;
466
- if (typeof SessionID === undefined)
467
- return res.send(404, { status: "not found" });
468
- for (let i = 0; i < sessions.length; i++) {
469
- if (SessionID === sessions[i]?.id) {
470
- sessions[i].isValid = false;
471
- return res.send(200, { status: `session ${SessionID} logouted` });
472
- }
473
- }
474
- return res.send(404, { status: "not found" });
475
- }
476
- });
477
- server.add({
478
- method: "POST",
479
- middelWares: [Auth],
480
- path: "/passwd/change/auth",
481
- handler: async (req, res) => {
482
- try {
483
- const { oldpwd, newpwd } = req.body;
484
- if (!oldpwd || !newpwd)
485
- return res.send(401, { status: "all field are required !" });
486
- if (oldpwd !== password)
487
- return res.send(401, { status: "incorect password" });
488
- if (oldpwd === newpwd)
489
- return res.send(400, { status: "old pwd must be defrent from new one" });
490
- password = newpwd;
491
- return res.send(200, { status: "password changed with secc" });
492
- }
493
- catch {
494
- res.send(500, { status: "internal server error" });
495
- }
496
- return res.send(401, { status: "?" });
497
- }
498
- });
499
- server.add({
500
- method: "POST",
501
- middelWares: [Auth],
502
- path: "/api/user/change",
503
- handler: async (req, res) => {
504
- try {
505
- const { userName } = req.body;
506
- if (!userName)
507
- return res.send(401, { status: "all field are required !" });
508
- if (userName.length <= 3 || userName.length >= 20)
509
- return res.send(400, { status: "username must be between 4-19" });
510
- username = userName;
511
- return res.send(200, { status: "username changed with secc" });
512
- }
513
- catch {
514
- res.send(500, { status: "internal server error" });
515
- }
516
- return res.send(401, { status: "?" });
517
- }
518
- });
519
- server.servDir("./public/doc", "docs");
520
- server.servDir("./public/imgs", "imgs");
521
- server.servDir("./public/login", "/", [Auth]);
522
- server.servDir("./public/admin", "admin", [Auth]);
523
- server.listen(false);
524
- }
525
280
  listen(enableMon, callback) {
526
- if (enableMon)
527
- this.monitor(new Server({ port: this.PORT + 1, ServerName: "Monitor" }));
528
281
  this.server.listen(this.PORT, callback ?? (() => {
529
282
  this.log(`start listening in http://${this.hostname}:${this.PORT}`);
530
283
  }));
531
284
  }
532
285
  }
533
- //# sourceMappingURL=Server.js.map
@@ -86,4 +86,3 @@ export type AdminSessions = {
86
86
  isValid: boolean;
87
87
  request: number;
88
88
  };
89
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import * as http from "http";
2
2
  import Server from "./Server.js";
3
- //# sourceMappingURL=types.js.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
- export {};
2
- //# sourceMappingURL=index.d.ts.map
1
+ import Server from "./core/Server.js";
2
+ import type { ServerOptions } from "./core/types.js";
3
+ export { Server };
4
+ export default Server;
5
+ export declare function createServer(options?: ServerOptions): Server;
6
+ export { VERSION } from "./utils/version.js";
7
+ export type { ServerOptions, ServerReq, ServerRes, AddOption, HandlerFun, Methods, Headers, Cookie, Logs, Session, AdminSessions, Decorator, DirFiles, ServFiles } from "./core/types.js";
package/dist/index.js CHANGED
@@ -1,11 +1,7 @@
1
1
  import Server from "./core/Server.js";
2
- const srv = new Server({ port: 3000 });
3
- srv.add({
4
- path: "/messages/:userId",
5
- method: "GET",
6
- handler: (req, res) => {
7
- res.send(200, { data: `message id = ${req.params.userId}` });
8
- }
9
- });
10
- srv.listen(true);
11
- //# sourceMappingURL=index.js.map
2
+ export { Server };
3
+ export default Server;
4
+ export function createServer(options) {
5
+ return new Server(options ?? {});
6
+ }
7
+ export { VERSION } from "./utils/version.js";
@@ -9,4 +9,3 @@ export declare const colors: {
9
9
  cyan: string;
10
10
  white: string;
11
11
  };
12
- //# sourceMappingURL=constants.d.ts.map
@@ -9,4 +9,3 @@ export const colors = {
9
9
  cyan: '\x1b[36m',
10
10
  white: '\x1b[37m',
11
11
  };
12
- //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ export declare const VERSION = "1.0.2";
@@ -0,0 +1 @@
1
+ export const VERSION = "1.0.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tinny-backend",
3
- "version": "1.0.0",
4
- "description": "A lightweight and flexible routing system for Node.js with WebSocket support",
3
+ "version": "1.0.2",
4
+ "description": "A lightweight and flexible backend framework built on Node.js.",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Yassine Ajagrou",
@@ -10,31 +10,29 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git+https://github.com/iaceene/TinnyBackend.git"
13
+ "url": "git+https://github.com/iaceene/tinny-backend.git"
14
14
  },
15
15
  "bugs": {
16
- "url": "https://github.com/iaceene/TinnyBackend/issues"
16
+ "url": "https://github.com/iaceene/tinny-backend/issues"
17
17
  },
18
- "homepage": "https://github.com/iaceene/TinnyBackend#readme",
18
+ "homepage": "https://github.com/iaceene/tinny-backend#readme",
19
19
  "keywords": [
20
+ "backend",
21
+ "framework",
20
22
  "router",
21
23
  "routing",
22
- "express",
23
- "websocket",
24
- "ws",
24
+ "http",
25
+ "node",
25
26
  "nodejs",
26
27
  "typescript",
27
- "jwt",
28
- "authentication"
28
+ "server"
29
29
  ],
30
30
  "type": "module",
31
31
  "main": "./dist/index.js",
32
- "module": "./dist/index.js",
33
32
  "types": "./dist/index.d.ts",
34
33
  "exports": {
35
34
  ".": {
36
35
  "import": "./dist/index.js",
37
- "require": "./dist/index.js",
38
36
  "types": "./dist/index.d.ts"
39
37
  }
40
38
  },
@@ -46,44 +44,28 @@
46
44
  ],
47
45
  "scripts": {
48
46
  "build": "tsc",
49
- "dev": "nodemon --exec tsx src/app/index.ts",
50
- "example": "node ./dist/app/index.js",
47
+ "dev": "tsx src/index.ts",
51
48
  "test": "vitest",
52
- "test:coverage": "vitest --coverage",
53
49
  "lint": "eslint . --ext .ts",
54
50
  "lint:fix": "eslint . --ext .ts --fix",
55
51
  "format": "prettier --write .",
56
- "prepublishOnly": "npm run build",
57
- "version": "npm run format && git add -A src",
58
- "postversion": "git push && git push --tags"
59
- },
60
- "peerDependencies": {
61
- "node": ">=18.0.0"
52
+ "prepublishOnly": "npm run build"
62
53
  },
63
54
  "devDependencies": {
64
- "@types/jsonwebtoken": "^9.0.10",
65
55
  "@types/node": "^25.9.3",
66
- "@types/ws": "^8.18.1",
67
- "@typescript-eslint/eslint-plugin": "^7.0.0",
68
- "@typescript-eslint/parser": "^7.0.0",
69
- "eslint": "^8.57.0",
70
- "nodemon": "^3.1.14",
71
- "prettier": "^3.2.5",
72
- "tsx": "^4.7.0",
73
- "typescript": "^5.7.3",
56
+ "@typescript-eslint/eslint-plugin": "^8.39.1",
57
+ "@typescript-eslint/parser": "^8.39.1",
58
+ "eslint": "^9.36.0",
59
+ "prettier": "^3.6.2",
60
+ "tsx": "^4.20.5",
61
+ "typescript": "^5.9.2",
74
62
  "vitest": "^4.1.9"
75
63
  },
76
- "dependencies": {
77
- "dotenv": "^17.4.2",
78
- "jsonwebtoken": "^9.0.3",
79
- "ws": "^8.21.0"
80
- },
81
64
  "engines": {
82
65
  "node": ">=18.0.0"
83
66
  },
84
67
  "publishConfig": {
85
- "access": "public",
86
- "registry": "https://registry.npmjs.org/"
68
+ "access": "public"
87
69
  },
88
70
  "private": false
89
- }
71
+ }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/admin/auth.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/admin/auth.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=monitor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/admin/monitor.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=monitor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/admin/monitor.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=routes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/admin/routes.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=routes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/admin/routes.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../app/index.ts"],"names":[],"mappings":""}
package/dist/app/index.js DELETED
@@ -1,19 +0,0 @@
1
- import { uptime } from "node:process";
2
- import Server from "../src/index.js";
3
- const srv = new Server({});
4
- srv.add({
5
- path: "/",
6
- handler: async (req, res) => {
7
- return await srv.SendFile(res, "public/example/default.html", 200);
8
- },
9
- method: "GET"
10
- });
11
- srv.add({
12
- path: "/api/info",
13
- handler: async (req, res) => {
14
- return res.send(200, { uptime: uptime() });
15
- },
16
- method: "GET"
17
- });
18
- srv.listen(true);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC,CAAA;AAE1B,GAAG,CAAC,GAAG,CAAC;IACJ,IAAI,EAAE,GAAG;IACT,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACxB,OAAO,MAAM,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,6BAA6B,EAAE,GAAG,CAAC,CAAA;IACtE,CAAC;IACD,MAAM,EAAE,KAAK;CAChB,CAAC,CAAA;AAEF,GAAG,CAAC,GAAG,CAAC;IACJ,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACxB,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAC,MAAM,EAAE,MAAM,EAAE,EAAC,CAAC,CAAA;IAC5C,CAAC;IACD,MAAM,EAAE,KAAK;CAChB,CAAC,CAAA;AAGF,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Request.d.ts","sourceRoot":"","sources":["../../src/core/Request.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAO,aAAa,CAAA;AACjC,OAAO,KAAK,EACR,SAAS,EACZ,MAAM,YAAY,CAAA;AAEnB,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CA2B/E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Request.js","sourceRoot":"","sources":["../../src/core/Request.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAO,aAAa,CAAA;AAKjC,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,GAAc,EAAE,MAAc;IAChE,IAAI,IAAI,GAAW,EAAE,CAAC;IAEtB,IACA,CAAC;QACG,MAAM,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;QACvF,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,GAAG,CAAC,MAAc,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC9E,GAAG,CAAC,KAAK,GAAG,IAAI,eAAe,CAAE,GAAG,CAAC,MAAc,CAAC,YAAY,CAAC,CAAC;QAClE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC/C,CAAC;IACD,MACA,CAAC;QACG,MAAM,CAAC,GAAG,CAAC,gBAAgB,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;QAC9C,GAAG,CAAC,MAAc,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC;QACvC,GAAG,CAAC,OAAO,GAAG,EAAE,CAAA;IACpB,CAAC;IACD,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,WAAW,CAAC;IACnE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;IAEnB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE,qBAAqB,GAAG,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAErF,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QACrB,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../src/core/Response.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,KAAK,EACR,SAAS,EACT,SAAS,EAEZ,MAAM,YAAY,CAAA;AAGnB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CA4FhG"}