Go to file
2022-01-14 21:33:00 +00:00
src add ability to access from cli 2022-01-14 14:44:54 -06:00
.env Add minimal proof of concept 2022-01-14 14:39:29 -06:00
.gitignore Add minimal proof of concept 2022-01-14 14:39:29 -06:00
package.json Add minimal proof of concept 2022-01-14 14:39:29 -06:00
pnpm-lock.yaml Add minimal proof of concept 2022-01-14 14:39:29 -06:00
README.md Update 'README.md' 2022-01-14 21:33:00 +00:00
tsconfig.json Add minimal proof of concept 2022-01-14 14:39:29 -06:00

Extollo runtime type validation proof-of-concept

You can read more about this proof-of-concept here:

https://garrettmills.dev/blog/2022/01/14/Runtime-Data-Validation-from-TypeScript-Interfaces/

To run it:

pnpm i
pnpm build

The intermediate files are generated in the exbuild/ directory, and the final compiled output is in the lib/ directory.

Access the Zod schema:

node --experimental-repl-await lib/cli.js shell
powered by Extollo, © 2022 Garrett Mills
Access your application using the "app" global.
(extollo) ➤ Home = require('./lib/app/http/controllers/main/Home.controller').Home
[class Home extends Controller]
(extollo) ➤ home = new Home
Home { request: undefined }
(extollo) ➤ home.getValidator().getZod().shape
{
  username: ZodString {
    spa: [Function (anonymous)],
    superRefine: [Function (anonymous)],
    _def: { checks: [Array], typeName: 'ZodString' },
    transform: [Function: bound ],
    default: [Function: bound ],
    _regex: [Function (anonymous)],
    nonempty: [Function (anonymous)]
  },
  password: ZodString {
    spa: [Function (anonymous)],
    superRefine: [Function (anonymous)],
    _def: { checks: [Array], typeName: 'ZodString' },
    transform: [Function: bound ],
    default: [Function: bound ],
    _regex: [Function (anonymous)],
    nonempty: [Function (anonymous)]
  },
  rememberMe: ZodOptional {
    spa: [Function (anonymous)],
    superRefine: [Function (anonymous)],
    _def: { innerType: [ZodBoolean], typeName: 'ZodOptional' },
    transform: [Function: bound ],
    default: [Function: bound ]
  }
}