Add homepage to show all events
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
import express from 'express';
|
||||
import path from 'path';
|
||||
import payload from 'payload';
|
||||
|
||||
import findEventsOnDay from './helpers/findEventsOnDay';
|
||||
// import findEventsOnDay from './helpers/findEventsOnDay';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -30,18 +31,6 @@ payload.init({
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/', async (req, res) => {
|
||||
const docs = await payload.find({
|
||||
collection: 'events',
|
||||
sort: 'startTime',
|
||||
pagination: false
|
||||
});
|
||||
|
||||
res.json(docs);
|
||||
});
|
||||
|
||||
app.get('/day/:day', async (req, res) => {
|
||||
res.json(await findEventsOnDay(payload, req.params.day));
|
||||
});
|
||||
app.use(express.static(path.join(__dirname, '../public')));
|
||||
|
||||
app.listen(process.env.LISTEN_PORT);
|
||||
|
||||
Reference in New Issue
Block a user