apeframework 0.0.0-dev.16 → 0.0.0-dev.18

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,2 +1,2 @@
1
- type Config = Record<string, boolean | number | string>;
1
+ type Config = Record<string, any>;
2
2
  export { type Config, };
package/config/Config.ts CHANGED
@@ -1,4 +1,4 @@
1
- type Config = Record<string, boolean | number | string>
1
+ type Config = Record<string, any>
2
2
 
3
3
  export {
4
4
  type Config,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apeframework",
3
- "version": "0.0.0-dev.16",
3
+ "version": "0.0.0-dev.18",
4
4
  "license": "MIT",
5
5
  "author": "Matthieu Symoens",
6
6
  "description": "Node.js app framework",
@@ -0,0 +1,6 @@
1
+ import type { Parser } from '../../Parser';
2
+ declare const createEnumParser: <Type extends Record<string, string | number>>(params: {
3
+ type: string;
4
+ enum: Type;
5
+ }) => Parser<Type[keyof Type]>;
6
+ export { createEnumParser, };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEnumParser = void 0;
4
+ const ParseError_1 = require("../../errors/ParseError");
5
+ const createEnumParser = (params) => {
6
+ return (input) => {
7
+ if (!Object.values(params.enum).includes(input)) {
8
+ throw new ParseError_1.ParseError(params.type);
9
+ }
10
+ return input;
11
+ };
12
+ };
13
+ exports.createEnumParser = createEnumParser;
@@ -0,0 +1,21 @@
1
+ import { ParseError } from '../../errors/ParseError'
2
+ import type { Parser } from '../../Parser'
3
+
4
+ const createEnumParser = <Type extends Record<string, string | number>>(
5
+ params: {
6
+ type: string,
7
+ enum: Type,
8
+ },
9
+ ): Parser<Type[keyof Type]> => {
10
+ return (input) => {
11
+ if (!Object.values(params.enum).includes(input)) {
12
+ throw new ParseError(params.type)
13
+ }
14
+
15
+ return input
16
+ }
17
+ }
18
+
19
+ export {
20
+ createEnumParser,
21
+ }
@@ -0,0 +1,2 @@
1
+ declare const isValidIsoDate: (date: string) => boolean;
2
+ export { isValidIsoDate, };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidIsoDate = void 0;
4
+ const isValidIsoDate = (date) => {
5
+ const d = new Date(date);
6
+ return !isNaN(d.getTime()) && date === d.toISOString();
7
+ };
8
+ exports.isValidIsoDate = isValidIsoDate;
@@ -0,0 +1,9 @@
1
+ const isValidIsoDate = (date: string): boolean => {
2
+ const d = new Date(date)
3
+
4
+ return !isNaN(d.getTime()) && date === d.toISOString()
5
+ }
6
+
7
+ export {
8
+ isValidIsoDate,
9
+ }