Skip to content

Commit

Permalink
undo app.js changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahlessner committed Dec 4, 2024
1 parent 8c8d331 commit 787c4fc
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions apps/ai-image-tagging/lambda/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,26 @@ const app = express();

const FRONTEND = path.dirname(require.resolve('@contentful/ai-image-tagging-frontend'));

const computeLastModifiedTime = () => {
const deployTime = process.env.DEPLOY_TIME_UNIX;
if (typeof deployTime === 'undefined') {
throw new Error('Missing DEPLOY_TIME_UNIX env var');
}

// JS uses number of _milliseconds_ since epoch, whereas unix generates number in
// _seconds_ since epoch. So we have to convert
const epochTime = Number(deployTime) * 1000;
return new Date(epochTime).toUTCString();
};
// const computeLastModifiedTime = () => {
// const deployTime = process.env.DEPLOY_TIME_UNIX;
// if (typeof deployTime === 'undefined') {
// throw new Error('Missing DEPLOY_TIME_UNIX env var');
// }

// // JS uses number of _milliseconds_ since epoch, whereas unix generates number in
// // _seconds_ since epoch. So we have to convert
// const epochTime = Number(deployTime) * 1000;
// return new Date(epochTime).toUTCString();
// };

app.use('/tags', async (req, res) => {
const { status, body } = await handle(req.method, req.path, deps);
res.status(status).json(body);
});

const lastModified = computeLastModifiedTime();

app.use(
'/frontend',
express.static(FRONTEND, {
lastModified,
setHeaders: (res) => {
res.setHeader('Last-Modified', lastModified);
},
})
);
// const lastModified = computeLastModifiedTime();

app.use('/frontend', express.static(FRONTEND));
app.use((_req, res) => res.status(404).send('Not found'));

module.exports = app;

0 comments on commit 787c4fc

Please sign in to comment.