@point-hub/papi 0.1.6 → 0.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.
Files changed (69) hide show
  1. package/lib/src/app.d.ts +3 -0
  2. package/lib/src/app.d.ts.map +1 -0
  3. package/lib/src/app.spec.d.ts +2 -0
  4. package/lib/src/app.spec.d.ts.map +1 -0
  5. package/lib/src/console/commands/make-command/index.command.d.ts +6 -0
  6. package/lib/src/console/commands/make-command/index.command.d.ts.map +1 -0
  7. package/lib/src/console/commands/make-command/index.spec.d.ts +2 -0
  8. package/lib/src/console/commands/make-command/index.spec.d.ts.map +1 -0
  9. package/lib/src/console/commands/make-middleware/index.command.d.ts +8 -0
  10. package/lib/src/console/commands/make-middleware/index.command.d.ts.map +1 -0
  11. package/lib/src/console/commands/make-middleware/index.spec.d.ts +2 -0
  12. package/lib/src/console/commands/make-middleware/index.spec.d.ts.map +1 -0
  13. package/lib/src/console/index.d.ts +13 -0
  14. package/lib/src/console/index.d.ts.map +1 -0
  15. package/lib/src/console/index.spec.d.ts +2 -0
  16. package/lib/src/console/index.spec.d.ts.map +1 -0
  17. package/lib/src/database/connection.d.ts +32 -0
  18. package/lib/src/database/connection.d.ts.map +1 -0
  19. package/lib/src/database/mongodb/connection.d.ts +37 -0
  20. package/lib/src/database/mongodb/connection.d.ts.map +1 -0
  21. package/lib/src/database/mongodb/mongodb-error-handler.d.ts +10 -0
  22. package/lib/src/database/mongodb/mongodb-error-handler.d.ts.map +1 -0
  23. package/lib/src/database/mongodb/mongodb-helper.d.ts +35 -0
  24. package/lib/src/database/mongodb/mongodb-helper.d.ts.map +1 -0
  25. package/lib/src/database/mongodb/mongodb-querystring.d.ts +82 -0
  26. package/lib/src/database/mongodb/mongodb-querystring.d.ts.map +1 -0
  27. package/lib/src/database/mongodb/mongodb-querystring.spec.d.ts +2 -0
  28. package/lib/src/database/mongodb/mongodb-querystring.spec.d.ts.map +1 -0
  29. package/lib/src/index.d.ts +38 -0
  30. package/lib/src/index.d.ts.map +1 -0
  31. package/lib/src/server.d.ts +16 -0
  32. package/lib/src/server.d.ts.map +1 -0
  33. package/lib/src/server.spec.d.ts +2 -0
  34. package/lib/src/server.spec.d.ts.map +1 -0
  35. package/lib/stub/command/index.command.d.ts +6 -0
  36. package/lib/stub/command/index.command.d.ts.map +1 -0
  37. package/lib/stub/command/index.spec.d.ts +2 -0
  38. package/lib/stub/command/index.spec.d.ts.map +1 -0
  39. package/lib/stub/middleware/configurable.middleware.d.ts +3 -0
  40. package/lib/stub/middleware/configurable.middleware.d.ts.map +1 -0
  41. package/lib/stub/middleware/configurable.spec.d.ts +2 -0
  42. package/lib/stub/middleware/configurable.spec.d.ts.map +1 -0
  43. package/lib/stub/middleware/new.middleware.d.ts +3 -0
  44. package/lib/stub/middleware/new.middleware.d.ts.map +1 -0
  45. package/lib/stub/middleware/new.spec.d.ts +2 -0
  46. package/lib/stub/middleware/new.spec.d.ts.map +1 -0
  47. package/package.json +4 -5
  48. package/lib/index.d.ts +0 -318
  49. package/lib/index.tsbuildinfo +0 -1
  50. package/src/app.spec.ts +0 -8
  51. package/src/app.ts +0 -13
  52. package/src/console/commands/make-command/index.command.ts +0 -52
  53. package/src/console/commands/make-command/index.spec.ts +0 -58
  54. package/src/console/commands/make-middleware/index.command.ts +0 -86
  55. package/src/console/commands/make-middleware/index.spec.ts +0 -73
  56. package/src/console/index.spec.ts +0 -14
  57. package/src/console/index.ts +0 -23
  58. package/src/database/connection.ts +0 -78
  59. package/src/database/mongodb/connection.ts +0 -339
  60. package/src/database/mongodb/mongodb-error-handler.ts +0 -63
  61. package/src/database/mongodb/mongodb-helper.ts +0 -109
  62. package/src/database/mongodb/mongodb-querystring.spec.ts +0 -80
  63. package/src/database/mongodb/mongodb-querystring.ts +0 -143
  64. package/src/index.ts +0 -42
  65. package/src/server.spec.ts +0 -68
  66. package/src/server.ts +0 -49
  67. package/src/types/controller.d.ts +0 -18
  68. package/src/types/database.d.ts +0 -104
  69. package/src/types/use-case.d.ts +0 -3
@@ -0,0 +1,3 @@
1
+ import express from 'express';
2
+ export declare function createApp(): Promise<express.Express>;
3
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAuC,MAAM,SAAS,CAAA;AAE7D,wBAAsB,SAAS,6BAU9B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=app.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.spec.d.ts","sourceRoot":"","sources":["../../src/app.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { BaseCommand } from '@point-hub/express-cli';
2
+ export default class MakeCommand extends BaseCommand {
3
+ constructor();
4
+ handle(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=index.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.command.d.ts","sourceRoot":"","sources":["../../../../../src/console/commands/make-command/index.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAS,MAAM,wBAAwB,CAAA;AAO3D,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;;IAe5C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CA6B9B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../../../src/console/commands/make-command/index.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { BaseCommand } from '@point-hub/express-cli';
2
+ export default class MakeMiddleware extends BaseCommand {
3
+ constructor();
4
+ handle(): Promise<void>;
5
+ private copyMiddleware;
6
+ private copyConfigureableMiddleware;
7
+ }
8
+ //# sourceMappingURL=index.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.command.d.ts","sourceRoot":"","sources":["../../../../../src/console/commands/make-middleware/index.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAS,MAAM,wBAAwB,CAAA;AAO3D,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,WAAW;;IAuB/C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB7B,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,2BAA2B;CAkBpC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../../../src/console/commands/make-middleware/index.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { ExpressCli } from '@point-hub/express-cli';
2
+ export declare class ConsoleKernel {
3
+ private command;
4
+ constructor(command: ExpressCli);
5
+ /**
6
+ * Register the commands for the application.
7
+ *
8
+ * @example
9
+ * this.command.register(new ExampleCommand());
10
+ */
11
+ register(): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/console/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAKnD,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAY;gBAEf,OAAO,EAAE,UAAU;IAI/B;;;;;OAKG;IACG,QAAQ;CAIf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/console/index.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ export declare class DatabaseConnection implements IDatabase {
2
+ adapter: IDatabase;
3
+ session: unknown;
4
+ constructor(adapter: IDatabase);
5
+ open(): Promise<void>;
6
+ close(): Promise<void>;
7
+ database(name: string): this;
8
+ collection(name: string): this;
9
+ listCollections(): Promise<{
10
+ name: string;
11
+ }[]>;
12
+ startSession(): IClientSession;
13
+ endSession(): Promise<void>;
14
+ startTransaction(): void;
15
+ commitTransaction(): Promise<void>;
16
+ abortTransaction(): Promise<void>;
17
+ createIndex(name: string, spec: unknown, options?: unknown): Promise<void>;
18
+ createCollection(name: string, options?: unknown): Promise<void>;
19
+ dropCollection(name: string, options?: unknown): Promise<void>;
20
+ updateSchema(name: string, schema: unknown): Promise<void>;
21
+ create(document: IDocument, options?: unknown): Promise<ICreateOutput>;
22
+ createMany(documents: IDocument[], options?: unknown): Promise<ICreateManyOutput>;
23
+ retrieveAll(query: IQuery, options?: unknown): Promise<IRetrieveAllOutput>;
24
+ retrieve(_id: string, options?: unknown): Promise<IRetrieveOutput>;
25
+ update(_id: string, document: IDocument, options?: unknown): Promise<IUpdateOutput>;
26
+ updateMany(filter: IDocument, document: IDocument, options?: unknown): Promise<IUpdateManyOutput>;
27
+ delete(_id: string, options?: unknown): Promise<IDeleteOutput>;
28
+ deleteMany(_ids: string[], options?: unknown): Promise<IDeleteManyOutput>;
29
+ deleteAll(options?: unknown): Promise<IDeleteManyOutput>;
30
+ aggregate(pipeline: IPipeline[], query: IQuery, options?: unknown): Promise<IAggregateOutput>;
31
+ }
32
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/database/connection.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,YAAW,SAAS;IAE/B,OAAO,EAAE,SAAS;IADrC,OAAO,EAAE,OAAO,CAAA;gBACG,OAAO,EAAE,SAAS;IACxB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAGrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAG5B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI5B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;I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AAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAGzE,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAGxD,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG3G"}
@@ -0,0 +1,37 @@
1
+ import type { ClientSession, Collection, CollectionOptions, CreateIndexesOptions, Db, DbOptions, IndexSpecification } from 'mongodb';
2
+ import { MongoClient } from 'mongodb';
3
+ export declare class MongoDBConnection implements IDatabase {
4
+ databaseName: string;
5
+ client: MongoClient;
6
+ _database: Db | undefined;
7
+ _collection: Collection | undefined;
8
+ session: ClientSession | undefined;
9
+ constructor(connectionString: string, databaseName: string);
10
+ open(): Promise<void>;
11
+ close(): Promise<void>;
12
+ database(name: string, options?: DbOptions): this;
13
+ collection(name: string, options?: CollectionOptions): this;
14
+ listCollections(): Promise<{
15
+ name: string;
16
+ }[]>;
17
+ createIndex(name: string, spec: IndexSpecification, options: CreateIndexesOptions): Promise<void>;
18
+ updateSchema(name: string, schema: unknown): Promise<void>;
19
+ createCollection(name: string, options: any): Promise<void>;
20
+ dropCollection(name: string, options: any): Promise<void>;
21
+ startSession(): ClientSession;
22
+ endSession(): Promise<void>;
23
+ startTransaction(): void;
24
+ commitTransaction(): Promise<void>;
25
+ abortTransaction(): Promise<void>;
26
+ create(document: IDocument, options?: unknown): Promise<ICreateOutput>;
27
+ createMany(documents: IDocument[], options?: unknown): Promise<ICreateManyOutput>;
28
+ retrieveAll(query: IQuery, options?: any): Promise<IRetrieveAllOutput>;
29
+ retrieve(_id: string, options?: any): Promise<IRetrieveOutput>;
30
+ update(_id: string, document: IDocument, options?: any): Promise<IUpdateOutput>;
31
+ updateMany(filter: IDocument[], document: IDocument[], options?: any): Promise<IUpdateManyOutput>;
32
+ delete(_id: string, options?: any): Promise<IDeleteOutput>;
33
+ deleteMany(_ids: string[], options?: any): Promise<IDeleteManyOutput>;
34
+ deleteAll(options?: any): Promise<IDeleteManyOutput>;
35
+ aggregate(pipeline: IPipeline[], query: IQuery, options?: any): Promise<IAggregateOutput>;
36
+ }
37
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,EAAE,EACF,SAAS,EAGT,kBAAkB,EAInB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,WAAW,EAAY,MAAM,SAAS,CAAA;AAK/C,qBAAa,iBAAkB,YAAW,SAAS;IAQxC,YAAY,EAAE,MAAM;IAPtB,MAAM,EAAE,WAAW,CAAA;IACnB,SAAS,EAAE,EAAE,GAAG,SAAS,CAAA;IACzB,WAAW,EAAE,UAAU,GAAG,SAAS,CAAA;IACnC,OAAO,EAAE,aAAa,GAAG,SAAS,CAAA;gBAGvC,gBAAgB,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM;IAQhB,IAAI;IAIJ,KAAK;IAIX,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;IAK1C,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB;IAS9C,eAAe,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAQ9C,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAa1D,gBAAgB,CAAC,IAAI,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AK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAwCvG"}
@@ -0,0 +1,10 @@
1
+ import { BaseError, type IError } from '@point-hub/express-error-handler';
2
+ import { MongoServerError } from 'mongodb';
3
+ export declare function handleSchemaValidation(err: MongoServerError, error: IError): void;
4
+ export declare function handleUniqueValidation(err: MongoServerError, error: IError): void;
5
+ export declare class MongoErrorHandler extends BaseError {
6
+ constructor(err: MongoServerError);
7
+ get isOperational(): boolean;
8
+ get name(): string;
9
+ }
10
+ //# sourceMappingURL=mongodb-error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-error-handler.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-error-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAQ,KAAK,MAAM,EAAoB,MAAM,kCAAkC,CAAA;AACjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,QAS1E;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,QA4B1E;AAED,qBAAa,iBAAkB,SAAQ,SAAS;gBAClC,GAAG,EAAE,gBAAgB;IAUjC,IAAI,aAAa,YAEhB;IACD,IAAa,IAAI,WAEhB;CACF"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * https://www.mongodb.com/docs/drivers/node/current/fundamentals/indexes/
3
+ * https://www.mongodb.com/docs/manual/reference/collation/
4
+ * https://www.mongodb.com/docs/manual/core/index-sparse/
5
+ * https://www.mongodb.com/docs/manual/core/index-partial/
6
+ */
7
+ export declare class MongoDBHelper {
8
+ private db;
9
+ constructor(db: IDatabase);
10
+ /**
11
+ * Create unique column
12
+ *
13
+ * @example
14
+ * create unique attribute "name"
15
+ * createUnique(collection, {
16
+ * name: -1,
17
+ * })
18
+ *
19
+ * @example
20
+ * create unique attribute for multiple column "first_name" and "last_name"
21
+ * createUnique(collection, {
22
+ * firstName: -1,
23
+ * lastName: -1,
24
+ * })
25
+ */
26
+ createUnique(collection: string, properties: object): Promise<void>;
27
+ /**
28
+ * Create unique if column is exists
29
+ */
30
+ createUniqueIfNotNull(collection: string, properties: object): Promise<void>;
31
+ isExists(name: string): Promise<boolean>;
32
+ static stringToObjectId(val: any): any;
33
+ static objectIdToString(val: any): any;
34
+ }
35
+ //# sourceMappingURL=mongodb-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-helper.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-helper.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,EAAE,CAAA;gBAEE,EAAE,EAAE,SAAS;IAIzB;;;;;;;;;;;;;;;OAeG;IACU,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAUhE;;OAEG;IACU,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAW5D,QAAQ,CAAC,IAAI,EAAE,MAAM;WAQpB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG;WAqB/B,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG;CAuB9C"}
@@ -0,0 +1,82 @@
1
+ import { SortDirection } from 'mongodb';
2
+ interface IFieldsObject {
3
+ [key: string]: number;
4
+ }
5
+ interface ISortObject {
6
+ [key: string]: SortDirection;
7
+ }
8
+ /**
9
+ * Parse query string to number
10
+ *
11
+ * @example
12
+ * page("10") // => 10
13
+ * page(10) // => 10
14
+ */
15
+ export declare function page(page?: string | number): number;
16
+ /**
17
+ * Parse query string to number
18
+ *
19
+ * @example
20
+ * limit("10") // => 10
21
+ * limit(10) // => 10
22
+ */
23
+ export declare function limit(pageSize?: string | number): number;
24
+ /**
25
+ * Skip number of data from page
26
+ *
27
+ * @example
28
+ * skip(1, 10) // => 0
29
+ * skip(2, 10) // => 10
30
+ * skip(3, 10) // => 20
31
+ */
32
+ export declare function skip(currentPage: string | number, pageSize: string | number): number;
33
+ export declare function filter(filter: never): never;
34
+ /**
35
+ * Convert string param to mongodb field object
36
+ *
37
+ * @example
38
+ * fields("name, address") // => { name: 1, address: 1 }
39
+ */
40
+ export declare function fields(fields?: string, excludeFields?: string[]): IFieldsObject;
41
+ /**
42
+ * Convert string to array
43
+ *
44
+ * @example
45
+ * convertStringToArray("name, address") // => ["name", "address"]
46
+ */
47
+ export declare function convertStringToArray(fields: string): string[];
48
+ /**
49
+ * Convert array to mongodb field object
50
+ *
51
+ * @example
52
+ * convertArrayToObject(["name", "address"]) // => { name: 1, address: 1 }
53
+ * convertArrayToObject(["name", "address"], -1) // => { name: -1, address: -1 }
54
+ */
55
+ export declare function convertArrayToObject(array: string[], value?: number): IFieldsObject;
56
+ /**
57
+ * Remove excluded fields
58
+ *
59
+ * @example
60
+ * ex: { password: 0 }
61
+ */
62
+ export declare function filterExludeFields(obj: IFieldsObject, excludeFields: string[]): IFieldsObject;
63
+ /**
64
+ * Convert string param to mongodb sort object
65
+ *
66
+ * @example
67
+ * sort("name, -createdAt") // => { name: 1, createdAt: -1 }
68
+ */
69
+ export declare function sort(fields: string): ISortObject;
70
+ declare const _default: {
71
+ page: typeof page;
72
+ limit: typeof limit;
73
+ skip: typeof skip;
74
+ sort: typeof sort;
75
+ fields: typeof fields;
76
+ filter: typeof filter;
77
+ filterExludeFields: typeof filterExludeFields;
78
+ convertStringToArray: typeof convertStringToArray;
79
+ convertArrayToObject: typeof convertArrayToObject;
80
+ };
81
+ export default _default;
82
+ //# sourceMappingURL=mongodb-querystring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-querystring.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-querystring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,UAAU,aAAa;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED,UAAU,WAAW;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,MAAM,GAAG,MAAU,GAAG,MAAM,CAMtD;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,QAAQ,GAAE,MAAM,GAAG,MAAW,GAAG,MAAM,CAM5D;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAEpF;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,KAAK,SAEnC;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,SAAK,EAAE,aAAa,GAAE,MAAM,EAAO,GAAG,aAAa,CAI/E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,SAAI,GAAG,aAAa,CAM9E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,aAAa,CAK7F;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAchD;;;;;;;;;;;;AAED,wBAUC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mongodb-querystring.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-querystring.spec.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-querystring.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import { BaseCommand } from '@point-hub/express-cli';
2
+ import { ApiError, BaseError, errorHandlerMiddleware, find, invalidPathMiddleware } from '@point-hub/express-error-handler';
3
+ import { MongoServerError } from 'mongodb';
4
+ import { ConsoleKernel } from './console';
5
+ import { DatabaseConnection } from './database/connection';
6
+ import { MongoDBConnection } from './database/mongodb/connection';
7
+ import { MongoErrorHandler } from './database/mongodb/mongodb-error-handler';
8
+ import { MongoDBHelper } from './database/mongodb/mongodb-helper';
9
+ export declare const stubDir: string;
10
+ export { ExpressCli as BaseConsoleCli } from '@point-hub/express-cli';
11
+ export declare const BaseConsoleCommand: typeof BaseCommand;
12
+ export declare const BaseConsoleKernel: typeof ConsoleKernel;
13
+ export declare const BaseDatabaseConnection: typeof DatabaseConnection;
14
+ export declare const BaseMongoDBConnection: typeof MongoDBConnection;
15
+ export declare const BaseMongoDBHelper: typeof MongoDBHelper;
16
+ export declare const BaseMongoDBQuerystring: {
17
+ page: typeof import("./database/mongodb/mongodb-querystring").page;
18
+ limit: typeof import("./database/mongodb/mongodb-querystring").limit;
19
+ skip: typeof import("./database/mongodb/mongodb-querystring").skip;
20
+ sort: typeof import("./database/mongodb/mongodb-querystring").sort;
21
+ fields: typeof import("./database/mongodb/mongodb-querystring").fields;
22
+ filter: typeof import("./database/mongodb/mongodb-querystring").filter;
23
+ filterExludeFields: typeof import("./database/mongodb/mongodb-querystring").filterExludeFields;
24
+ convertStringToArray: typeof import("./database/mongodb/mongodb-querystring").convertStringToArray;
25
+ convertArrayToObject: typeof import("./database/mongodb/mongodb-querystring").convertArrayToObject;
26
+ };
27
+ export declare const BaseMongoServerError: typeof MongoServerError;
28
+ export declare const BaseMongoErrorHandler: typeof MongoErrorHandler;
29
+ export declare const BaseErrorHandler: {
30
+ ApiError: typeof ApiError;
31
+ BaseError: typeof BaseError;
32
+ isTrustedError: (err: Error) => boolean;
33
+ getHttpError: typeof find;
34
+ errorHandlerMiddleware: typeof errorHandlerMiddleware;
35
+ invalidPathMiddleware: typeof invalidPathMiddleware;
36
+ };
37
+ export { Server as BaseServer } from './server';
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,sBAAsB,EACtB,IAAI,EACJ,qBAAqB,EAEtB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAGjE,eAAO,MAAM,OAAO,QAAqF,CAAA;AAGzG,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACrE,eAAO,MAAM,kBAAkB,oBAAc,CAAA;AAC7C,eAAO,MAAM,iBAAiB,sBAAgB,CAAA;AAE9C,eAAO,MAAM,sBAAsB,2BAAqB,CAAA;AACxD,eAAO,MAAM,qBAAqB,0BAAoB,CAAA;AACtD,eAAO,MAAM,iBAAiB,sBAAgB,CAAA;AAC9C,eAAO,MAAM,sBAAsB;;;;;;;;;;CAAc,CAAA;AACjD,eAAO,MAAM,oBAAoB,yBAAmB,CAAA;AACpD,eAAO,MAAM,qBAAqB,0BAAoB,CAAA;AAEtD,eAAO,MAAM,gBAAgB;;;;;;;CAO5B,CAAA;AAED,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,16 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="bun-types" />
3
+ import { Express } from 'express';
4
+ import { Server as HttpServer } from 'http';
5
+ export declare class Server {
6
+ app: Express;
7
+ server: HttpServer | null;
8
+ constructor(app: Express);
9
+ listen(port: number, hostname?: string): Promise<unknown>;
10
+ start(port: number, hostname?: string): Promise<void>;
11
+ stop(): void;
12
+ get host(): string;
13
+ get port(): number;
14
+ get url(): string;
15
+ }
16
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAA;AAG3C,qBAAa,MAAM;IACjB,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,EAAE,UAAU,GAAG,IAAI,CAAO;gBAEpB,GAAG,EAAE,OAAO;IAIxB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAUhC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAI3C,IAAI;IAKJ,IAAI,IAAI,WAOP;IAED,IAAI,IAAI,WAGP;IAED,IAAI,GAAG,WAEN;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.spec.d.ts","sourceRoot":"","sources":["../../src/server.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { BaseCommand } from '@point-hub/express-cli';
2
+ export default class NewCommand extends BaseCommand {
3
+ constructor();
4
+ handle(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=index.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.command.d.ts","sourceRoot":"","sources":["../../../stub/command/index.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;;IAU3C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../stub/command/index.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { NextFunction, Request, Response } from 'express';
2
+ export default function newMiddleware<T>(options?: T): (req: Request, res: Response, next: NextFunction) => void;
3
+ //# sourceMappingURL=configurable.middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configurable.middleware.d.ts","sourceRoot":"","sources":["../../../stub/middleware/configurable.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEzD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,SAC5B,OAAO,OAAO,QAAQ,QAAQ,YAAY,UAIjE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=configurable.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configurable.spec.d.ts","sourceRoot":"","sources":["../../../stub/middleware/configurable.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { NextFunction, Request, Response } from 'express';
2
+ export default function (req: Request, res: Response, next: NextFunction): void;
3
+ //# sourceMappingURL=new.middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.middleware.d.ts","sourceRoot":"","sources":["../../../stub/middleware/new.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEzD,MAAM,CAAC,OAAO,WAAW,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,QAEvE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=new.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.spec.d.ts","sourceRoot":"","sources":["../../../stub/middleware/new.spec.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@point-hub/papi",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Point API Framework",
5
5
  "type": "module",
6
- "main": "src/index.ts",
7
- "types": "lib/index.d.ts",
6
+ "main": "lib/index.js",
7
+ "types": "lib/src/index.d.ts",
8
8
  "files": [
9
9
  "lib/",
10
- "stub/",
11
- "src/"
10
+ "stub/"
12
11
  ],
13
12
  "scripts": {
14
13
  "check-types": "tsc -p tsconfig.json",