removed useless code
This commit is contained in:
50
index.js
50
index.js
@@ -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}`)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user