skyguard-js 1.1.6 → 1.1.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.
package/README.md CHANGED
@@ -142,8 +142,7 @@ app.get("/secure", () => Response.json({ secure: true }), [authMiddleware]);
142
142
  To enable CORS, use the built-in `cors` middleware.
143
143
 
144
144
  ```ts
145
- import { cors } from "skyguard-js/middlewares";
146
- import { HttpMethods } from "skyguard-js";
145
+ import { cors, HttpMethods } from "skyguard-js";
147
146
 
148
147
  app.middlewares([
149
148
  cors({
@@ -222,7 +221,7 @@ Validation is:
222
221
  The framework provides a set of built-in HTTP exceptions that can be thrown from route handlers or middleware. When an exception is thrown, the framework detects it and sends an appropriate HTTP response with the status code and message you specified in the class.
223
222
 
224
223
  ```ts
225
- import { NotFoundError, InternalServerError } from "skyguard-js/exceptions";
224
+ import { NotFoundError, InternalServerError } from "skyguard-js";
226
225
 
227
226
  const listResources = ["1", "2", "3"];
228
227
 
@@ -257,8 +256,7 @@ app.get("/divide", (request: Request) => {
257
256
  To handle sessions, you must use the framework’s built-in middleware. Depending on where you want to store them (in memory, in files, or in a database), you need to use the corresponding storage class.
258
257
 
259
258
  ```ts
260
- import { sessions } from "skyguard-js/middlewares";
261
- import { FileSessionStorage } from "skyguard-js";
259
+ import { sessions, FileSessionStorage } from "skyguard-js";
262
260
 
263
261
  app.middlewares([
264
262
  sessions(FileSessionStorage, {
@@ -306,7 +304,7 @@ app.get("/me", (request: Request) => {
306
304
  The framework includes some password hashing and JWT token generation functions, and also includes JWT authentication middleware.
307
305
 
308
306
  ```ts
309
- import { Hasher, JWT } from "skyguard-js/security";
307
+ import { Hasher, JWT } from "skyguard-js";
310
308
 
311
309
  app.post("/register", async (request: Request) => {
312
310
  const { username, password } = request.data;
@@ -9,7 +9,7 @@ import { Response } from "../http/response";
9
9
  * @example
10
10
  * return json({ ok: true, userId: 1 });
11
11
  */
12
- export declare function json<T>(data: T): Response;
12
+ export declare function json(data: unknown): Response;
13
13
  /**
14
14
  * Creates an HTTP response with a plain text body.
15
15
  *
package/dist/index.d.ts CHANGED
@@ -7,3 +7,7 @@ export { HttpMethods } from "./http/httpMethods";
7
7
  export { createUploader } from "./storage/uploader";
8
8
  export { StorageType } from "./storage/types";
9
9
  export { v, schema, validateData } from "./validators/validationSchema";
10
+ export { Hasher, JWT } from "./crypto";
11
+ export { sessions, cors } from "./middlewares";
12
+ export * from "./exceptions/httpExceptions";
13
+ export * from "./helpers/http";
package/dist/index.js CHANGED
@@ -1,6 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateData = exports.schema = exports.v = exports.StorageType = exports.createUploader = exports.HttpMethods = exports.MemorySessionStorage = exports.FileSessionStorage = exports.RouterGroup = exports.Response = exports.Request = exports.createApp = void 0;
17
+ exports.cors = exports.sessions = exports.JWT = exports.Hasher = exports.validateData = exports.schema = exports.v = exports.StorageType = exports.createUploader = exports.HttpMethods = exports.MemorySessionStorage = exports.FileSessionStorage = exports.RouterGroup = exports.Response = exports.Request = exports.createApp = void 0;
4
18
  var app_1 = require("./app");
5
19
  Object.defineProperty(exports, "createApp", { enumerable: true, get: function () { return app_1.createApp; } });
6
20
  var http_1 = require("./http");
@@ -21,3 +35,11 @@ var validationSchema_1 = require("./validators/validationSchema");
21
35
  Object.defineProperty(exports, "v", { enumerable: true, get: function () { return validationSchema_1.v; } });
22
36
  Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return validationSchema_1.schema; } });
23
37
  Object.defineProperty(exports, "validateData", { enumerable: true, get: function () { return validationSchema_1.validateData; } });
38
+ var crypto_1 = require("./crypto");
39
+ Object.defineProperty(exports, "Hasher", { enumerable: true, get: function () { return crypto_1.Hasher; } });
40
+ Object.defineProperty(exports, "JWT", { enumerable: true, get: function () { return crypto_1.JWT; } });
41
+ var middlewares_1 = require("./middlewares");
42
+ Object.defineProperty(exports, "sessions", { enumerable: true, get: function () { return middlewares_1.sessions; } });
43
+ Object.defineProperty(exports, "cors", { enumerable: true, get: function () { return middlewares_1.cors; } });
44
+ __exportStar(require("./exceptions/httpExceptions"), exports);
45
+ __exportStar(require("./helpers/http"), exports);
package/package.json CHANGED
@@ -1,31 +1,9 @@
1
1
  {
2
2
  "name": "skyguard-js",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "A lightweight, dependency-free TypeScript backend framework",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js"
11
- },
12
- "./helpers": {
13
- "types": "./dist/helpers/http.d.ts",
14
- "import": "./dist/helpers/http.js"
15
- },
16
- "./middlewares": {
17
- "types": "./dist/middlewares/index.d.ts",
18
- "import": "./dist/middlewares/index.js"
19
- },
20
- "./exceptions": {
21
- "types": "./dist/exceptions/httpExceptions.d.ts",
22
- "import": "./dist/exceptions/httpExceptions.js"
23
- },
24
- "./security": {
25
- "types": "./dist/crypto/index.d.ts",
26
- "import": "./dist/crypto/index.js"
27
- }
28
- },
29
7
  "keywords": [
30
8
  "typescript",
31
9
  "javascript",