backedn converted to ts

This commit is contained in:
QkoSad
2023-07-27 15:58:35 +03:00
parent 3bf4e9fc56
commit 40051f9d5e
18 changed files with 1394 additions and 29668 deletions
+12 -10
View File
@@ -1,12 +1,14 @@
const express = require('express');
const connectDB= require('./config/db')
import express from 'express'
const path = require('path')
import connectDB from './config/db'
import path from 'path'
const app = express();
connectDB();
app.use(express.json({extended:false}));
app.use(express.json());
app.use('/api/users', require('./routers/api/users'))
@@ -15,13 +17,13 @@ app.use('/api/profile', require('./routers/api/profile'))
app.use('/api/posts', require('./routers/api/posts'))
// Serve static assets in production
if (process.env.NODE_ENV==='production'){
app.use(express.static('client/build'));
app.get('*',(req, res)=>[
res.sendFile(path.resolve(__dirname, 'client', 'build','index.html'))
])
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'));
app.get('*', (req, res) => [
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'))
])
}
const PORT = process.env.PORT || 5000;
app.listen(PORT,()=> console.log(`Server started on port ${PORT}`));
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));