Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ac-convert-json-schema-to-mongoose
Advanced tools
A library for converting JSON schema to mongoose 5 schema
A translation library between JSON Schema and Mongoose Schema. Written in TypeScript.
This project was created from the ashes of json-schema-converter
. I took away
some features and made it more single purpose and added features to the
conversion.
Some of the alternatives...
npm i convert-json-schema-to-mongoose -S
import { createMongooseSchema } from 'convert-json-schema-to-mongoose';
// Or use plain javascript
// const createMongooseSchema = require('json-schema-to-mongoose').default;
// example json-schema references
const refs =
{
yep:
{
type: 'string',
pattern: '^\\d{3}$'
},
idSpec: {
type: 'object',
properties:
{
id:
{
$ref: 'yep'
}
}
}
};
// example schema to convert to mongoose schema
const schema =
{
type: 'object',
properties:
{
id:
{
$ref: 'yep'
},
address:
{
type: 'object',
properties:
{
street: {type: 'string', default: '44', pattern: '^\\d{2}$'},
houseColor: {type: 'string', default: '[Function=Date.now]', format: 'date-time'}
}
}
}
};
//Convert the schema
const mongooseSchema = createMongooseSchema(refs, schema);
//Alternative syntax, which makes it so you can convert many at one time.
// var jsonSchemas = {commonRef: ..., good: ..., schema: ..., naming: ...}
// var convert = createMongooseSchema(jsonSchemas)
// var schemaNames = ['good', 'schema', 'naming']
// var schemas = _.map(schemaNames, (name) => { return jsonSchemas[name] })
// var mongooseSchemas = _.zipObject(schemaNames, schemas.reduce((mongooseSchemas, schema) => {
// return mongooseSchemas.concat(convert(schema))
// }, []))
console.dir(mongooseSchema, {depth: null});
const Schema = new mongoose.Schema(mongooseSchema);
FAQs
A library for converting JSON schema to mongoose 5 schema
We found that ac-convert-json-schema-to-mongoose demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.