removed useless code

This commit is contained in:
slawk0
2024-08-19 21:50:14 +02:00
parent 229a9f5b18
commit 9f568f4515
2 changed files with 18 additions and 32 deletions

View File

@@ -7,42 +7,28 @@ const port = 3000
const app = express()
require('dotenv').config()
const main = async () => {
const client = new Client({
user: process.env.PG_USER,
password: process.env.PG_PASSWORD,
database: process.env.PG_DATABASE,
host: process.env.PG_HOST,
});
await client.connect();
try {
console.log(await client.query('SELECT 1'));
} finally {
await client.end();
}
};
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, 'static')));
main().catch(console.error);
app.use(session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true
}));
app.get('/', (req, res) => {
const main = async () => {
const client = new Client({
user: process.env.PG_USER,
password: process.env.PG_PASSWORD,
database: process.env.PG_DATABASE,
host: process.env.PG_HOST,
});
await client.connect();
try {
console.log(await client.query('SELECT 1'));
} finally {
await client.end();
}
};
const client = new Client({
user: process.env.PG_USER,
password: process.env.PG_PASSWORD,
database: process.env.PG_DATABASE,
host: process.env.PG_HOST,
});
res.send('Hello World!')
app.get('/login', (req, res) => {
response.sendFile(path.join(__dirname + '/routes/login.html'));
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
})