-
Notifications
You must be signed in to change notification settings - Fork 32
/
server.js
27 lines (24 loc) · 749 Bytes
/
server.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
require("dotenv").config();
const express = require("express");
const path = require("path");
const { AssemblyAI } = require("assemblyai");
const aai = new AssemblyAI({ apiKey: process.env.ASSEMBLYAI_API_KEY });
const app = express();
app.use(express.static("public"));
app.use(
"/assemblyai.js",
express.static(
path.join(__dirname, "node_modules/assemblyai/dist/assemblyai.umd.js"),
),
);
app.use(express.json());
app.get("/token", async (_req, res) => {
const token = await aai.realtime.createTemporaryToken({ expires_in: 3600 });
res.json({ token });
});
app.set("port", 8000);
const server = app.listen(app.get("port"), () => {
console.log(
`Server is running on port http://localhost:${server.address().port}`,
);
});