You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
640 B
25 lines
640 B
import express from 'express';
|
|
import bodyParser from 'body-parser';
|
|
import cors from 'cors';
|
|
import {get_client, init_db, insert_one} from './src/utils/database.js';
|
|
import UserRoute from "./src/routes/user.route.js";
|
|
import dotenv from "dotenv";
|
|
|
|
dotenv.config();
|
|
|
|
const app = express();
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
app.use(cors());
|
|
app.use(bodyParser.json());
|
|
app.use(bodyParser.urlencoded({ extended: true }));
|
|
app.use(express.static('public'));
|
|
|
|
app.use('/api/users', UserRoute)
|
|
|
|
await get_client();
|
|
await init_db('mydatabase');
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`Server is running on http://localhost:${PORT}`);
|
|
})
|