-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
42 lines (31 loc) · 835 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
require('dotenv').config()
const express = require('express');
const bodyParser = require('body-parser')
const app = express();
app.use(bodyParser.json());
const textToSpeech = require('./controllers/textToSpeech');
app.post('/', (req, res) => {
if (req.body.apiKey !== process.env.API_KEY) {
res
.status(401)
.send('Unauthorized')
.end();
return;
}
var result = textToSpeech(req.body.text, req.body.languageCode, req.body.ssmlGender, req.body.name);
result.then((link) => {
console.log(result, link);
res
.status(200)
.send(link)
.end();
})
});
// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
module.exports = app;