Created
October 7, 2019 18:26
-
-
Save deepal/0926cf5a1515e9ed589b55c663f4b4a8 to your computer and use it in GitHub Desktop.
BCrypt Server with Thread Pool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const {WorkerPool} = require('./pool'); | |
| const app = express(); | |
| // Create a new worker pool to run script ./task.js | |
| const pool = new WorkerPool('./task.js', 4); | |
| app.get('/', (req, res) => { | |
| const plainText = req.query.text; | |
| pool.runWithArg(plainText, (err, enc) => { | |
| if (err) return console.error(err); | |
| return res.status(200).send(enc); | |
| }); | |
| }); | |
| app.listen(8081); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment