Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href] [![bundle][bundle-src]][bundle-href]
▶️ Check online playground
# npm
npm i untyped
# yarn
yarn add untyped
# pnpm
pnpm add untyped
First we have to define a reference object that describes types, defaults, and a $resolve
method (normalizer).
const defaultPlanet = {
name: 'earth',
specs: {
gravity: {
$resolve: val => parseFloat(val),
$default: '9.8'
},
moons: {
$resolve: (val = ['moon']) => [].concat(val),
$schema: {
title: 'planet moons'
}
}
}
}
resolveSchema
import { resolveSchema } from 'untyped'
const schema = await resolveSchema(defaultPlanet)
Output:
{
"properties": {
"name": {
"type": "string",
"default": "earth"
},
"specs": {
"properties": {
"gravity": {
"default": 9.8,
"type": "number"
},
"moons": {
"title": "planet moons",
"default": [
"moon"
],
"type": "array",
"items": [
{
"type": "string"
}
]
}
},
"type": "object"
}
},
"type": "object"
}
generateTypes
import { resolveSchema, generateTypes } from 'untyped'
const types = generateTypes(await resolveSchema(defaultPlanet))
Output:
interface Untyped {
/** @default "earth" */
name: string,
specs: {
/** @default 9.8 */
gravity: number,
/**
* planet moons
* @default ["moon"]
*/
moons: string[],
},
}
generateMarkdown
import { resolveSchema, generateMarkdown } from 'untyped'
const markdown = generateMarkdown(await resolveSchema(defaultPlanet))
Output:
# `name`
- **Type**: `string`
- **Default**: `"earth"`
# `specs`
## `gravity`
- **Type**: `number`
- **Default**: `9.8`
## `moons`
- **Type**: `array`
- **Default**: `["moon"]`
corepack enable
(use npm i -g corepack
for Node.js < 16.10)pnpm install
pnpm dev
pnpm web
to start playground websitepnpm test
before push to ensure all tests and lint checks passingThanks to @dominikschreiber for donating package name.
FAQs
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href] [![bundle][bundle-src]][bundle-href]
The npm package untyped receives a total of 389,819 weekly downloads. As such, untyped popularity was classified as popular.
We found that untyped demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.