File size: 862 Bytes
44fba65 |
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 |
import 'dotenv/config'
import express from 'express'
import nodeCleanup from 'node-cleanup'
import fileUpload from 'express-fileupload'
import routes from './routes.js'
import { init, cleanup } from './middlewares/req.js'
import cors from 'cors'
const app = express()
app.use(express.urlencoded({ extended: true }))
app.use(cors())
app.use(express.json())
app.use(fileUpload())
app.use('/api', routes)
// linking client
import path from 'path';
const currentDir = process.cwd();
app.use(express.static(path.resolve(currentDir, "./client/public")));
app.get("*", function (request, response) {
response.sendFile(path.resolve(currentDir, "./client/public", "index.html"));
});
app.listen(process.env.PORT || 3010, () => {
init()
console.log(`Whatsham server is runnin gon port ${process.env.PORT}`)
})
nodeCleanup(cleanup)
export default app
|