summaryrefslogtreecommitdiff
path: root/api/server.js
blob: a6cb48c4f9b50fe8b521c92c6e73257a02dd97a1 (plain) (blame)
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
const express = require('express');
const cors = require('cors');
const quotesRouter  = require('./routes/quotes');

const app = express();
const PORT = 3000;

const createServer = () => {
    app.use(cors()); // Allow cross-origin requests
    app.use(express.json());

    app.use('/api', quotesRouter);

    app.get('/api/version', (req, res) => {
        const { abVersion } = require('../storage/settings.json');
        res.json(abVersion);

    });

    // Start the server
    app.listen(PORT, () => {
        console.log(`Server is running on http://localhost:${PORT}`);
    });
};

module.exports = createServer;