Files
getting-started/nodejs/node-csv-importer/server/index.js
Arpendu Kumar Garai cd69fa5842 code example for CSV Importer with Node
Co-authored-by: Arpendu Kumar Garai <Arpendu.KumarGarai@microfocus.com>
2022-12-05 09:50:13 +11:00

28 lines
651 B
JavaScript

import express from 'express';
import path from 'path';
import cors from 'cors';
import initRoutes from './routes/index.js';
global.__basedir = path.resolve() + "/..";
const app = express();
var corsOptions = {
origin: "http://localhost:3000"
};
app.use(cors(corsOptions));
// parse requests of content-type - application/json
app.use(express.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: true }));
initRoutes(app);
// set port, listen for requests
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});