Express сервер зависает
const express = require('express');
// const { sequelize } = require('./model/default_settings');
// const api = require('./routes/api.route');
// const auth = require('./routes/auth.route');
require('dotenv').config();
const app = express();
// (async () => await sequelize.authenticate())().then(() => console.log("Successfully authentificated"));
// app.use(express.json)
// app.use(auth)
// // auth.forEach(object => object["method"] === 'post' ? app.post(object["path"], object["func"]) : app.get(object["path"], object["func"]))
// app.use(api)
// app.use(public)
const PORT = process.env.PORT | 3000;
app.listen(PORT, console.log(`We are working on ${PORT} port`));
// В файле .env надо SALT, SECRET_KEY и опционально PORT
module.exports = { app }
const { pages } = require("./lib/path");
const { readFileSync } = require('fs');
app.get('/login/', (req, res, next) => {
const file = readFileSync(pages('login', 'index.html'), { encoding: "utf-8" })
res.end(file)
// res.socket.end()
// res.shouldKeepAlive = false
next()
})
app.get('/style/login/', (req, res, next) => {
res.sendFile(pages('login', 'style.css'))
// res.shouldKeepAlive = false
// res.socket.end()
// next()
})
При обращении в localhost:3000/login страница зависает и ничего нельзя с ним сделать