Socket
Socket
Sign inDemoInstall

mongoose-type-html

Package Overview
Dependencies
313
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mongoose-type-html

An html field-type with sanitize-html and dompurify options


Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

mongoose-type-html

An html field-type for Mongoose schemas. The field type can use DOMPurify and Sanitize-HTML for casting HTML values. At default only DOMPurify is enabled with default options. You can easily disable or change the options from both. To know which options you can use visit their github pages and take a look there.

npm

usage

This will cast html, correctly:

var mongoose = require('mongoose');
require('mongoose-type-html');

// Using with default options: dompurify = true / sanitizehtml = false
var UserSchema = new mongoose.Schema({
    description: mongoose.SchemaTypes.Html
});

// Using with both options on true: dompurify = true / sanitizehtml = true
var UserSchema = new mongoose.Schema({
    description: {
        type: mongoose.SchemaTypes.Html,
        dompurify: true, // You can pass an object with dompurify config too. True uses default options.
        sanitizehtml: true // You can pass an object with sanitizehtml config too. True uses default options.
    }
});

You can also use the stuff in String type:

var UserSchema = new mongoose.Schema({
    description: { type: mongoose.SchemaTypes.Html, required: true }
});

You can also use it as an array:

var UserSchema = new mongoose.Schema({
    descriptions: [{type: mongoose.SchemaTypes.Html}]
});

In typescript you only have to import it instead of requiring.

import 'mongoose-type-html';

Keywords

FAQs

Last updated on 04 Dec 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc