Created
April 6, 2018 12:25
-
-
Save mykeels/48ac39144df03c0cf1499dc6b546cef5 to your computer and use it in GitHub Desktop.
Fork of https://gist.github.com/mykeels/8396f87d42a809697d08f6b6c9cd8db0 to show request-no-memoization
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 textBodyParser = require('body-parser').text() | |
const isPrime = require('./is-prime') | |
const app = express() | |
app.post('/', textBodyParser, (req, res) => { | |
res.send(req.body.split('\n').map((line) => line.split('').reverse().join('')).join('\n')) | |
}) | |
app.get('/', (req, res) => { | |
const primes = [] | |
const max = Number(req.query.max) || 1000 | |
for (let i = 1; i <= max; i++) { | |
if (isPrime(i)) primes.push(i) | |
} | |
res.json(primes) | |
}) | |
app.listen(process.env.PORT || 3030) | |
console.log('app is running!') | |
module.exports = app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment