Skip to content

Repository files navigation

Content Moderator | APIVerve Template

License: MIT Node.js Express APIVerve | Profanity Filter

Clean up comments, reviews and chat before they go live. Paste any text and get it back with profanity masked, plus how many words were caught.

Deploy with Vercel

Content Moderator masking two words in a product review


Get your free API key

This template needs an APIVerve API key. Sign up free, no credit card required.


Deploy in one click

Click Deploy with Vercel above. Vercel copies this repo to your GitHub account, asks for your APIVERVE_API_KEY, and gives you a live URL about a minute later.

Run it locally

  1. Clone the repository

    git clone https://github.com/apiverve/content-moderator-node-tutorial.git
    cd content-moderator-node-tutorial
  2. Install dependencies

    npm install
  3. Add your API key

    cp .env.example .env

    Then open .env and set APIVERVE_API_KEY.

  4. Start the server

    npm run dev
  5. Open http://localhost:3000

How it works

  1. The page in public/index.html calls POST /api/moderate on this server.
  2. server.js checks the input, then calls Profanity Filter. Your API key stays on the server and never reaches the browser.
  3. The page shows the result.
├── server.js            # Express: the /api route that calls APIVerve
├── public/index.html    # The page (HTML, CSS and JavaScript)
├── .env.example         # Copy to .env and add your key
└── package.json

The API call

const res = await fetch('https://api.apiverve.com/v1/profanityfilter', {
  method: 'POST',
  headers: { 'x-api-key': process.env.APIVERVE_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ text, mask: '*' })
});
const { data } = await res.json();
// data.filteredText, data.isProfane, data.profaneWords

Before you share your URL

Once deployed, anyone who finds your URL can use it on your API key. Each visitor can make 10 requests a minute, which is fine for a demo. The limit is kept in memory, so it isn't shared between serverless instances. For production:

  • Put the page behind your own sign-in, or
  • Move the limit to a shared store such as Upstash Redis, or
  • Call the route only from your own backend.

Ideas to extend it

  • Mask comments on save, and keep the original for moderators
  • Hold posts with several flagged words for review instead of publishing
  • Add Sentiment Analysis to spot hostile posts that use no profanity

API reference

Tech stack

  • Node.js 20+ and Express 4
  • Plain HTML, CSS and JavaScript, no build step
  • Deploys to Vercel as-is: server.js becomes one function and public/ is served from the CDN

License

MIT. See LICENSE.

About

Content moderation template for Node.js and Express: mask profanity in comments and reviews. Deploy to Vercel in one click.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages