This commit is contained in:
2025-02-01 22:35:39 +09:00
parent c164491dcb
commit fa10a84380
6 changed files with 6328 additions and 19 deletions

View File

@@ -1,8 +1,45 @@
require('dotenv').config()
const express = require('express')
const sequelize = require('./db')
const PORT = process.env.PORT || 5000
const app = express()
app.listen(PORT, () => console.log(`Server started on port ${PORT}`))
process.on('uncaughtException', function (err) {
console.log(err);
});
/* const nachalo = async () => {
try {
await sequelize.authenticate()
await sequelize.sync()
app.listen(PORT, () => console.log(`Server started on port http://localhost:${PORT}`))
} catch(errors) {
console.log(errors)
}
}
nachalo() */
app.get('/api/data', (req, res) => {
db.query('SELECT * FROM your_table', (error, results) => {
if (error) throw error;
res.json(results);
});
});
app.listen(PORT, () => {
console.log(`Сервер запущен на порту http://localhost:${PORT}`);
});
app.get('/', (req, res) => {
res.send('Welcome to the homepage!');
});