mirror of
https://github.com/mariadb-corporation/dev-example-places.git
synced 2025-07-25 15:01:26 +00:00
29 lines
739 B
JavaScript
29 lines
739 B
JavaScript
const express = require('express');
|
|
const app = express();
|
|
const port = 8080;
|
|
const path = require('path');
|
|
const bodyParser = require("body-parser");
|
|
|
|
const locationRoutes = require("./routes/locationRoutes");
|
|
|
|
app.use(bodyParser.json());
|
|
app.use(bodyParser.urlencoded({ extended: false }));
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
app.use(express.static('client/build'));
|
|
}
|
|
|
|
app.use("/api/locations", locationRoutes);
|
|
|
|
app.get("/*", (req, res) => {
|
|
res.sendFile(path.join(__dirname, "/client/build/index.html"));
|
|
});
|
|
|
|
app.use((err, req, res, next) => {
|
|
res.status(422).send({ error: err._message });
|
|
});
|
|
|
|
// console.log that your server is up and running
|
|
app.listen(port, () => console.log(`Listening on port ${port}`));
|
|
|