tinny-backend 1.0.5 → 1.0.7

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,5 @@
1
1
  import type { ServerOptions, ServerRes, Handlers, AddOption, HandlerFun, Decorator, Logs, DirFiles } from "./types.js";
2
+ import * as http from "http";
2
3
  export default class Server {
3
4
  private PORT;
4
5
  private hostname;
@@ -12,6 +13,7 @@ export default class Server {
12
13
  private ServerName;
13
14
  private defaultHandler;
14
15
  getMethodHandlers(): Handlers[];
16
+ getHttpServer(): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
15
17
  getDecorators(): Decorator[];
16
18
  getUpTime(): number;
17
19
  getReqCount(): number;
@@ -23,6 +23,9 @@ export default class Server {
23
23
  getMethodHandlers() {
24
24
  return this.methodHandler;
25
25
  }
26
+ getHttpServer() {
27
+ return this.server;
28
+ }
26
29
  getDecorators() {
27
30
  return this.decorators;
28
31
  }
@@ -219,13 +222,16 @@ export default class Server {
219
222
  });
220
223
  this.server = http.createServer((req, res) => {
221
224
  let body = "";
225
+ const rawChunks = [];
222
226
  this.reqCount++;
223
227
  const Req = RequestParser(req, this);
224
228
  const Res = ResponseParser(res, Req, this);
225
229
  req.on("data", (chunk) => {
226
230
  body += chunk.toString();
231
+ rawChunks.push(chunk);
227
232
  });
228
233
  req.on("end", async () => {
234
+ Req.RawBody = Buffer.concat(rawChunks);
229
235
  if (req.headers["content-type"] === "application/json") {
230
236
  Req.body = body ? JSON.parse(body) : null;
231
237
  }
@@ -33,6 +33,7 @@ export type ServerReq = http.IncomingMessage & {
33
33
  Query: URLSearchParams;
34
34
  queries: object;
35
35
  body?: any;
36
+ RawBody: Buffer;
36
37
  ip: string;
37
38
  server: Server;
38
39
  params: Record<string, string>;
@@ -1 +1 @@
1
- export declare const VERSION = "1.0.5";
1
+ export declare const VERSION = "1.0.7";
@@ -1 +1 @@
1
- export const VERSION = "1.0.5";
1
+ export const VERSION = "1.0.7";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinny-backend",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A lightweight and flexible backend framework built on Node.js.",
5
5
  "license": "MIT",
6
6
  "author": {
package/dist/tester.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/tester.js DELETED
@@ -1,10 +0,0 @@
1
- import Server from "./core/Server.js";
2
- const srv = new Server({});
3
- srv.add({
4
- path: "/",
5
- method: "POST",
6
- handler: (req, res) => {
7
- res.send(200, { message: "Hello" });
8
- }
9
- });
10
- srv.listen();